Commit 38acfa5355000dccb93f37b165063c4c50cc2bc9
1 parent
68badb4b
Exists in
master
and in
5 other branches
fixed activity and material models, changed base.html on notifications
Showing
6 changed files
with
153 additions
and
5 deletions
Show diff stats
core/templates/base.html
... | ... | @@ -85,7 +85,14 @@ |
85 | 85 | {% endif %} |
86 | 86 | {% endfor %} |
87 | 87 | |
88 | - <div> <p>See more</p> </div> | |
88 | + <li> | |
89 | + <a> | |
90 | + <div class="list-group-item"> | |
91 | + <div class="row-content"> | |
92 | + <p class="list-group-item-text">See More</p> | |
93 | + </div> | |
94 | + </a> | |
95 | + </li> | |
89 | 96 | </ul> |
90 | 97 | </li> |
91 | 98 | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +# -*- coding: utf-8 -*- | |
2 | +# Generated by Django 1.10 on 2016-09-26 03:26 | |
3 | +from __future__ import unicode_literals | |
4 | + | |
5 | +import autoslug.fields | |
6 | +from django.db import migrations, models | |
7 | + | |
8 | + | |
9 | +class Migration(migrations.Migration): | |
10 | + | |
11 | + dependencies = [ | |
12 | + ('courses', '0001_initial'), | |
13 | + ] | |
14 | + | |
15 | + operations = [ | |
16 | + migrations.CreateModel( | |
17 | + name='SubjectCategory', | |
18 | + fields=[ | |
19 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
20 | + ('name', models.CharField(max_length=100, verbose_name='Name')), | |
21 | + ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name', unique=True, verbose_name='Slug')), | |
22 | + ('description', models.TextField(blank=True, verbose_name='Description')), | |
23 | + ('subjects', models.ManyToManyField(to='courses.Subject')), | |
24 | + ], | |
25 | + options={ | |
26 | + 'verbose_name_plural': 'subject categories', | |
27 | + 'verbose_name': 'subject category', | |
28 | + }, | |
29 | + ), | |
30 | + migrations.RemoveField( | |
31 | + model_name='activity', | |
32 | + name='create_date', | |
33 | + ), | |
34 | + migrations.RemoveField( | |
35 | + model_name='material', | |
36 | + name='create_date', | |
37 | + ), | |
38 | + ] | ... | ... |
courses/models.py
... | ... | @@ -88,7 +88,6 @@ It is one kind of possible resources available inside a Topic. |
88 | 88 | Activity is something that has a deadline and has to be delivered by the student |
89 | 89 | """ |
90 | 90 | class Activity(Resource): |
91 | - create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) | |
92 | 91 | topic = models.ForeignKey(Topic, verbose_name = _('Topic')) |
93 | 92 | limit_date = models.DateTimeField(_('Deliver Date')) |
94 | 93 | student = models.ForeignKey(User, verbose_name = _('student')) |
... | ... | @@ -98,8 +97,21 @@ class Activity(Resource): |
98 | 97 | It represents any Material inside a topic, be it a file, a link, etc. |
99 | 98 | """ |
100 | 99 | class Material(Resource): |
101 | - create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True) | |
102 | 100 | topic = models.ForeignKey(Topic, verbose_name = _('Topic')) |
103 | 101 | student = models.ForeignKey(User, verbose_name = _('student')) |
104 | 102 | |
105 | 103 | |
104 | + | |
105 | + | |
106 | +""" | |
107 | +It is a category for each subject. | |
108 | +""" | |
109 | +class SubjectCategory(models.Model): | |
110 | + name = models.CharField(_('Name'), max_length= 100) | |
111 | + slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) | |
112 | + description = models.TextField(_('Description'), blank = True) | |
113 | + subjects = models.ManyToManyField(Subject) | |
114 | + | |
115 | + class Meta: | |
116 | + verbose_name = _('subject category') | |
117 | + verbose_name_plural = _('subject categories') | ... | ... |
... | ... | @@ -0,0 +1,77 @@ |
1 | +{% extends 'base.html' %} | |
2 | + | |
3 | +{% load static i18n permission_tags %} | |
4 | + | |
5 | +{% block breadcrumbs %} | |
6 | + | |
7 | + <ol class="breadcrumb"> | |
8 | + <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li> | |
9 | + | |
10 | + | |
11 | + </ol> | |
12 | +{% endblock %} | |
13 | + | |
14 | +{% block sidebar %} | |
15 | + | |
16 | + <div class="panel panel-primary"> | |
17 | + | |
18 | + <div class="panel-heading"> | |
19 | + <h3 class="panel-title">{{course}}</h3> | |
20 | + </div> | |
21 | + | |
22 | + <div class="panel-body"> | |
23 | + {% for category in subject_categories %} | |
24 | + <div class="row"> | |
25 | + <div class="col-md-12 col-sm-12"> | |
26 | + <a href="" class="btn btn-default text-left">{{subject}}</a> | |
27 | + </div> | |
28 | + </div> | |
29 | + {% endfor %} | |
30 | + </div> | |
31 | + </div> | |
32 | + | |
33 | + {% if user|has_role:'system_admin' or user|has_role:'professor' %} | |
34 | + <a href="" class="btn btn-primary btn-md btn-block">{% trans "Create Subject Category" %}</a> | |
35 | + {% endif %} | |
36 | +{% endblock %} | |
37 | + | |
38 | +{% block content %} | |
39 | + <div class="panel panel-info"> | |
40 | + <div class="panel-heading"> | |
41 | + <div class="row"> | |
42 | + <div class="col-md-7 col-sm-7"> | |
43 | + <h3>{{subject}}</h3> | |
44 | + </div> | |
45 | + <div class="col-md-2 col-sm-2"> | |
46 | + {% if user|has_role:'system_admin' or user in subject.professors %} | |
47 | + <a href="" class="btn">{% trans "edit" %}</a> | |
48 | + {% endif %} | |
49 | + </div> | |
50 | + <div class="col-md-3 col-sm-3"> | |
51 | + {% if user|has_role:'system_admin' or user in subject.professors %} | |
52 | + <a href="" class="btn">{% trans "delete" %}</a> | |
53 | + {% endif %} | |
54 | + </div> | |
55 | + </div> | |
56 | + </div> | |
57 | + <div class="panel-body"> | |
58 | + <p> | |
59 | + {{subject.description|linebreaks}} | |
60 | + </p> | |
61 | + </div> | |
62 | + </div> | |
63 | + | |
64 | + | |
65 | +{% endblock %} | |
66 | + | |
67 | +{% block rightbar %} | |
68 | + | |
69 | + <div class="panel panel-warning"> | |
70 | + <div class="panel-heading"> | |
71 | + <h3 class="panel-title">{% trans "Pending Stuffs" %}</h3> | |
72 | + </div> | |
73 | + <div class="panel-body"> | |
74 | + | |
75 | + </div> | |
76 | + </div> | |
77 | +{% endblock rightbar %} | |
0 | 78 | \ No newline at end of file | ... | ... |
courses/urls.py
... | ... | @@ -20,5 +20,6 @@ urlpatterns = [ |
20 | 20 | url(r'^subjects/delete/(?P<slug>[\w_-]+)/$', views.DeleteSubjectView.as_view(), name='delete_subject'), |
21 | 21 | url(r'^topics/create/(?P<slug>[\w_-]+)/$', views.CreateTopicView.as_view(), name='create_topic'), |
22 | 22 | url(r'^topics/update/(?P<slug>[\w_-]+)/$', views.UpdateTopicView.as_view(), name='update_topic'), |
23 | - url(r'^topics/(?P<slug>[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic') | |
23 | + url(r'^topics/(?P<slug>[\w_-]+)/$', views.TopicsView.as_view(), name='view_topic'), | |
24 | + url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), | |
24 | 25 | ] | ... | ... |
courses/views.py
... | ... | @@ -12,7 +12,7 @@ from django.db.models import Q |
12 | 12 | from rolepermissions.verifications import has_object_permission |
13 | 13 | |
14 | 14 | from .forms import CourseForm, UpdateCourseForm, CategoryForm, SubjectForm,TopicForm |
15 | -from .models import Course, Subject, Category,Topic | |
15 | +from .models import Course, Subject, Category,Topic, SubjectCategory | |
16 | 16 | from core.mixins import NotificationMixin |
17 | 17 | from users.models import User |
18 | 18 | |
... | ... | @@ -441,3 +441,16 @@ class DeleteSubjectView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
441 | 441 | |
442 | 442 | def get_success_url(self): |
443 | 443 | return reverse_lazy('course:view', kwargs={'slug' : self.object.course.slug}) |
444 | + | |
445 | +class IndexSubjectCategoryView(LoginRequiredMixin, generic.ListView): | |
446 | + allowed_roles = ['professor', 'system_admin'] | |
447 | + login_url = reverse_lazy("core:home") | |
448 | + redirect_field_name = 'next' | |
449 | + model = SubjectCategory | |
450 | + template_name = 'subject_category/index.html' | |
451 | + paginate_by = 10 | |
452 | + | |
453 | + def get_context_data(self, **kwargs): | |
454 | + context = super(IndexSubjectCategoryView, self).get_context_data(**kwargs) | |
455 | + context['subject_categories'] = SubjectCategory.objects.all() | |
456 | + return context | |
444 | 457 | \ No newline at end of file | ... | ... |