Commit 391ca499048e2c5381485f6ee7b99f13244b7760
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
17 changed files
with
309 additions
and
76 deletions
Show diff stats
core/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-01 16:02 | |
2 | +# Generated by Django 1.10 on 2016-10-02 00:17 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | 5 | import autoslug.fields |
6 | -from django.conf import settings | |
7 | 6 | from django.db import migrations, models |
8 | 7 | import django.db.models.deletion |
9 | 8 | |
... | ... | @@ -13,7 +12,6 @@ class Migration(migrations.Migration): |
13 | 12 | initial = True |
14 | 13 | |
15 | 14 | dependencies = [ |
16 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
17 | 15 | ] |
18 | 16 | |
19 | 17 | operations = [ |
... | ... | @@ -33,7 +31,6 @@ class Migration(migrations.Migration): |
33 | 31 | name='Action_Resource', |
34 | 32 | fields=[ |
35 | 33 | ('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')), | |
37 | 34 | ], |
38 | 35 | options={ |
39 | 36 | 'verbose_name': 'Action_Resource', |
... | ... | @@ -45,8 +42,6 @@ class Migration(migrations.Migration): |
45 | 42 | fields=[ |
46 | 43 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
47 | 44 | ('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')), | |
50 | 45 | ], |
51 | 46 | options={ |
52 | 47 | 'verbose_name': 'Log', |
... | ... | @@ -61,8 +56,6 @@ class Migration(migrations.Migration): |
61 | 56 | ('read', models.BooleanField(default=False, verbose_name='Read')), |
62 | 57 | ('datetime', models.DateTimeField(auto_now_add=True, verbose_name='Date and Time of action')), |
63 | 58 | ('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')), | |
66 | 59 | ], |
67 | 60 | options={ |
68 | 61 | 'verbose_name': 'Notification', |
... | ... | @@ -83,9 +76,4 @@ class Migration(migrations.Migration): |
83 | 76 | 'verbose_name_plural': 'Resources', |
84 | 77 | }, |
85 | 78 | ), |
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 | - ), | |
91 | 79 | ] | ... | ... |
... | ... | @@ -0,0 +1,50 @@ |
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/static/css/base/amadeus.css
core/templates/base.html
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7/css/bootstrap.css' %}"> |
22 | 22 | <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/material.min.css' %}"> |
23 | 23 | <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/ripples.min.css' %}"> |
24 | - <link rel="stylesheet" type="text/css" href="{% static 'css/datepicker.css' %}"> | |
24 | + <link rel="stylesheet" type="text/css" href="{% static 'css/vendor/datepicker.css' %}"> | |
25 | 25 | <script type="text/javascript" src="{% static 'bootstrap-3.3.7/js/bootstrap.js' %}"></script> |
26 | 26 | <script type="text/javascript" src="{% static 'js/vendor/bootstrap-acessibility.min.js' %}"></script> |
27 | 27 | <script type="text/javascript" src="{% static 'js/vendor/material.min.js' %}"></script> |
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | <script type="text/javascript">$.material.init()</script> |
39 | 39 | |
40 | 40 | <!--Javascript block for specific-app ones --> |
41 | - <script src="{% static 'js/base/amadeus.js' %}"></script> | |
41 | + <script src="{% static 'js/main.js' %}"></script> | |
42 | 42 | {% block style %} |
43 | 43 | {% endblock %} |
44 | 44 | </head> | ... | ... |
courses/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-01 16:02 | |
2 | +# Generated by Django 1.10 on 2016-10-02 00:17 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | 5 | import autoslug.fields |
6 | -from django.conf import settings | |
7 | 6 | from django.db import migrations, models |
8 | 7 | import django.db.models.deletion |
9 | 8 | |
... | ... | @@ -13,7 +12,6 @@ class Migration(migrations.Migration): |
13 | 12 | initial = True |
14 | 13 | |
15 | 14 | dependencies = [ |
16 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
17 | 15 | ('core', '0001_initial'), |
18 | 16 | ] |
19 | 17 | |
... | ... | @@ -24,7 +22,6 @@ class Migration(migrations.Migration): |
24 | 22 | ('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')), |
25 | 23 | ('limit_date', models.DateTimeField(verbose_name='Deliver Date')), |
26 | 24 | ('all_students', models.BooleanField(default=False, verbose_name='All Students')), |
27 | - ('students', models.ManyToManyField(related_name='activities', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | |
28 | 25 | ], |
29 | 26 | bases=('core.resource',), |
30 | 27 | ), |
... | ... | @@ -56,9 +53,6 @@ class Migration(migrations.Migration): |
56 | 53 | ('init_date', models.DateField(verbose_name='Begin of Course Date')), |
57 | 54 | ('end_date', models.DateField(verbose_name='End of Course Date')), |
58 | 55 | ('image', models.ImageField(blank=True, upload_to='courses/', verbose_name='Image')), |
59 | - ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Category', verbose_name='Category')), | |
60 | - ('professors', models.ManyToManyField(related_name='courses_professors', to=settings.AUTH_USER_MODEL, verbose_name='Professors')), | |
61 | - ('students', models.ManyToManyField(related_name='courses_student', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | |
62 | 56 | ], |
63 | 57 | options={ |
64 | 58 | 'ordering': ('create_date', 'name'), |
... | ... | @@ -71,7 +65,6 @@ class Migration(migrations.Migration): |
71 | 65 | fields=[ |
72 | 66 | ('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')), |
73 | 67 | ('all_students', models.BooleanField(default=False, verbose_name='All Students')), |
74 | - ('students', models.ManyToManyField(related_name='materials', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | |
75 | 68 | ], |
76 | 69 | bases=('core.resource',), |
77 | 70 | ), |
... | ... | @@ -87,8 +80,6 @@ class Migration(migrations.Migration): |
87 | 80 | ('end_date', models.DateField(verbose_name='End of Subject Date')), |
88 | 81 | ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation Date')), |
89 | 82 | ('update_date', models.DateTimeField(auto_now=True, verbose_name='Date of last update')), |
90 | - ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subjects', to='courses.Course', verbose_name='Course')), | |
91 | - ('professors', models.ManyToManyField(related_name='subjects', to=settings.AUTH_USER_MODEL, verbose_name='Professors')), | |
92 | 83 | ], |
93 | 84 | options={ |
94 | 85 | 'ordering': ('create_date', 'name'), |
... | ... | @@ -103,7 +94,6 @@ class Migration(migrations.Migration): |
103 | 94 | ('name', models.CharField(max_length=100, verbose_name='Name')), |
104 | 95 | ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name', unique=True, verbose_name='Slug')), |
105 | 96 | ('description', models.TextField(blank=True, verbose_name='Description')), |
106 | - ('subjects', models.ManyToManyField(to='courses.Subject')), | |
107 | 97 | ], |
108 | 98 | options={ |
109 | 99 | 'verbose_name': 'subject category', |
... | ... | @@ -120,8 +110,6 @@ class Migration(migrations.Migration): |
120 | 110 | ('create_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation Date')), |
121 | 111 | ('update_date', models.DateTimeField(auto_now=True, verbose_name='Date of last update')), |
122 | 112 | ('visible', models.BooleanField(default=False, verbose_name='Visible')), |
123 | - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Owner')), | |
124 | - ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Subject', verbose_name='Subject')), | |
125 | 113 | ], |
126 | 114 | options={ |
127 | 115 | 'ordering': ('create_date', 'name'), |
... | ... | @@ -129,14 +117,4 @@ class Migration(migrations.Migration): |
129 | 117 | 'verbose_name_plural': 'Topics', |
130 | 118 | }, |
131 | 119 | ), |
132 | - migrations.AddField( | |
133 | - model_name='material', | |
134 | - name='topic', | |
135 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='materials', to='courses.Topic', verbose_name='Topic'), | |
136 | - ), | |
137 | - migrations.AddField( | |
138 | - model_name='activity', | |
139 | - name='topic', | |
140 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='courses.Topic', verbose_name='Topic'), | |
141 | - ), | |
142 | 120 | ] | ... | ... |
... | ... | @@ -0,0 +1,80 @@ |
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/templates/subject/form_view_student.html
1 | 1 | {% load i18n %} |
2 | 2 | |
3 | +{% block javascript %} | |
4 | + <script type="text/javascript" src="{% static 'js/forum.js' %}"></script> | |
5 | +{% endblock %} | |
6 | + | |
3 | 7 | <div class="panel panel-default"> |
4 | 8 | <a href="{% url 'course:view_topic' topic.slug %}"> |
5 | 9 | <div class="panel-heading"> |
... | ... | @@ -13,4 +17,24 @@ |
13 | 17 | </div> |
14 | 18 | <div class="panel-body"> |
15 | 19 | <p>{{topic.description|linebreaks}}</p> |
20 | + {% list_topic_foruns request topic %} | |
21 | +</div> | |
22 | + | |
23 | +<div class="modal fade" id="forumModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
24 | + <div class="modal-dialog" role="document"> | |
25 | + <div class="modal-content"> | |
26 | + <div class="modal-header"> | |
27 | + <h4 class="modal-title" id="myModalLabel">{% trans 'Forum' %}</h4> | |
28 | + </div> | |
29 | + <div class="modal-body"> | |
30 | + <section> | |
31 | + <div class="forum_topics"></div> | |
32 | + </section> | |
33 | + </div> | |
34 | + <div class="modal-footer"> | |
35 | + <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans 'Close' %}</button> | |
36 | + <button type="button" class="btn btn-primary btn-raised">{% trans 'Save changes' %}</button> | |
37 | + </div> | |
38 | + </div> | |
39 | + </div> | |
16 | 40 | </div> |
17 | 41 | \ No newline at end of file | ... | ... |
courses/templates/subject/form_view_teacher.html
... | ... | @@ -19,7 +19,10 @@ |
19 | 19 | </a> |
20 | 20 | <div class="panel-body"> |
21 | 21 | <p>{{ topic.description|linebreaks }}</p> |
22 | - {% list_topic_foruns request topic %} | |
22 | + <button class="btn btn-primary btn-raised" onclick="createForum('{% url 'forum:create' %}', '{{ topic.id }}')">{% trans '+ Create Forum' %}</button> | |
23 | + <div class="foruns_list"> | |
24 | + {% list_topic_foruns request topic %} | |
25 | + </div> | |
23 | 26 | </div> |
24 | 27 | </div> |
25 | 28 | |
... | ... | @@ -27,7 +30,7 @@ |
27 | 30 | <div class="modal-dialog" role="document"> |
28 | 31 | <div class="modal-content"> |
29 | 32 | <div class="modal-header"> |
30 | - <h4 class="modal-title" id="myModalLabel">Forum</h4> | |
33 | + <h4 class="modal-title" id="myModalLabel">{% trans 'Forum' %}</h4> | |
31 | 34 | </div> |
32 | 35 | <div class="modal-body"> |
33 | 36 | <section> |
... | ... | @@ -40,4 +43,23 @@ |
40 | 43 | </div> |
41 | 44 | </div> |
42 | 45 | </div> |
46 | +</div> | |
47 | + | |
48 | +<div class="modal fade" id="createForum" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
49 | + <div class="modal-dialog" role="document"> | |
50 | + <div class="modal-content"> | |
51 | + <div class="modal-header"> | |
52 | + <h4 class="modal-title" id="myModalLabel">{% trans 'Forum' %}</h4> | |
53 | + </div> | |
54 | + <div class="modal-body"> | |
55 | + <section> | |
56 | + <div class="forum_form"></div> | |
57 | + </section> | |
58 | + </div> | |
59 | + <div class="modal-footer"> | |
60 | + <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans 'Close' %}</button> | |
61 | + <button type="button" onclick="$('#forum_create').submit();" class="btn btn-primary btn-raised">{% trans 'Create' %}</button> | |
62 | + </div> | |
63 | + </div> | |
64 | + </div> | |
43 | 65 | </div> |
44 | 66 | \ No newline at end of file | ... | ... |
forum/forms.py
... | ... | @@ -6,17 +6,22 @@ class ForumForm(forms.ModelForm): |
6 | 6 | |
7 | 7 | class Meta: |
8 | 8 | model = Forum |
9 | - fields = ('name', 'description') | |
9 | + fields = ('name', 'limit_date', 'description', 'topic', ) | |
10 | 10 | labels = { |
11 | 11 | 'name': _('Title'), |
12 | - 'description': _('Description') | |
12 | + 'description': _('Description'), | |
13 | + 'limit_date': _('Limit Date'), | |
13 | 14 | } |
14 | 15 | help_texts = { |
15 | 16 | 'name': _('Forum title'), |
16 | - 'description': _('What is this forum about?') | |
17 | + 'description': _('What is this forum about?'), | |
18 | + 'limit_date': _('Limit date for students post on this forum'), | |
17 | 19 | } |
18 | 20 | widgets = { |
19 | - 'description': forms.Textarea(attrs={'cols': 80, 'rows': 5}), | |
21 | + 'name': forms.TextInput(attrs={'class': 'form-control'}), | |
22 | + 'description': forms.Textarea(attrs={'cols': 80, 'rows': 5, 'class': 'form-control'}), | |
23 | + 'topic': forms.HiddenInput(), | |
24 | + 'limit_date': forms.DateInput(attrs={'class': 'date-picker form-control'}), | |
20 | 25 | } |
21 | 26 | |
22 | 27 | class PostForm(forms.ModelForm): | ... | ... |
forum/migrations/0001_initial.py
1 | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-10-01 16:02 | |
2 | +# Generated by Django 1.10 on 2016-10-02 00:17 | |
3 | 3 | from __future__ import unicode_literals |
4 | 4 | |
5 | -from django.conf import settings | |
6 | 5 | from django.db import migrations, models |
7 | 6 | import django.db.models.deletion |
8 | 7 | |
... | ... | @@ -13,7 +12,6 @@ class Migration(migrations.Migration): |
13 | 12 | |
14 | 13 | dependencies = [ |
15 | 14 | ('courses', '0001_initial'), |
16 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
17 | 15 | ] |
18 | 16 | |
19 | 17 | operations = [ |
... | ... | @@ -38,8 +36,6 @@ class Migration(migrations.Migration): |
38 | 36 | ('message', models.TextField(verbose_name='Post message')), |
39 | 37 | ('modification_date', models.DateTimeField(auto_now=True, verbose_name='Modification Date')), |
40 | 38 | ('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')), | |
43 | 39 | ], |
44 | 40 | options={ |
45 | 41 | 'verbose_name': 'Post', |
... | ... | @@ -54,7 +50,6 @@ class Migration(migrations.Migration): |
54 | 50 | ('modification_date', models.DateTimeField(auto_now=True, verbose_name='Modification Date')), |
55 | 51 | ('answer_date', models.DateTimeField(auto_now_add=True, verbose_name='Answer Date')), |
56 | 52 | ('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')), | |
58 | 53 | ], |
59 | 54 | options={ |
60 | 55 | 'verbose_name': 'Post Answer', | ... | ... |
... | ... | @@ -0,0 +1,35 @@ |
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
... | ... | @@ -14,6 +14,46 @@ function getCookie(name) { |
14 | 14 | return cookieValue; |
15 | 15 | } |
16 | 16 | |
17 | +function createForum(url, topic) { | |
18 | + $.ajax({ | |
19 | + url: url, | |
20 | + data: {'topic': topic}, | |
21 | + success: function(data) { | |
22 | + $(".forum_form").html(data); | |
23 | + $("#id_topic").val(topic); | |
24 | + | |
25 | + $('.date-picker').datepicker({ | |
26 | + orientation: 'auto' | |
27 | + }); | |
28 | + | |
29 | + | |
30 | + var frm = $('#forum_create'); | |
31 | + frm.submit(function () { | |
32 | + $.ajax({ | |
33 | + type: frm.attr('method'), | |
34 | + url: frm.attr('action'), | |
35 | + data: frm.serialize(), | |
36 | + success: function (data) { | |
37 | + data = data.split('-'); | |
38 | + | |
39 | + $('.foruns_list').append("<a href='javascript:"+showForum(data[0], data[1])+"'>"+data[2]+"</a><br />"); | |
40 | + | |
41 | + $("#createForum").modal('hide'); | |
42 | + | |
43 | + showForum(data[0], data[1]); | |
44 | + }, | |
45 | + error: function(data) { | |
46 | + console.log('Error'); | |
47 | + } | |
48 | + }); | |
49 | + return false; | |
50 | + }); | |
51 | + } | |
52 | + }); | |
53 | + | |
54 | + $("#createForum").modal(); | |
55 | +} | |
56 | + | |
17 | 57 | |
18 | 58 | /* |
19 | 59 | * | ... | ... |
forum/templates/forum/forum_form.html
1 | 1 | {% load static i18n %} |
2 | 2 | {% load widget_tweaks %} |
3 | 3 | |
4 | -<form method="post" action="" enctype="multipart/form-data"> | |
4 | +<form id="forum_create" method="post" action="{% url 'forum:create' %}" 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"> |
8 | - <label for="{{ field.auto_id }}">{{ field.label }}</label> | |
9 | - {% render_field field class='form-control' %} | |
10 | - <span class="help-block">{{ field.help_text }}</span> | |
11 | - {% if field.errors %} | |
12 | - <div class="row"> | |
13 | - <br /> | |
14 | - <div class="alert alert-danger alert-dismissible" role="alert"> | |
15 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
16 | - <span aria-hidden="true">×</span> | |
17 | - </button> | |
18 | - <ul> | |
19 | - {% for error in field.errors %} | |
20 | - <li>{{ error }}</li> | |
21 | - {% endfor %} | |
22 | - </ul> | |
8 | + {% if field.field.widget.input_type == 'hidden' %} | |
9 | + {% render_field field class='form-control' %} | |
10 | + {% else %} | |
11 | + <label for="{{ field.auto_id }}">{{ field.label }}</label> | |
12 | + {% render_field field %} | |
13 | + <span class="help-block">{{ field.help_text }}</span> | |
14 | + {% if field.errors %} | |
15 | + <div class="row"> | |
16 | + <br /> | |
17 | + <div class="alert alert-danger alert-dismissible" role="alert"> | |
18 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
19 | + <span aria-hidden="true">×</span> | |
20 | + </button> | |
21 | + <ul> | |
22 | + {% for error in field.errors %} | |
23 | + <li>{{ error }}</li> | |
24 | + {% endfor %} | |
25 | + </ul> | |
26 | + </div> | |
23 | 27 | </div> |
24 | - </div> | |
28 | + {% endif %} | |
25 | 29 | {% endif %} |
26 | 30 | </div> |
27 | 31 | {% endfor %} |
28 | - | |
29 | - <input type="submit" value="{% trans 'Create' %}" class="btn btn-primary" /> | |
30 | 32 | </form> |
31 | 33 | \ No newline at end of file | ... | ... |
forum/urls.py
... | ... | @@ -5,12 +5,13 @@ from . import views |
5 | 5 | |
6 | 6 | urlpatterns = [ |
7 | 7 | url(r'^$', views.ForumIndex.as_view(), name='index'), |
8 | - url(r'^create$', views.CreateForumView.as_view(), name='create'), | |
9 | - url(r'^create_post$', views.CreatePostView.as_view(), name='create_post'), | |
8 | + url(r'^create/$', views.CreateForumView.as_view(), name='create'), | |
9 | + url(r'^render_forum/([\w_-]+)/$', views.render_forum, name='render_forum'), | |
10 | + url(r'^create_post/$', views.CreatePostView.as_view(), name='create_post'), | |
10 | 11 | url(r'^update_post/(?P<pk>[\w_-]+)/$', views.PostUpdateView.as_view(), name='update_post'), |
11 | 12 | url(r'^delete_post/(?P<pk>[\w_-]+)/$', views.PostDeleteView.as_view(), name='delete_post'), |
12 | 13 | url(r'^render_post/([\w_-]+)/$', views.render_post, name='render_post'), |
13 | 14 | url(r'^post_deleted/$', views.post_deleted, name='deleted_post'), |
14 | - url(r'^post_answers$', views.PostAnswerIndex.as_view(), name='post_answers'), | |
15 | - url(r'^reply_post$', views.CreatePostAnswerView.as_view(), name='reply_post'), | |
15 | + url(r'^post_answers/$', views.PostAnswerIndex.as_view(), name='post_answers'), | |
16 | + url(r'^reply_post/$', views.CreatePostAnswerView.as_view(), name='reply_post'), | |
16 | 17 | ] | ... | ... |
forum/views.py
... | ... | @@ -31,10 +31,21 @@ class ForumIndex(LoginRequiredMixin, generic.ListView): |
31 | 31 | return context |
32 | 32 | |
33 | 33 | class CreateForumView(LoginRequiredMixin, generic.edit.CreateView): |
34 | + login_url = reverse_lazy("core:home") | |
35 | + redirect_field_name = 'next' | |
34 | 36 | |
35 | 37 | template_name = 'forum/forum_form.html' |
36 | 38 | form_class = ForumForm |
37 | - success_url = reverse_lazy('forum:index') | |
39 | + | |
40 | + def get_success_url(self): | |
41 | + self.success_url = reverse('forum:render_forum', args = (self.object.id, )) | |
42 | + | |
43 | + return self.success_url | |
44 | + | |
45 | +def render_forum(request, forum): | |
46 | + last_forum = get_object_or_404(Forum, id = forum) | |
47 | + | |
48 | + return HttpResponse(str(reverse_lazy('forum:index')) + '-' + str(forum) + '-' + str(last_forum.name)) | |
38 | 49 | |
39 | 50 | class CreatePostView(LoginRequiredMixin, generic.edit.CreateView): |
40 | 51 | login_url = reverse_lazy("core:home") | ... | ... |
poll/migrations/0001_initial.py