Commit 4bb420278e4ebbf424e981e99d392520f4be3260
1 parent
d0f76248
Exists in
master
and in
5 other branches
Adding Forum create template [Issue: #88]
Showing
6 changed files
with
82 additions
and
27 deletions
Show diff stats
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/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/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 | ... | ... |