Commit 61a6e5fd01379a141538d0ee62dd72d5004fced0
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
45 changed files
with
474 additions
and
370 deletions
Show diff stats
amadeus/settings.py
... | ... | @@ -47,14 +47,16 @@ INSTALLED_APPS = [ |
47 | 47 | 'rolepermissions', |
48 | 48 | 'rest_framework', |
49 | 49 | 'django_bootstrap_breadcrumbs', |
50 | + 's3direct', | |
50 | 51 | |
52 | + 'users', | |
51 | 53 | 'core', |
52 | 54 | 'app', |
53 | 55 | 'courses', |
54 | - 'users', | |
55 | 56 | 'forum', |
56 | 57 | 'poll', |
57 | - 's3direct', | |
58 | + 'avaliacao', | |
59 | + | |
58 | 60 | ] |
59 | 61 | |
60 | 62 | MIDDLEWARE_CLASSES = [ |
... | ... | @@ -205,7 +207,6 @@ S3DIRECT_DESTINATIONS = { |
205 | 207 | |
206 | 208 | } |
207 | 209 | |
208 | - | |
209 | 210 | try: |
210 | 211 | from .local_settings import * |
211 | 212 | except ImportError: | ... | ... |
amadeus/urls.py
... | ... | @@ -23,7 +23,6 @@ urlpatterns = [ |
23 | 23 | url(r'^home/', include('app.urls', namespace = 'app')), |
24 | 24 | url(r'^course/', include('courses.urls', namespace = 'course')), |
25 | 25 | url(r'^users/', include('users.urls', namespace = 'users')), |
26 | - url(r'^forum/', include('forum.urls', namespace = 'forum')), | |
27 | 26 | url(r'^admin/', admin.site.urls), |
28 | 27 | url(r'^', include('core.urls', namespace = 'core')), |
29 | 28 | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +from django.utils.translation import ugettext_lazy as _ | |
2 | +from django.db import models | |
3 | +from autoslug.fields import AutoSlugField | |
4 | +from users.models import User | |
5 | +from core.models import Resource | |
6 | +from courses.models import Activity | |
7 | + | |
8 | +class Avaliacao(Activity): | |
9 | + | |
10 | + name_avalicao = models.CharField(_('Name'), max_length = 100) | |
11 | + init_date = models.DateField(_('Begin of Avaliacao Date')) | |
12 | + end_date = models.DateField(_('End of Avaliacao Date')) | |
13 | + | |
14 | + class Meta: | |
15 | + #ordering = ('create_date','name') | |
16 | + verbose_name = _('Avaliacao') | |
17 | + verbose_name_plural = _('Avaliacoes') | |
18 | + | |
19 | +def __str__(self): | |
20 | + return str(self.name) + str("/") + str(self.topic) | ... | ... |
core/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
2 | +# Generated by Django 1.10 on 2016-10-05 02:05 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | 5 | import autoslug.fields |
6 | +from django.conf import settings | |
6 | 7 | from django.db import migrations, models |
7 | 8 | import django.db.models.deletion |
8 | 9 | |
... | ... | @@ -12,6 +13,7 @@ class Migration(migrations.Migration): |
12 | 13 | initial = True |
13 | 14 | |
14 | 15 | dependencies = [ |
16 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
15 | 17 | ] |
16 | 18 | |
17 | 19 | operations = [ |
... | ... | @@ -23,18 +25,19 @@ class Migration(migrations.Migration): |
23 | 25 | ('created_date', models.DateField(auto_now_add=True, verbose_name='Created Date')), |
24 | 26 | ], |
25 | 27 | options={ |
26 | - 'verbose_name': 'Action', | |
27 | 28 | 'verbose_name_plural': 'Actions', |
29 | + 'verbose_name': 'Action', | |
28 | 30 | }, |
29 | 31 | ), |
30 | 32 | migrations.CreateModel( |
31 | 33 | name='Action_Resource', |
32 | 34 | fields=[ |
33 | 35 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
36 | + ('action', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action', verbose_name='Action_Applied')), | |
34 | 37 | ], |
35 | 38 | options={ |
36 | - 'verbose_name': 'Action_Resource', | |
37 | 39 | 'verbose_name_plural': 'Action_Resources', |
40 | + 'verbose_name': 'Action_Resource', | |
38 | 41 | }, |
39 | 42 | ), |
40 | 43 | migrations.CreateModel( |
... | ... | @@ -42,10 +45,12 @@ class Migration(migrations.Migration): |
42 | 45 | fields=[ |
43 | 46 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
44 | 47 | ('datetime', models.DateTimeField(auto_now_add=True, verbose_name='Date and Time of action')), |
48 | + ('action_resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action_Resource', verbose_name='Action_Resource')), | |
49 | + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Actor')), | |
45 | 50 | ], |
46 | 51 | options={ |
47 | - 'verbose_name': 'Log', | |
48 | 52 | 'verbose_name_plural': 'Logs', |
53 | + 'verbose_name': 'Log', | |
49 | 54 | }, |
50 | 55 | ), |
51 | 56 | migrations.CreateModel( |
... | ... | @@ -56,10 +61,12 @@ class Migration(migrations.Migration): |
56 | 61 | ('read', models.BooleanField(default=False, verbose_name='Read')), |
57 | 62 | ('datetime', models.DateTimeField(auto_now_add=True, verbose_name='Date and Time of action')), |
58 | 63 | ('action_resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action_Resource', verbose_name='Action_Resource')), |
64 | + ('actor', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notification_Performer', to=settings.AUTH_USER_MODEL, verbose_name='Perfomer')), | |
65 | + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notification_Actor', to=settings.AUTH_USER_MODEL, verbose_name='User')), | |
59 | 66 | ], |
60 | 67 | options={ |
61 | - 'verbose_name': 'Notification', | |
62 | 68 | 'verbose_name_plural': 'Notifications', |
69 | + 'verbose_name': 'Notification', | |
63 | 70 | }, |
64 | 71 | ), |
65 | 72 | migrations.CreateModel( |
... | ... | @@ -72,8 +79,13 @@ class Migration(migrations.Migration): |
72 | 79 | ('url', models.CharField(default='', max_length=100, verbose_name='URL')), |
73 | 80 | ], |
74 | 81 | options={ |
75 | - 'verbose_name': 'Resource', | |
76 | 82 | 'verbose_name_plural': 'Resources', |
83 | + 'verbose_name': 'Resource', | |
77 | 84 | }, |
78 | 85 | ), |
86 | + migrations.AddField( | |
87 | + model_name='action_resource', | |
88 | + name='resource', | |
89 | + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Resource', verbose_name='Resource'), | |
90 | + ), | |
79 | 91 | ] | ... | ... |
core/migrations/0002_auto_20161001_2117.py
... | ... | @@ -1,50 +0,0 @@ |
1 | -# -*- coding: utf-8 -*- | |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
3 | -from __future__ import unicode_literals | |
4 | - | |
5 | -from django.conf import settings | |
6 | -from django.db import migrations, models | |
7 | -import django.db.models.deletion | |
8 | - | |
9 | - | |
10 | -class Migration(migrations.Migration): | |
11 | - | |
12 | - initial = True | |
13 | - | |
14 | - dependencies = [ | |
15 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
16 | - ('core', '0001_initial'), | |
17 | - ] | |
18 | - | |
19 | - operations = [ | |
20 | - migrations.AddField( | |
21 | - model_name='notification', | |
22 | - name='actor', | |
23 | - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notification_Performer', to=settings.AUTH_USER_MODEL, verbose_name='Perfomer'), | |
24 | - ), | |
25 | - migrations.AddField( | |
26 | - model_name='notification', | |
27 | - name='user', | |
28 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notification_Actor', to=settings.AUTH_USER_MODEL, verbose_name='User'), | |
29 | - ), | |
30 | - migrations.AddField( | |
31 | - model_name='log', | |
32 | - name='action_resource', | |
33 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action_Resource', verbose_name='Action_Resource'), | |
34 | - ), | |
35 | - migrations.AddField( | |
36 | - model_name='log', | |
37 | - name='user', | |
38 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Actor'), | |
39 | - ), | |
40 | - migrations.AddField( | |
41 | - model_name='action_resource', | |
42 | - name='action', | |
43 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Action', verbose_name='Action_Applied'), | |
44 | - ), | |
45 | - migrations.AddField( | |
46 | - model_name='action_resource', | |
47 | - name='resource', | |
48 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Resource', verbose_name='Resource'), | |
49 | - ), | |
50 | - ] |
core/templates/base.html
core/urls.py
1 | 1 | from django.conf.urls import url, include |
2 | 2 | from django.contrib.auth import views as auth_views |
3 | 3 | from django.contrib.auth.views import password_reset, password_reset_done,password_reset_confirm, password_reset_complete |
4 | - | |
5 | 4 | from . import views |
6 | 5 | |
7 | 6 | |
... | ... | @@ -12,10 +11,13 @@ urlpatterns = [ |
12 | 11 | url(r'^logout/$', auth_views.logout, {'next_page': 'core:home'}, name='logout'), |
13 | 12 | url(r'^notification/([0-9]+)/$', views.processNotification, name='notification_read'), |
14 | 13 | url(r'^getNotifications/$', views.getNotifications, name='getNotifications'), |
14 | +] | |
15 | 15 | |
16 | - url(r'^reset/$', password_reset, {'template_name':'registration/passwor_reset_form.html','email_template_name':'registration/password_reset_email.html','post_reset_redirect':'done/'}, name="password_reset"), | |
17 | - url(r'^reset/done/$', password_reset_done, {'template_name':'registration/passwor_reset_done.html'}), | |
18 | - url(r'^reset/(?P<uidb36>[0-9A-Za-z]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', password_reset_confirm, {'template_name':'registration/password_reset_confirm.html'}), | |
19 | - url(r'^done/$', password_reset_complete,{'template_name':'registration/passwor_reset_complete.html'}), | |
16 | +#Reset Password | |
17 | +urlpatterns += [ | |
18 | + url(r'^password/reset/$', password_reset, {'post_reset_redirect' : 'password/reset/done/','template_name': 'registration/passwor_reset_form.html'}, name="password_reset"), | |
19 | + url(r'^password/reset/done/$', password_reset_done, {'template_name': 'registration/passwor_reset_done.html'}), | |
20 | + url(r'^password/reset/(?P<uidb36>[0-9A-Za-z]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', password_reset_confirm, {'post_reset_redirect' : 'password/done/', 'template_name': 'registration/password_reset_confirm.html'}), | |
21 | + url(r'^password/done/$', password_reset_complete,{'template_name': 'registration/passwor_reset_complete.html'}), | |
20 | 22 | |
21 | 23 | ] | ... | ... |
courses/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
2 | +# Generated by Django 1.10 on 2016-10-05 02:05 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | 5 | import autoslug.fields |
6 | +from django.conf import settings | |
6 | 7 | from django.db import migrations, models |
7 | 8 | import django.db.models.deletion |
9 | +import s3direct.fields | |
8 | 10 | |
9 | 11 | |
10 | 12 | class Migration(migrations.Migration): |
... | ... | @@ -13,6 +15,7 @@ class Migration(migrations.Migration): |
13 | 15 | |
14 | 16 | dependencies = [ |
15 | 17 | ('core', '0001_initial'), |
18 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
16 | 19 | ] |
17 | 20 | |
18 | 21 | operations = [ |
... | ... | @@ -22,10 +25,24 @@ class Migration(migrations.Migration): |
22 | 25 | ('resource_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.Resource')), |
23 | 26 | ('limit_date', models.DateTimeField(verbose_name='Deliver Date')), |
24 | 27 | ('all_students', models.BooleanField(default=False, verbose_name='All Students')), |
28 | + ('students', models.ManyToManyField(related_name='activities', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | |
25 | 29 | ], |
26 | 30 | bases=('core.resource',), |
27 | 31 | ), |
28 | 32 | migrations.CreateModel( |
33 | + name='ActivityFile', | |
34 | + fields=[ | |
35 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
36 | + ('pdf', s3direct.fields.S3DirectField()), | |
37 | + ('name', models.CharField(max_length=100)), | |
38 | + ('diet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='files', to='courses.Activity')), | |
39 | + ], | |
40 | + options={ | |
41 | + 'verbose_name_plural': 'Activitys Files', | |
42 | + 'verbose_name': 'Activity File', | |
43 | + }, | |
44 | + ), | |
45 | + migrations.CreateModel( | |
29 | 46 | name='Category', |
30 | 47 | fields=[ |
31 | 48 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
... | ... | @@ -34,8 +51,8 @@ class Migration(migrations.Migration): |
34 | 51 | ('create_date', models.DateField(auto_now_add=True, verbose_name='Creation Date')), |
35 | 52 | ], |
36 | 53 | options={ |
37 | - 'verbose_name': 'Category', | |
38 | 54 | 'verbose_name_plural': 'Categories', |
55 | + 'verbose_name': 'Category', | |
39 | 56 | }, |
40 | 57 | ), |
41 | 58 | migrations.CreateModel( |
... | ... | @@ -53,11 +70,14 @@ class Migration(migrations.Migration): |
53 | 70 | ('init_date', models.DateField(verbose_name='Begin of Course Date')), |
54 | 71 | ('end_date', models.DateField(verbose_name='End of Course Date')), |
55 | 72 | ('image', models.ImageField(blank=True, upload_to='courses/', verbose_name='Image')), |
73 | + ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Category', verbose_name='Category')), | |
74 | + ('professors', models.ManyToManyField(related_name='courses_professors', to=settings.AUTH_USER_MODEL, verbose_name='Professors')), | |
75 | + ('students', models.ManyToManyField(related_name='courses_student', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | |
56 | 76 | ], |
57 | 77 | options={ |
58 | 78 | 'ordering': ('create_date', 'name'), |
59 | - 'verbose_name': 'Course', | |
60 | 79 | 'verbose_name_plural': 'Courses', |
80 | + 'verbose_name': 'Course', | |
61 | 81 | }, |
62 | 82 | ), |
63 | 83 | migrations.CreateModel( |
... | ... | @@ -65,6 +85,7 @@ class Migration(migrations.Migration): |
65 | 85 | fields=[ |
66 | 86 | ('resource_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.Resource')), |
67 | 87 | ('all_students', models.BooleanField(default=False, verbose_name='All Students')), |
88 | + ('students', models.ManyToManyField(related_name='materials', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | |
68 | 89 | ], |
69 | 90 | bases=('core.resource',), |
70 | 91 | ), |
... | ... | @@ -80,11 +101,13 @@ class Migration(migrations.Migration): |
80 | 101 | ('end_date', models.DateField(verbose_name='End of Subject Date')), |
81 | 102 | ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation Date')), |
82 | 103 | ('update_date', models.DateTimeField(auto_now=True, verbose_name='Date of last update')), |
104 | + ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subjects', to='courses.Course', verbose_name='Course')), | |
105 | + ('professors', models.ManyToManyField(related_name='subjects', to=settings.AUTH_USER_MODEL, verbose_name='Professors')), | |
83 | 106 | ], |
84 | 107 | options={ |
85 | 108 | 'ordering': ('create_date', 'name'), |
86 | - 'verbose_name': 'Subject', | |
87 | 109 | 'verbose_name_plural': 'Subjects', |
110 | + 'verbose_name': 'Subject', | |
88 | 111 | }, |
89 | 112 | ), |
90 | 113 | migrations.CreateModel( |
... | ... | @@ -94,10 +117,11 @@ class Migration(migrations.Migration): |
94 | 117 | ('name', models.CharField(max_length=100, verbose_name='Name')), |
95 | 118 | ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name', unique=True, verbose_name='Slug')), |
96 | 119 | ('description', models.TextField(blank=True, verbose_name='Description')), |
120 | + ('subjects', models.ManyToManyField(to='courses.Subject')), | |
97 | 121 | ], |
98 | 122 | options={ |
99 | - 'verbose_name': 'subject category', | |
100 | 123 | 'verbose_name_plural': 'subject categories', |
124 | + 'verbose_name': 'subject category', | |
101 | 125 | }, |
102 | 126 | ), |
103 | 127 | migrations.CreateModel( |
... | ... | @@ -110,11 +134,23 @@ class Migration(migrations.Migration): |
110 | 134 | ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation Date')), |
111 | 135 | ('update_date', models.DateTimeField(auto_now=True, verbose_name='Date of last update')), |
112 | 136 | ('visible', models.BooleanField(default=False, verbose_name='Visible')), |
137 | + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Owner')), | |
138 | + ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Subject', verbose_name='Subject')), | |
113 | 139 | ], |
114 | 140 | options={ |
115 | 141 | 'ordering': ('create_date', 'name'), |
116 | - 'verbose_name': 'Topic', | |
117 | 142 | 'verbose_name_plural': 'Topics', |
143 | + 'verbose_name': 'Topic', | |
118 | 144 | }, |
119 | 145 | ), |
146 | + migrations.AddField( | |
147 | + model_name='material', | |
148 | + name='topic', | |
149 | + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='materials', to='courses.Topic', verbose_name='Topic'), | |
150 | + ), | |
151 | + migrations.AddField( | |
152 | + model_name='activity', | |
153 | + name='topic', | |
154 | + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='courses.Topic', verbose_name='Topic'), | |
155 | + ), | |
120 | 156 | ] | ... | ... |
courses/migrations/0002_auto_20161001_2117.py
... | ... | @@ -1,80 +0,0 @@ |
1 | -# -*- coding: utf-8 -*- | |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
3 | -from __future__ import unicode_literals | |
4 | - | |
5 | -from django.conf import settings | |
6 | -from django.db import migrations, models | |
7 | -import django.db.models.deletion | |
8 | - | |
9 | - | |
10 | -class Migration(migrations.Migration): | |
11 | - | |
12 | - initial = True | |
13 | - | |
14 | - dependencies = [ | |
15 | - ('courses', '0001_initial'), | |
16 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
17 | - ] | |
18 | - | |
19 | - operations = [ | |
20 | - migrations.AddField( | |
21 | - model_name='topic', | |
22 | - name='owner', | |
23 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Owner'), | |
24 | - ), | |
25 | - migrations.AddField( | |
26 | - model_name='topic', | |
27 | - name='subject', | |
28 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Subject', verbose_name='Subject'), | |
29 | - ), | |
30 | - migrations.AddField( | |
31 | - model_name='subjectcategory', | |
32 | - name='subjects', | |
33 | - field=models.ManyToManyField(to='courses.Subject'), | |
34 | - ), | |
35 | - migrations.AddField( | |
36 | - model_name='subject', | |
37 | - name='course', | |
38 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subjects', to='courses.Course', verbose_name='Course'), | |
39 | - ), | |
40 | - migrations.AddField( | |
41 | - model_name='subject', | |
42 | - name='professors', | |
43 | - field=models.ManyToManyField(related_name='subjects', to=settings.AUTH_USER_MODEL, verbose_name='Professors'), | |
44 | - ), | |
45 | - migrations.AddField( | |
46 | - model_name='material', | |
47 | - name='students', | |
48 | - field=models.ManyToManyField(related_name='materials', to=settings.AUTH_USER_MODEL, verbose_name='Students'), | |
49 | - ), | |
50 | - migrations.AddField( | |
51 | - model_name='material', | |
52 | - name='topic', | |
53 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='materials', to='courses.Topic', verbose_name='Topic'), | |
54 | - ), | |
55 | - migrations.AddField( | |
56 | - model_name='course', | |
57 | - name='category', | |
58 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Category', verbose_name='Category'), | |
59 | - ), | |
60 | - migrations.AddField( | |
61 | - model_name='course', | |
62 | - name='professors', | |
63 | - field=models.ManyToManyField(related_name='courses_professors', to=settings.AUTH_USER_MODEL, verbose_name='Professors'), | |
64 | - ), | |
65 | - migrations.AddField( | |
66 | - model_name='course', | |
67 | - name='students', | |
68 | - field=models.ManyToManyField(related_name='courses_student', to=settings.AUTH_USER_MODEL, verbose_name='Students'), | |
69 | - ), | |
70 | - migrations.AddField( | |
71 | - model_name='activity', | |
72 | - name='students', | |
73 | - field=models.ManyToManyField(related_name='activities', to=settings.AUTH_USER_MODEL, verbose_name='Students'), | |
74 | - ), | |
75 | - migrations.AddField( | |
76 | - model_name='activity', | |
77 | - name='topic', | |
78 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='courses.Topic', verbose_name='Topic'), | |
79 | - ), | |
80 | - ] |
courses/migrations/0003_activityfile.py
... | ... | @@ -1,30 +0,0 @@ |
1 | -# -*- coding: utf-8 -*- | |
2 | -# Generated by Django 1.10 on 2016-10-03 16:10 | |
3 | -from __future__ import unicode_literals | |
4 | - | |
5 | -from django.db import migrations, models | |
6 | -import django.db.models.deletion | |
7 | -import s3direct.fields | |
8 | - | |
9 | - | |
10 | -class Migration(migrations.Migration): | |
11 | - | |
12 | - dependencies = [ | |
13 | - ('courses', '0002_auto_20161001_2117'), | |
14 | - ] | |
15 | - | |
16 | - operations = [ | |
17 | - migrations.CreateModel( | |
18 | - name='ActivityFile', | |
19 | - fields=[ | |
20 | - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
21 | - ('pdf', s3direct.fields.S3DirectField()), | |
22 | - ('name', models.CharField(max_length=100)), | |
23 | - ('diet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='files', to='courses.Activity')), | |
24 | - ], | |
25 | - options={ | |
26 | - 'verbose_name_plural': 'Activitys Files', | |
27 | - 'verbose_name': 'Activity File', | |
28 | - }, | |
29 | - ), | |
30 | - ] |
courses/templates/course/index.html
... | ... | @@ -53,23 +53,33 @@ |
53 | 53 | {% endfor %} |
54 | 54 | {% endif %} |
55 | 55 | |
56 | +<div class="col-md-12"> | |
57 | + <div class="input-group"> | |
58 | + <div class="form-group is-empty"><input type="search" class="form-control" placeholder="Search Courses"></div> | |
59 | + <span class="input-group-btn input-group-sm"> | |
60 | + <button type="button" class="btn btn-fab btn-fab-mini"> | |
61 | + <i class="material-icons">search</i> | |
62 | + </button> | |
63 | + </span> | |
64 | + </div> | |
65 | + </div> | |
56 | 66 | {% if user|has_role:'professor, system_admin' %} |
57 | 67 | |
58 | 68 | <div class="col-md-12"> |
59 | - {% if courses_teacher|length > 0 %} | |
69 | + {% if courses|length > 0 %} | |
60 | 70 | {% for course in courses_teacher %} |
61 | 71 | <!-- Put your content here! --> |
62 | 72 | <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false"> |
63 | 73 | <div class="group"> |
64 | 74 | <div class="panel panel-info"> |
65 | - <div class="panel-heading headingOne ui-sortable-handle" role="tab"> | |
75 | + <div class="panel-heading" role="tab"> | |
66 | 76 | <div class="row"> |
67 | - <div class="col-xs-9 col-md-10 titleTopic"> | |
77 | + <div class="col-xs-9 col-md-9 titleTopic"> | |
68 | 78 | <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> |
69 | - <h4>{{course.name}}</h4> | |
79 | + <h4 style="color:white">{{course.name}}</h4> | |
70 | 80 | </a> |
71 | 81 | </div> |
72 | - <div class="col-xs-4 col-md-2" id="divMoreActions"> | |
82 | + <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
73 | 83 | <div class="btn-group"> |
74 | 84 | <button type="button" class="btn btn-default btn-sm eye" data-toggle="tooltip" data-placement="bottom" title="Visible"> |
75 | 85 | <i class="fa fa-eye fa-2x" aria-hidden="true"></i> |
... | ... | @@ -81,7 +91,6 @@ |
81 | 91 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
82 | 92 | </button> |
83 | 93 | <ul class="dropdown-menu" aria-labelledby="moreActions"> |
84 | - <li><a href="{% url 'course:view' course.slug %}"><i class="fa fa-angle-double-right fa-fw" aria-hidden="true"></i> Access</a></li> | |
85 | 94 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> Replicate</a></li> |
86 | 95 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> Remove</a></li> |
87 | 96 | </ul> |
... | ... | @@ -100,7 +109,7 @@ |
100 | 109 | {{course.description}} |
101 | 110 | </i> |
102 | 111 | </p> |
103 | - | |
112 | + <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">{% trans 'View Course' %}<div class="ripple-container"></div></a> | |
104 | 113 | </div> |
105 | 114 | </div> |
106 | 115 | </div> |
... | ... | @@ -131,21 +140,11 @@ |
131 | 140 | </div> |
132 | 141 | </div> |
133 | 142 | </div> |
143 | +{% endif %} | |
134 | 144 | |
135 | -{% else %} | |
136 | - | |
137 | - <div class="col-md-12"> | |
138 | - <div class="input-group"> | |
139 | - <div class="form-group is-empty"><input type="search" class="form-control" placeholder="Search Courses"></div> | |
140 | - <span class="input-group-btn input-group-sm"> | |
141 | - <button type="button" class="btn btn-fab btn-fab-mini"> | |
142 | - <i class="material-icons">search</i> | |
143 | - </button> | |
144 | - </span> | |
145 | - </div> | |
146 | - </div> | |
145 | +{% if user|has_role:'students' %} | |
147 | 146 | |
148 | - {% if subjects_student|length > 0 %} | |
147 | + {% if courses|length > 0 %} | |
149 | 148 | {% for course in courses_student %} |
150 | 149 | <div class="col-md-12"> |
151 | 150 | <div class="panel panel-info"> |
... | ... | @@ -155,9 +154,15 @@ |
155 | 154 | <img src="" class="img-responsive" /> |
156 | 155 | {% endif %} --> |
157 | 156 | <div class="panel-heading"> |
158 | - <h3 class="panel-title">Course</h3> | |
159 | - <span class="label label-info">{{ course.category }}</span> | |
160 | - <span class="label label-warning">{{ course.max_students }} {% trans 'students tops' %}</span> | |
157 | + <div class="row"> | |
158 | + <div class="col-md-9"> | |
159 | + <h3 class="panel-title">{{course.name}}</h3> | |
160 | + </div> | |
161 | + <div class="col-md-3"> | |
162 | + <span class="label label-info">{{ course.category }}</span> | |
163 | + <span class="label label-warning">{{ course.max_students }} {% trans 'students tops' %}</span> | |
164 | + </div> | |
165 | + </div> | |
161 | 166 | </div> |
162 | 167 | <div class="panel-body"> |
163 | 168 | <p><b>Course Name: </b>{{ course.name }}</p> |
... | ... | @@ -166,18 +171,22 @@ |
166 | 171 | <p> |
167 | 172 | <b>Description:</b> |
168 | 173 | <i> |
169 | - "Lorem ipsum dolor sit amet, consecctetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." | |
174 | + {% if couse.description %} | |
175 | + {{course.description|linebreaks}} | |
176 | + {% else %} | |
177 | + {% trans 'No description' %} | |
178 | + {% endif %} | |
170 | 179 | </i> |
171 | 180 | </p> |
172 | 181 | |
173 | - {% if user|has_role:'professor, system_admin' %} | |
182 | + <!--{% if user|has_role:'professor, system_admin' %} | |
174 | 183 | <a href="{% url 'course:update' course.slug %}" class="btn btn-sm btn-primary"> |
175 | 184 | <span class="glyphicon glyphicon-edit"></span> |
176 | 185 | </a> |
177 | 186 | <a href="{% url 'course:delete' course.slug %}" class="btn btn-sm btn-danger"> |
178 | 187 | <span class="glyphicon glyphicon-trash"></span> |
179 | 188 | </a> |
180 | - {% endif %} | |
189 | + {% endif %}--> | |
181 | 190 | |
182 | 191 | <a href="{% url 'course:view' course.slug %}" class="btn btn-raised btn-default center-block">View Course</a> |
183 | 192 | </div> |
... | ... | @@ -186,7 +195,6 @@ |
186 | 195 | |
187 | 196 | {% endfor %} |
188 | 197 | |
189 | - | |
190 | 198 | <nav aria-label="Page navigation"> |
191 | 199 | <ul class="pagination"> |
192 | 200 | {% for page_number in paginator.page_range %} |
... | ... | @@ -200,4 +208,5 @@ |
200 | 208 | {% trans 'No courses found' %} |
201 | 209 | {% endif %} |
202 | 210 | {% endif %} |
211 | + | |
203 | 212 | {% endblock %} | ... | ... |
courses/templates/course/view.html
... | ... | @@ -52,10 +52,10 @@ |
52 | 52 | <div class="panel panel-info"> |
53 | 53 | <div class="panel-heading headingOne"> |
54 | 54 | <div class="row"> |
55 | - <div class="col-xs-8 col-md-10 titleTopic"> | |
55 | + <div class="col-xs-8 col-md-9 titleTopic"> | |
56 | 56 | <h4>{{course}}</h4> |
57 | 57 | </div> |
58 | - <div class="col-xs-4 col-md-2" id="divMoreActions"> | |
58 | + <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
59 | 59 | <div class="btn-group"> |
60 | 60 | <button type="button" class="btn btn-default btn-sm eye" data-toggle="tooltip" data-placement="bottom" title="Visible"> |
61 | 61 | <i class="fa fa-eye fa-2x" aria-hidden="true"></i> |
... | ... | @@ -99,7 +99,7 @@ |
99 | 99 | </div> |
100 | 100 | <div class="modal-body"> |
101 | 101 | <div> |
102 | - <form class="form-horizontal"> | |
102 | + <!--<form class="form-horizontal"> | |
103 | 103 | <div class="form-group is-empty"> |
104 | 104 | <label class="control-label col-md-2 col-md-offset-1 col-xs-2 col-xs-offset-1">Name</label> |
105 | 105 | <div class="col-md-8 col-xs-8"> |
... | ... | @@ -148,7 +148,7 @@ |
148 | 148 | </div> |
149 | 149 | </div> |
150 | 150 | </div> |
151 | - </form> | |
151 | + </form>--> | |
152 | 152 | </div> |
153 | 153 | <div class="modal-footer"> |
154 | 154 | <button type="button" data-dismiss="modal" class="btn btn-default">Cancel</button> |
... | ... | @@ -190,12 +190,12 @@ |
190 | 190 | <div class="panel panel-info"> |
191 | 191 | <div class="panel-heading headingTwo ui-sortable-handle" role="tab"> |
192 | 192 | <div class="row"> |
193 | - <div class="col-xs-9 col-md-10 titleTopic"> | |
193 | + <div class="col-xs-9 col-md-9 titleTopic"> | |
194 | 194 | <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseTwo" aria-expanded="true" aria-controls="collapseTwo"> |
195 | - <h4>{{subject.name}}</h4> | |
195 | + <h4 style="color:white">{{subject.name}}</h4> | |
196 | 196 | </a> |
197 | 197 | </div> |
198 | - <div class="col-xs-3 col-md-2" id="divMoreActions"> | |
198 | + <div class="col-xs-3 col-md-3" id="divMoreActions"> | |
199 | 199 | <div class="btn-group"> |
200 | 200 | <button type="button" class="btn btn-default btn-sm eye" data-toggle="tooltip" data-placement="bottom" title="Visible"> |
201 | 201 | <i class="fa fa-eye fa-2x" aria-hidden="true"></i> |
... | ... | @@ -206,7 +206,6 @@ |
206 | 206 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> |
207 | 207 | </button> |
208 | 208 | <ul class="dropdown-menu" aria-labelledby="moreActions"> |
209 | - <li><a href="{% url 'course:view_subject' subject.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> Access</a></li> | |
210 | 209 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal3"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> Replicate</a></li> |
211 | 210 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeSubject2"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> Remove</a></li> |
212 | 211 | </ul> |
... | ... | @@ -231,8 +230,13 @@ |
231 | 230 | <p><b>{% trans "End" %}: </b>{{subject.end_date}}</p> |
232 | 231 | </div> |
233 | 232 | </div> |
233 | + <a href="{% url 'course:view_subject' subject.slug %}" class="btn btn-raised btn-default center-block">{% trans 'View Subject' %}<div class="ripple-container"></div></a> | |
234 | 234 | </div> |
235 | 235 | </div> |
236 | +<div class="form-group"> | |
237 | + <a href="{% url 'course:create_subject' subject.slug %}" data-toggle="modal" data-target="" class="btn btn-primary btn-lg btn-block btn-raised">{% trans 'Create Subject' %}<div class="ripple-container"></div></a> | |
238 | +</div> | |
239 | + | |
236 | 240 | {% endfor %} |
237 | 241 | |
238 | 242 | ... | ... |
courses/templates/subject/form_view_teacher.html
... | ... | @@ -19,32 +19,13 @@ |
19 | 19 | </a> |
20 | 20 | <div class="panel-body"> |
21 | 21 | <p>{{ topic.description|linebreaks }}</p> |
22 | - <button class="btn btn-primary btn-raised" onclick="createForum('{% url 'forum:create' %}', '{{ topic.id }}')">{% trans '+ Create Forum' %}</button> | |
22 | + <button class="btn btn-primary btn-raised" onclick="createForum('{% url 'course:forum:create' %}', '{{ topic.id }}')">{% trans '+ Create Forum' %}</button> | |
23 | 23 | <div class="foruns_list"> |
24 | 24 | {% list_topic_foruns request topic %} |
25 | 25 | </div> |
26 | 26 | </div> |
27 | 27 | </div> |
28 | 28 | |
29 | -<div class="modal fade" id="forumModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
30 | - <div class="modal-dialog" role="document"> | |
31 | - <div class="modal-content"> | |
32 | - <div class="modal-header"> | |
33 | - <h4 class="modal-title" id="myModalLabel">{% trans 'Forum' %}</h4> | |
34 | - </div> | |
35 | - <div class="modal-body"> | |
36 | - <section> | |
37 | - <div class="forum_topics"></div> | |
38 | - </section> | |
39 | - </div> | |
40 | - <div class="modal-footer"> | |
41 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans 'Close' %}</button> | |
42 | - <button type="button" class="btn btn-primary btn-raised">{% trans 'Save changes' %}</button> | |
43 | - </div> | |
44 | - </div> | |
45 | - </div> | |
46 | -</div> | |
47 | - | |
48 | 29 | <div class="modal fade" id="createForum" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> |
49 | 30 | <div class="modal-dialog" role="document"> |
50 | 31 | <div class="modal-content"> | ... | ... |
courses/templates/subject/index.html
... | ... | @@ -67,7 +67,9 @@ |
67 | 67 | {% endfor %} |
68 | 68 | |
69 | 69 | {% if user|has_role:'system_admin' or topic.owner == user%} |
70 | - <a name="create_topic" class="btn btn-primary btn-md btn-block" href="{% url 'course:create_topic' subject.slug %}">{% trans "Create Topic" %}</a> | |
70 | + <div class="form-group"> | |
71 | + <a href="{% url 'course:create_topic' subject.slug %}" data-toggle="modal" data-target="" class="btn btn-primary btn-lg btn-block btn-raised" name="create_topic">{% trans "Create Topic" %}<div class="ripple-container"></div></a> | |
72 | + </div> | |
71 | 73 | {% endif %} |
72 | 74 | |
73 | 75 | {% endblock %} | ... | ... |
courses/templates/topic/list_topic_foruns.html
1 | 1 | {% for forum in foruns %} |
2 | - <a id="forum_{{ forum.id }}" href="javascript:showForum('{% url 'forum:index' %}', '{{forum.id}}')">{{ forum }}<br /></a> | |
2 | + <a id="forum_{{ forum.id }}" href="{% url 'course:forum:view' forum.slug %}">{{ forum }}<br /></a> | |
3 | 3 | {% endfor %} |
4 | 4 | \ No newline at end of file | ... | ... |
courses/urls.py
... | ... | @@ -24,6 +24,7 @@ urlpatterns = [ |
24 | 24 | url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), |
25 | 25 | |
26 | 26 | |
27 | - url(r'^poll/', include('poll.urls', namespace = 'poll')) | |
28 | - | |
27 | + url(r'^forum/', include('forum.urls', namespace = 'forum')), | |
28 | + url(r'^poll/', include('poll.urls', namespace = 'poll')), | |
29 | + url(r'^avaliacao/', include('avaliacao.urls', namespace = 'avaliacao')) | |
29 | 30 | ] | ... | ... |
courses/views.py
... | ... | @@ -24,13 +24,14 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
24 | 24 | redirect_field_name = 'next' |
25 | 25 | queryset = Course.objects.all() |
26 | 26 | template_name = 'course/index.html' |
27 | - context_object_name = 'courses_student' | |
27 | + context_object_name = 'courses' | |
28 | 28 | paginate_by = 3 |
29 | 29 | |
30 | 30 | def get_context_data(self, **kwargs): |
31 | 31 | context = super(IndexView, self).get_context_data(**kwargs) |
32 | 32 | context['categories'] = Category.objects.all() |
33 | 33 | context['courses_teacher'] = Course.objects.filter(professors__name = self.request.user.name) |
34 | + context['courses_student'] = Course.objects.filter(students__name = self.request.user.name) | |
34 | 35 | |
35 | 36 | return context |
36 | 37 | ... | ... |
forum/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
2 | +# Generated by Django 1.10 on 2016-10-05 02:05 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | +from django.conf import settings | |
5 | 6 | from django.db import migrations, models |
6 | 7 | import django.db.models.deletion |
7 | 8 | |
... | ... | @@ -12,6 +13,7 @@ class Migration(migrations.Migration): |
12 | 13 | |
13 | 14 | dependencies = [ |
14 | 15 | ('courses', '0001_initial'), |
16 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
15 | 17 | ] |
16 | 18 | |
17 | 19 | operations = [ |
... | ... | @@ -24,8 +26,8 @@ class Migration(migrations.Migration): |
24 | 26 | ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='Create Date')), |
25 | 27 | ], |
26 | 28 | options={ |
27 | - 'verbose_name': 'Forum', | |
28 | 29 | 'verbose_name_plural': 'Foruns', |
30 | + 'verbose_name': 'Forum', | |
29 | 31 | }, |
30 | 32 | bases=('courses.activity',), |
31 | 33 | ), |
... | ... | @@ -36,10 +38,12 @@ class Migration(migrations.Migration): |
36 | 38 | ('message', models.TextField(verbose_name='Post message')), |
37 | 39 | ('modification_date', models.DateTimeField(auto_now=True, verbose_name='Modification Date')), |
38 | 40 | ('post_date', models.DateTimeField(auto_now_add=True, verbose_name='Post Date')), |
41 | + ('forum', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forum.Forum', verbose_name='Forum')), | |
42 | + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Autor')), | |
39 | 43 | ], |
40 | 44 | options={ |
41 | - 'verbose_name': 'Post', | |
42 | 45 | 'verbose_name_plural': 'Posts', |
46 | + 'verbose_name': 'Post', | |
43 | 47 | }, |
44 | 48 | ), |
45 | 49 | migrations.CreateModel( |
... | ... | @@ -50,10 +54,11 @@ class Migration(migrations.Migration): |
50 | 54 | ('modification_date', models.DateTimeField(auto_now=True, verbose_name='Modification Date')), |
51 | 55 | ('answer_date', models.DateTimeField(auto_now_add=True, verbose_name='Answer Date')), |
52 | 56 | ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forum.Post', verbose_name='Post')), |
57 | + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Autor')), | |
53 | 58 | ], |
54 | 59 | options={ |
55 | - 'verbose_name': 'Post Answer', | |
56 | 60 | 'verbose_name_plural': 'Post Answers', |
61 | + 'verbose_name': 'Post Answer', | |
57 | 62 | }, |
58 | 63 | ), |
59 | 64 | ] | ... | ... |
forum/migrations/0002_auto_20161001_2117.py
... | ... | @@ -1,35 +0,0 @@ |
1 | -# -*- coding: utf-8 -*- | |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
3 | -from __future__ import unicode_literals | |
4 | - | |
5 | -from django.conf import settings | |
6 | -from django.db import migrations, models | |
7 | -import django.db.models.deletion | |
8 | - | |
9 | - | |
10 | -class Migration(migrations.Migration): | |
11 | - | |
12 | - initial = True | |
13 | - | |
14 | - dependencies = [ | |
15 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
16 | - ('forum', '0001_initial'), | |
17 | - ] | |
18 | - | |
19 | - operations = [ | |
20 | - migrations.AddField( | |
21 | - model_name='postanswer', | |
22 | - name='user', | |
23 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Autor'), | |
24 | - ), | |
25 | - migrations.AddField( | |
26 | - model_name='post', | |
27 | - name='forum', | |
28 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forum.Forum', verbose_name='Forum'), | |
29 | - ), | |
30 | - migrations.AddField( | |
31 | - model_name='post', | |
32 | - name='user', | |
33 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Autor'), | |
34 | - ), | |
35 | - ] |
forum/static/js/forum.js
1 | +/* | |
2 | +* | |
3 | +* Function to get a cookie stored on browser | |
4 | +* | |
5 | +*/ | |
1 | 6 | function getCookie(name) { |
2 | 7 | var cookieValue = null; |
3 | 8 | if (document.cookie && document.cookie !== '') { |
... | ... | @@ -16,6 +21,31 @@ function getCookie(name) { |
16 | 21 | |
17 | 22 | /* |
18 | 23 | * |
24 | +* Defining action of the form to make a post in forum | |
25 | +* | |
26 | +*/ | |
27 | +$(document).ready(function (){ | |
28 | + var frm = $('#form_post'); | |
29 | + frm.submit(function () { | |
30 | + $.ajax({ | |
31 | + type: frm.attr('method'), | |
32 | + url: frm.attr('action'), | |
33 | + data: frm.serialize(), | |
34 | + success: function (data) { | |
35 | + $("#posts_list").append(data); | |
36 | + frm[0].reset(); | |
37 | + }, | |
38 | + error: function(data) { | |
39 | + console.log(frm.serialize()); | |
40 | + console.log('Error'); | |
41 | + } | |
42 | + }); | |
43 | + return false; | |
44 | + }); | |
45 | +}); | |
46 | + | |
47 | +/* | |
48 | +* | |
19 | 49 | * Function to load create forum's form and set the submit function |
20 | 50 | * |
21 | 51 | */ |
... | ... | @@ -39,7 +69,7 @@ function createForum(url, topic) { |
39 | 69 | console.log(data); |
40 | 70 | data = data.split('-'); |
41 | 71 | |
42 | - $('.foruns_list').append("<a id='forum_"+data[1]+"' href='javascript:showForum("+data[0]+","+data[1]+")'>"+data[2]+"<br /></a>"); | |
72 | + $('.foruns_list').append("<a id='forum_"+data[1]+"' href='"+data[0]+"'>"+data[2]+"<br /></a>"); | |
43 | 73 | |
44 | 74 | $("#createForum").modal('hide'); |
45 | 75 | |
... | ... | @@ -59,29 +89,32 @@ function createForum(url, topic) { |
59 | 89 | |
60 | 90 | /* |
61 | 91 | * |
62 | -* Function to load forum to modal | |
92 | +* Function to load edit forum's form and set the submit function | |
63 | 93 | * |
64 | 94 | */ |
65 | -function showForum(url, forum_id) { | |
95 | +function editForum(url, forum) { | |
66 | 96 | $.ajax({ |
67 | 97 | url: url, |
68 | - data: {'forum_id': forum_id}, | |
98 | + data: {'pk': forum}, | |
69 | 99 | success: function(data) { |
70 | - $(".forum_topics").html(data); | |
100 | + $(".forum_form").html(data); | |
101 | + //$("#id_topic").val(topic); | |
102 | + | |
103 | + $('.date-picker').datepicker(); | |
71 | 104 | |
72 | - var frm = $('#form_post'); | |
105 | + var frm = $('#forum_create'); | |
73 | 106 | frm.submit(function () { |
74 | 107 | $.ajax({ |
75 | 108 | type: frm.attr('method'), |
76 | 109 | url: frm.attr('action'), |
77 | 110 | data: frm.serialize(), |
78 | 111 | success: function (data) { |
79 | - $("#posts_list").append(data); | |
80 | - frm[0].reset(); | |
112 | + $('.forum_view').html(data); | |
113 | + | |
114 | + $("#editForum").modal('hide'); | |
81 | 115 | }, |
82 | 116 | error: function(data) { |
83 | - console.log(frm.serialize()); | |
84 | - console.log('Error'); | |
117 | + $(".forum_form").html(data.responseText); | |
85 | 118 | } |
86 | 119 | }); |
87 | 120 | return false; |
... | ... | @@ -89,10 +122,15 @@ function showForum(url, forum_id) { |
89 | 122 | } |
90 | 123 | }); |
91 | 124 | |
92 | - $('#forumModal').modal(); | |
125 | + $("#editForum").modal(); | |
93 | 126 | } |
94 | 127 | |
95 | -function delete_forum(url, forum, message) { | |
128 | +/* | |
129 | +* | |
130 | +* Function to delete a forum | |
131 | +* | |
132 | +*/ | |
133 | +function delete_forum(url, forum, message, return_url) { | |
96 | 134 | alertify.confirm(message, function(){ |
97 | 135 | var csrftoken = getCookie('csrftoken'); |
98 | 136 | |
... | ... | @@ -103,8 +141,9 @@ function delete_forum(url, forum, message) { |
103 | 141 | }, |
104 | 142 | url: url, |
105 | 143 | success: function(data) { |
106 | - $("#forum_"+forum).remove(); | |
107 | - $('#forumModal').modal('hide'); | |
144 | + alertify.alert('Amadeus', data, function(){ | |
145 | + window.location.href = return_url; | |
146 | + }); | |
108 | 147 | } |
109 | 148 | }); |
110 | 149 | }); | ... | ... |
forum/templates/forum/forum_form.html
1 | 1 | {% load static i18n %} |
2 | 2 | {% load widget_tweaks %} |
3 | 3 | |
4 | -<form id="forum_create" method="post" action="{% url 'forum:create' %}" enctype="multipart/form-data"> | |
4 | +<form id="forum_create" method="post" action="{% if forum %}{% url 'course:forum:update' forum.id %}{% else %}{% url 'course:forum:create' %}{% endif %}" enctype="multipart/form-data"> | |
5 | 5 | {% csrf_token %} |
6 | 6 | {% for field in form %} |
7 | 7 | <div class="form-group {% if form.has_error %} has-error {% endif %} is-fileinput"> | ... | ... |
forum/templates/forum/forum_list.html
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | {% list_posts request forum %} |
30 | 30 | </div> |
31 | 31 | |
32 | -<form id="form_post" method="post" action="{% url 'forum:create_post' %}" enctype="multipart/form-data"> | |
32 | +<form id="form_post" method="post" action="{% url 'course:forum:create_post' %}" enctype="multipart/form-data"> | |
33 | 33 | {% csrf_token %} |
34 | 34 | {% for field in form %} |
35 | 35 | {% if field.field.widget.input_type == 'hidden' %} |
... | ... | @@ -63,26 +63,4 @@ |
63 | 63 | </div> |
64 | 64 | {% endif %} |
65 | 65 | {% endfor %} |
66 | -</form> | |
67 | - | |
68 | -<!--{% if foruns|length > 0 %} | |
69 | - {% for forum in foruns %} | |
70 | - <a class="forum_collapse" role="button" href="javascript: showPosts('{% url 'forum:posts' %}', '{{ forum.slug }}')" aria-expanded="true"> | |
71 | - <div class="page-header"> | |
72 | - <h1 id="timeline"> | |
73 | - {{ forum }} | |
74 | - </h1> | |
75 | - <b>{% trans 'Description' %}: </b>{{ forum.description }}<p> | |
76 | - <b>{% trans 'Created in' %}: </b>{{ forum.create_date }} | |
77 | - </div> | |
78 | - </a> | |
79 | - <div class="collapse" id="collapse{{ forum.slug }}"> | |
80 | - <div class="well"> | |
81 | - </div> | |
82 | - </div> | |
83 | - {% endfor %} | |
84 | -{% else %} | |
85 | - <div class="page-header"> | |
86 | - <p>{% trans 'No forum created yet.' %}</p> | |
87 | - </div> | |
88 | -{% endif %}--> | |
66 | +</form> | |
89 | 67 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,136 @@ |
1 | +{% extends 'base.html' %} | |
2 | + | |
3 | +{% load static i18n permission_tags list_post %} | |
4 | +{% load widget_tweaks %} | |
5 | + | |
6 | +{% block javascript %} | |
7 | + <script type="text/javascript" src="{% static 'js/forum.js' %}"></script> | |
8 | +{% endblock %} | |
9 | + | |
10 | +{% block breadcrumbs %} | |
11 | + | |
12 | + <ol class="breadcrumb"> | |
13 | + <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li> | |
14 | + <li><a href="{% url 'course:view' forum.topic.subject.course.slug %}">{{ forum.topic.subject.course }}</a></li> | |
15 | + {% if user|has_role:'professor' or user|has_role:'system_admin' %} | |
16 | + <li class="active">{% trans 'Forum' %}</li> | |
17 | + {% else %} | |
18 | + <li class="active">{{ forum.name }}</li> | |
19 | + {% endif %} | |
20 | + | |
21 | + </ol> | |
22 | +{% endblock %} | |
23 | + | |
24 | +{% block sidebar %} | |
25 | + <div class="panel panel-primary navigation"> | |
26 | + <div class="panel-heading"> | |
27 | + <h5>{% trans 'Menu' %}</h5> | |
28 | + </div> | |
29 | + <div class="panel-body"> | |
30 | + <ul class="nav nav-pills nav-stacked"> | |
31 | + <li><a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li> | |
32 | + <li><a href="{% url 'course:manage' %}">{% trans 'My Courses' %}</a></li> | |
33 | + </ul> | |
34 | + </div> | |
35 | + </div> | |
36 | + | |
37 | + {% if request.user|has_role:'system_admin' or request.user|has_role:'professor' and request.user == post.user %} | |
38 | + <div class="panel panel-primary navigation"> | |
39 | + <div class="panel-heading"> | |
40 | + <h3 class="panel-title">{% trans 'Actions' %}</h3> | |
41 | + </div> | |
42 | + <div class="panel-body"> | |
43 | + <ul class="nav nav-pills nav-stacked"> | |
44 | + <li><a href="javascript:editForum('{% url 'course:forum:update' forum.id %}', '{{ forum.id }}')">{% trans 'Edit' %}</a></li> | |
45 | + <li><a href="javascript:delete_forum('{% url 'course:forum:delete' forum.id %}', '{{ forum.id }}', '{% trans "Are you sure you want to delete this forum?" %}', '{% url 'course:view_subject' forum.topic.subject.slug %}')">{% trans 'Delete' %}</a></li> | |
46 | + </ul> | |
47 | + </div> | |
48 | + </div> | |
49 | + {% endif %} | |
50 | +{% endblock %} | |
51 | + | |
52 | +{% block content %} | |
53 | + <div class="row panel panel-default"> | |
54 | + <div class="panel-body"> | |
55 | + <div class="comments-list"> | |
56 | + <div class="section-heading forum_view"> | |
57 | + <h1>{{ forum }}</h1> | |
58 | + <h4><b>{% trans 'Description' %}:</b> {{ forum.description }}</h4> | |
59 | + <h4><b>{% trans 'Opened in' %}:</b> {{ forum.create_date }}</h4> | |
60 | + </div> | |
61 | + </div> | |
62 | + <div class="form_post_block"> | |
63 | + <hr /> | |
64 | + <form id="form_post" method="post" action="{% url 'course:forum:create_post' %}" enctype="multipart/form-data"> | |
65 | + {% csrf_token %} | |
66 | + {% for field in form %} | |
67 | + {% if field.field.widget.input_type == 'hidden' %} | |
68 | + {% render_field field class='form-control' value=forum.id %} | |
69 | + {% else %} | |
70 | + <div class="form-group {% if form.has_error %} has-error {% endif %} is-fileinput"> | |
71 | + <div class="input-group"> | |
72 | + {% render_field field class='form-control' placeholder="Post a message" %} | |
73 | + <span class="help-block">{{ field.help_text }}</span> | |
74 | + {% if field.errors %} | |
75 | + <div class="row"> | |
76 | + <br /> | |
77 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
78 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
79 | + <span aria-hidden="true">×</span> | |
80 | + </button> | |
81 | + <ul> | |
82 | + {% for error in field.errors %} | |
83 | + <li>{{ error }}</li> | |
84 | + {% endfor %} | |
85 | + </ul> | |
86 | + </div> | |
87 | + </div> | |
88 | + {% endif %} | |
89 | + <span class="input-group-btn"> | |
90 | + <button type="submit" class="btn btn-fab btn-fab-mini"> | |
91 | + <i class="material-icons">send</i> | |
92 | + </button> | |
93 | + </span> | |
94 | + </div> | |
95 | + </div> | |
96 | + {% endif %} | |
97 | + {% endfor %} | |
98 | + </form> | |
99 | + <hr /> | |
100 | + </div> | |
101 | + <div id="posts_list"> | |
102 | + {% list_posts request forum %} | |
103 | + </div> | |
104 | + </div> | |
105 | + </div> | |
106 | + <!-- Modal to show Forum edit form --> | |
107 | + <div class="modal fade" id="editForum" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
108 | + <div class="modal-dialog" role="document"> | |
109 | + <div class="modal-content"> | |
110 | + <div class="modal-header"> | |
111 | + <h4 class="modal-title" id="myModalLabel">{% trans 'Forum' %}</h4> | |
112 | + </div> | |
113 | + <div class="modal-body"> | |
114 | + <section> | |
115 | + <div class="forum_form"></div> | |
116 | + </section> | |
117 | + </div> | |
118 | + <div class="modal-footer"> | |
119 | + <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans 'Close' %}</button> | |
120 | + <button type="button" onclick="$('#forum_create').submit();" class="btn btn-primary btn-raised">{% trans 'Update' %}</button> | |
121 | + </div> | |
122 | + </div> | |
123 | + </div> | |
124 | + </div> | |
125 | +{% endblock %} | |
126 | + | |
127 | +{% block rightbar %} | |
128 | + <div class="panel panel-warning"> | |
129 | + <div class="panel-heading"> | |
130 | + <h3 class="panel-title">{% trans "Pending Stuffs" %}</h3> | |
131 | + </div> | |
132 | + <div class="panel-body"> | |
133 | + | |
134 | + </div> | |
135 | + </div> | |
136 | +{% endblock rightbar %} | ... | ... |
forum/templates/post/post_list.html
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <h3 class="user-name"> |
8 | 8 | {{ post.user }} |
9 | 9 | <div class="pull-right"> |
10 | - <a href="javascript:answer('{{ post.id }}', '{% url 'forum:reply_post' %}');"> | |
10 | + <a href="javascript:answer('{{ post.id }}', '{% url 'course:forum:reply_post' %}');"> | |
11 | 11 | <i class="material-icons">reply</i> |
12 | 12 | </a> |
13 | 13 | {% if request.user|has_role:'system_admin' or request.user == post.user %} |
... | ... | @@ -17,8 +17,8 @@ |
17 | 17 | <i class="material-icons">more_horiz</i> |
18 | 18 | </a> |
19 | 19 | <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> |
20 | - <li><a href="javascript:edit_post('{% url 'forum:update_post' post.id %}', '{{ post.id }}')"><i class="material-icons">create</i> {% trans 'Edit' %}</a></li> | |
21 | - <li><a href="javascript:javascript:delete_post('{% url 'forum:delete_post' post.id %}', '{{ post.id }}')"><i class="material-icons">delete_sweep</i> {% trans 'Remove' %}</a></li> | |
20 | + <li><a href="javascript:edit_post('{% url 'course:forum:update_post' post.id %}', '{{ post.id }}')"><i class="material-icons">create</i> {% trans 'Edit' %}</a></li> | |
21 | + <li><a href="javascript:javascript:delete_post('{% url 'course:forum:delete_post' post.id %}', '{{ post.id }}')"><i class="material-icons">delete_sweep</i> {% trans 'Remove' %}</a></li> | |
22 | 22 | </ul> |
23 | 23 | </div> |
24 | 24 | {% endif %} |
... | ... | @@ -40,34 +40,4 @@ |
40 | 40 | </div> |
41 | 41 | {% list_post_answer request post %} |
42 | 42 | {% endfor %} |
43 | -{% endif %} | |
44 | - <!--<li> | |
45 | - <a class="post_collapse" role="button" href="javascript: showPostsAnswers('{% url 'forum:post_answers' %}', '{{ post.id }}')" aria-expanded="false"> | |
46 | - <div class="timeline-panel"> | |
47 | - <div class="row"> | |
48 | - <div class="col-xs-2 col-sm-2 col-md-2"> | |
49 | - <img class="img-responsive img-rounded" src="{{ post.user.image_url }}" /> | |
50 | - </div> | |
51 | - <div class="col-xs-10 col-sm-10 col-md-10"> | |
52 | - <div class="timeline-heading"> | |
53 | - <h3> {{ post.user }}</h3> | |
54 | - </div> | |
55 | - <div class="timeline-body"> | |
56 | - <p><em>{{ post.message|linebreaks }}</em></p> | |
57 | - </div> | |
58 | - <hr> | |
59 | - <small class="text-muted"> | |
60 | - <span class="pull-right"> | |
61 | - <i class="glyphicon glyphicon-time"></i> {{ post.post_date|timesince }} | |
62 | - {% trans ' ago' %} | |
63 | - </span> | |
64 | - </small> | |
65 | - </div> | |
66 | - </div> | |
67 | - </div> | |
68 | - </a> | |
69 | - <div class="collapse" id="collapse{{ post.id }}" style="margin-top:10px;"> | |
70 | - <div class="well"> | |
71 | - </div> | |
72 | - </div> | |
73 | - </li>--> | |
74 | 43 | \ No newline at end of file |
44 | +{% endif %} | |
75 | 45 | \ No newline at end of file | ... | ... |
forum/templates/post/post_render.html
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <h3 class="user-name"> |
6 | 6 | {{ post.user }} |
7 | 7 | <div class="pull-right"> |
8 | - <a href="javascript:answer('{{ post.id }}', '{% url 'forum:reply_post' %}');"> | |
8 | + <a href="javascript:answer('{{ post.id }}', '{% url 'course:forum:reply_post' %}');"> | |
9 | 9 | <i class="material-icons">reply</i> |
10 | 10 | </a> |
11 | 11 | {% if request.user|has_role:'system_admin' or request.user|has_role:'professor' and request.user == post.user %} |
... | ... | @@ -15,8 +15,8 @@ |
15 | 15 | <i class="material-icons">more_horiz</i> |
16 | 16 | </a> |
17 | 17 | <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> |
18 | - <li><a href="javascript:edit_post('{% url 'forum:update_post' post.id %}', '{{ post.id }}')"></li> | |
19 | - <li><a href="javascript:delete_post('{% url 'forum:delete_post' post.id %}', '{{ post.id }}')"><i class="material-icons">delete_sweep</i> {% trans 'Remove' %}</a></li> | |
18 | + <li><a href="javascript:edit_post('{% url 'course:forum:update_post' post.id %}', '{{ post.id }}')"></li> | |
19 | + <li><a href="javascript:delete_post('{% url 'course:forum:delete_post' post.id %}', '{{ post.id }}')"><i class="material-icons">delete_sweep</i> {% trans 'Remove' %}</a></li> | |
20 | 20 | </ul> |
21 | 21 | </div> |
22 | 22 | {% endif %} | ... | ... |
forum/urls.py
1 | -from django.conf.urls import url, include | |
1 | +from django.conf.urls import url | |
2 | 2 | |
3 | 3 | from . import views |
4 | 4 | |
... | ... | @@ -6,8 +6,10 @@ from . import views |
6 | 6 | urlpatterns = [ |
7 | 7 | url(r'^$', views.ForumIndex.as_view(), name='index'), |
8 | 8 | url(r'^create/$', views.CreateForumView.as_view(), name='create'), |
9 | + url(r'^update/(?P<pk>[\w_-]+)/$', views.UpdateForumView.as_view(), name='update'), | |
9 | 10 | url(r'^delete/(?P<pk>[\w_-]+)/$', views.ForumDeleteView.as_view(), name='delete'), |
10 | 11 | url(r'^render_forum/([\w_-]+)/$', views.render_forum, name='render_forum'), |
12 | + url(r'^render_edit_forum/([\w_-]+)/$', views.render_edit_forum, name='render_edit_forum'), | |
11 | 13 | url(r'^forum_deleted/$', views.forum_deleted, name='deleted_forum'), |
12 | 14 | url(r'^create_post/$', views.CreatePostView.as_view(), name='create_post'), |
13 | 15 | url(r'^update_post/(?P<pk>[\w_-]+)/$', views.PostUpdateView.as_view(), name='update_post'), |
... | ... | @@ -16,4 +18,5 @@ urlpatterns = [ |
16 | 18 | url(r'^post_deleted/$', views.post_deleted, name='deleted_post'), |
17 | 19 | url(r'^post_answers/$', views.PostAnswerIndex.as_view(), name='post_answers'), |
18 | 20 | url(r'^reply_post/$', views.CreatePostAnswerView.as_view(), name='reply_post'), |
21 | + url(r'^(?P<slug>[\w_-]+)/$', views.ForumDetailView.as_view(), name='view'), | |
19 | 22 | ] | ... | ... |
forum/views.py
... | ... | @@ -41,15 +41,38 @@ class CreateForumView(LoginRequiredMixin, generic.edit.CreateView): |
41 | 41 | return self.render_to_response(self.get_context_data(form = form), status = 400) |
42 | 42 | |
43 | 43 | def get_success_url(self): |
44 | - print("Pass") | |
45 | - self.success_url = reverse('forum:render_forum', args = (self.object.id, )) | |
44 | + self.success_url = reverse('course:forum:render_forum', args = (self.object.id, )) | |
46 | 45 | |
47 | 46 | return self.success_url |
48 | 47 | |
49 | 48 | def render_forum(request, forum): |
50 | 49 | last_forum = get_object_or_404(Forum, id = forum) |
51 | 50 | |
52 | - return HttpResponse(str(reverse_lazy('forum:index')) + '-' + str(forum) + '-' + str(last_forum.name)) | |
51 | + return HttpResponse(str(reverse_lazy('course:forum:view', args = (), kwargs = {'slug': last_forum.slug})) + '-' + str(forum) + '-' + str(last_forum.name)) | |
52 | + | |
53 | +class UpdateForumView(LoginRequiredMixin, generic.UpdateView): | |
54 | + login_url = reverse_lazy("core:home") | |
55 | + redirect_field_name = 'next' | |
56 | + | |
57 | + template_name = 'forum/forum_form.html' | |
58 | + form_class = ForumForm | |
59 | + model = Forum | |
60 | + | |
61 | + def form_invalid(self, form): | |
62 | + return self.render_to_response(self.get_context_data(form = form), status = 400) | |
63 | + | |
64 | + def get_success_url(self): | |
65 | + self.success_url = reverse('course:forum:render_edit_forum', args = (self.object.id, )) | |
66 | + | |
67 | + return self.success_url | |
68 | + | |
69 | +def render_edit_forum(request, forum): | |
70 | + last_forum = get_object_or_404(Forum, id = forum) | |
71 | + context = { | |
72 | + 'forum': last_forum | |
73 | + } | |
74 | + | |
75 | + return render(request, 'forum/render_forum.html', context) | |
53 | 76 | |
54 | 77 | class ForumDeleteView(LoginRequiredMixin, generic.DeleteView): |
55 | 78 | login_url = reverse_lazy("core:home") |
... | ... | @@ -57,11 +80,29 @@ class ForumDeleteView(LoginRequiredMixin, generic.DeleteView): |
57 | 80 | |
58 | 81 | model = Forum |
59 | 82 | pk_url_kwarg = 'pk' |
60 | - success_url = reverse_lazy('forum:deleted_forum') | |
83 | + success_url = reverse_lazy('course:forum:deleted_forum') | |
61 | 84 | |
62 | 85 | def forum_deleted(request): |
63 | 86 | return HttpResponse(_("Forum deleted successfully.")) |
64 | 87 | |
88 | +class ForumDetailView(LoginRequiredMixin, generic.DetailView): | |
89 | + login_url = reverse_lazy("core:home") | |
90 | + redirect_field_name = 'next' | |
91 | + | |
92 | + model = Forum | |
93 | + template_name = 'forum/forum_view.html' | |
94 | + context_object_name = 'forum' | |
95 | + | |
96 | + def get_context_data(self, **kwargs): | |
97 | + context = super(ForumDetailView, self).get_context_data(**kwargs) | |
98 | + forum = get_object_or_404(Forum, slug = self.kwargs.get('slug')) | |
99 | + | |
100 | + context['form'] = PostForm() | |
101 | + context['forum'] = forum | |
102 | + context['title'] = forum.name | |
103 | + | |
104 | + return context | |
105 | + | |
65 | 106 | class CreatePostView(LoginRequiredMixin, generic.edit.CreateView): |
66 | 107 | login_url = reverse_lazy("core:home") |
67 | 108 | redirect_field_name = 'next' |
... | ... | @@ -77,7 +118,7 @@ class CreatePostView(LoginRequiredMixin, generic.edit.CreateView): |
77 | 118 | return super(CreatePostView, self).form_valid(form) |
78 | 119 | |
79 | 120 | def get_success_url(self): |
80 | - self.success_url = reverse('forum:render_post', args = (self.object.id, )) | |
121 | + self.success_url = reverse('course:forum:render_post', args = (self.object.id, )) | |
81 | 122 | |
82 | 123 | return self.success_url |
83 | 124 | |
... | ... | @@ -98,7 +139,7 @@ class PostUpdateView(LoginRequiredMixin, generic.UpdateView): |
98 | 139 | template_name = "post/post_update_form.html" |
99 | 140 | |
100 | 141 | def get_success_url(self): |
101 | - self.success_url = reverse('forum:render_post', args = (self.object.id, )) | |
142 | + self.success_url = reverse('course:forum:render_post', args = (self.object.id, )) | |
102 | 143 | |
103 | 144 | return self.success_url |
104 | 145 | |
... | ... | @@ -108,7 +149,7 @@ class PostDeleteView(LoginRequiredMixin, generic.DeleteView): |
108 | 149 | |
109 | 150 | model = Post |
110 | 151 | pk_url_kwarg = 'pk' |
111 | - success_url = reverse_lazy('forum:deleted_post') | |
152 | + success_url = reverse_lazy('course:forum:deleted_post') | |
112 | 153 | |
113 | 154 | def post_deleted(request): |
114 | 155 | return HttpResponse(_("Post deleted successfully.")) |
... | ... | @@ -128,7 +169,9 @@ class PostAnswerIndex(LoginRequiredMixin, generic.ListView): |
128 | 169 | return context |
129 | 170 | |
130 | 171 | class CreatePostAnswerView(LoginRequiredMixin, generic.edit.CreateView): |
172 | + login_url = reverse_lazy("core:home") | |
173 | + redirect_field_name = 'next' | |
131 | 174 | |
132 | 175 | template_name = 'post_answers/post_answer_form.html' |
133 | 176 | form_class = PostAnswerForm |
134 | - success_url = reverse_lazy('forum:index') | |
135 | 177 | \ No newline at end of file |
178 | + success_url = reverse_lazy('course:forum:index') | |
136 | 179 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +from django.db import models | |
2 | +from courses.models import Material | |
3 | +# Create your models here. | |
4 | +class Link(Material,models.Model): | |
5 | + name = models.CharField(max_lenght = 100) | |
6 | + link = models.UrlField() | |
7 | + description = models.CharField(max_lenght = 200) | |
8 | + class Meta: | |
9 | + verbose_name = 'Link' | |
10 | + verbose_name_plural = "Links" | |
11 | + def __str__(self): | |
12 | + return str(self.name) | |
13 | + | |
14 | + | |
15 | + | ... | ... |
poll/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
2 | +# Generated by Django 1.10 on 2016-10-05 02:05 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | 5 | from django.db import migrations, models |
... | ... | @@ -24,8 +24,8 @@ class Migration(migrations.Migration): |
24 | 24 | ], |
25 | 25 | options={ |
26 | 26 | 'ordering': ('order',), |
27 | - 'verbose_name': 'Answer', | |
28 | 27 | 'verbose_name_plural': 'Answers', |
28 | + 'verbose_name': 'Answer', | |
29 | 29 | }, |
30 | 30 | ), |
31 | 31 | migrations.CreateModel( |
... | ... | @@ -34,8 +34,8 @@ class Migration(migrations.Migration): |
34 | 34 | ('activity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='courses.Activity')), |
35 | 35 | ], |
36 | 36 | options={ |
37 | - 'verbose_name': 'Poll', | |
38 | 37 | 'verbose_name_plural': 'Polls', |
38 | + 'verbose_name': 'Poll', | |
39 | 39 | }, |
40 | 40 | bases=('courses.activity',), |
41 | 41 | ), | ... | ... |
users/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-02 00:17 | |
2 | +# Generated by Django 1.10 on 2016-10-03 19:10 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | 5 | import django.contrib.auth.models |
... | ... | @@ -42,8 +42,8 @@ class Migration(migrations.Migration): |
42 | 42 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), |
43 | 43 | ], |
44 | 44 | options={ |
45 | - 'verbose_name': 'User', | |
46 | 45 | 'verbose_name_plural': 'Users', |
46 | + 'verbose_name': 'User', | |
47 | 47 | }, |
48 | 48 | managers=[ |
49 | 49 | ('objects', django.contrib.auth.models.UserManager()), | ... | ... |