Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
Add simple readinweb models
Browse files Browse the repository at this point in the history
Add riw app
  • Loading branch information
AllanNozomu committed Sep 6, 2016
1 parent 07ea753 commit c75af99
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 3 deletions.
6 changes: 4 additions & 2 deletions config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# custom users app
'readinweb.users.apps.UsersConfig',
# Your stuff: custom apps go here
'readinweb.riw',
)

# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
Expand Down Expand Up @@ -83,7 +84,8 @@

# EMAIL CONFIGURATION
# ------------------------------------------------------------------------------
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
# EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# MANAGER CONFIGURATION
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -111,7 +113,7 @@
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'UTC-03:00'
TIME_ZONE = 'America/Sao_Paulo'

# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = 'en-us'
Expand Down
2 changes: 2 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
url(r'^users/', include('readinweb.users.urls', namespace='users')),
url(r'^accounts/', include('allauth.urls')),


# Your stuff: custom urls includes go here
url(r'^riw/', include('readinweb.riw.urls')),


] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Expand Down
Empty file added readinweb/riw/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions readinweb/riw/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions readinweb/riw/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class RiwConfig(AppConfig):
name = 'riw'
124 changes: 124 additions & 0 deletions readinweb/riw/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from django.db import models

class Course (models.Model):
name = models.CharField (max_length=150)
def __str__(self) :
return self.name


class Course_class (models.Model):
# Foreign Keys
course = models.ForeignKey('Course')
instructor = models.ForeignKey('users.User')

title = models.CharField(max_length=150)
created_at = models.DateTimeField()
started_at = models.DateTimeField(null=True, blank= True)
finished_at = models.DateTimeField(null=True, blank= True)
enrolling = models.BooleanField(default=False)
max_students = models.IntegerField()

class Meta:
verbose_name_plural = "Course classes"

class Module(models.Model):
title = models.CharField(max_length=100)

def __str__(self) :
return self.title

class Activity(models.Model):
# Foreign Keys
course = models.ForeignKey('Course')
module = models.ForeignKey('Module')

title = models.CharField(max_length=150)
content = models.TextField()
course_position = models.IntegerField()

class Meta:
verbose_name_plural = "Activities"

def __str__(self) :
return self.title

class Exercise(models.Model):
# Foreign Keys
activity = models.ForeignKey('Activity')

content = models.TextField()

class Meta:
verbose_name_plural = "Exercises"

class Grammar(models.Model):
# Foreign Keys
module = models.ForeignKey('Module')

content = models.TextField()

class Meta:
verbose_name_plural = "Grammars"

class Strategy(models.Model):
# Foreign Keys
module = models.ForeignKey('Module')

content = models.TextField()
reading = models.BooleanField()

class Meta:
verbose_name_plural = "Strategies"

class Functional_word(models.Model):
# Foreign Keys
module = models.ForeignKey('Module')

word = models.CharField(max_length=50)
meaning = models.CharField(max_length=100)

class Meta:
verbose_name_plural = "Functional Words"


class Glossary(models.Model):
# Foreign Keys
module = models.ForeignKey('Module')

word = models.CharField(max_length=50)
translation = models.CharField(max_length=100)

class Meta:
verbose_name_plural = "Glossaries"


class Activity_released(models.Model):
# Foreign Keys
course_class = models.ForeignKey('Course_class')
activity = models.ForeignKey('activity')

released = models.BooleanField()

class Meta:
verbose_name_plural = "Released Activities"

class Student_progress(models.Model):
# Foreign Keys
student = models.ForeignKey('users.User')
activity = models.ForeignKey('Activity')
course_class = models.ForeignKey('Course_class')

complete = models.BooleanField()

class Meta:
verbose_name_plural = "Students Progress"

class Allowed_student(models.Model):
# Foreign Keys
student = models.ForeignKey('users.User')

course_class = models.ForeignKey('Course_class')
allowed = models.BooleanField()

class Meta:
verbose_name_plural = "Allowed Students"
3 changes: 3 additions & 0 deletions readinweb/riw/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
10 changes: 10 additions & 0 deletions readinweb/riw/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.conf.urls import include, url
from . import views

urlpatterns = [
url(r'^$', views.ClassListView.as_view(), name='list'),
]
12 changes: 12 additions & 0 deletions readinweb/riw/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.shortcuts import render
from django.views.generic import DetailView, ListView, RedirectView, UpdateView
from django.contrib.auth.mixins import LoginRequiredMixin

from .models import *

# Create your views here.
class ClassListView(ListView):
model = Course
# These next two lines tell the view to index lookups by username
# slug_field = 'username'
# slug_url_kwarg = 'username'
35 changes: 35 additions & 0 deletions readinweb/templates/riw/course_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base.html" %}
{% load static %}

{% block title %}User: {{ object.name }}{% endblock %}

{% block content %}
<div class="container">

<div class="row">
<div class="col-sm-12">

<h2>{{ object.name }}</h2>
{% if object.name %}
<p>{{ object.name }}</p>
{% endif %}
</div>
</div>

{% if object == request.user %}
<!-- Action buttons -->
<div class="row">

<div class="col-sm-12 ">
<a class="btn btn-primary" href="{% url 'users:update' %}">My Info</a>
<a class="btn btn-primary" href="{% url 'account_email' %}">E-Mail</a>
<!-- Your Stuff: Custom user template urls -->
</div>

</div>
<!-- End Action buttons -->
{% endif %}


</div>
{% endblock content %}
22 changes: 22 additions & 0 deletions readinweb/templates/riw/course_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "base.html" %}
{% load static %}{% load i18n %}
{% block title %}Course{% endblock %}

{% block content %}

<div class="container">

<h2>Courses</h2>

<div class="list-group">
{% for course in course_list %}
<a href="{% url 'users:detail' user.username %}" class="list-group-item">
<h4 class="list-group-item-heading">{{ course.name }}</h4>
</a>
{% endfor %}

</div>

</div>

{% endblock content %}
1 change: 0 additions & 1 deletion readinweb/templates/users/user_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ <h2>{{ object.username }}</h2>

</div>
{% endblock content %}

0 comments on commit c75af99

Please sign in to comment.