From 3a6a41bd2ffbea2d61618f3997ea706b93f0a79e Mon Sep 17 00:00:00 2001 From: Zambom Date: Mon, 7 Nov 2016 20:59:20 -0300 Subject: [PATCH] Applying date limit [Issue: #259] --- forum/models.py | 7 +++++++ forum/static/js/forum.js | 2 ++ forum/templates/forum/forum_view.html | 76 +++++++++++++++++++++++++++++++++++++++------------------------------------- forum/templates/post/post_list.html | 36 +++++++++++++++++++----------------- forum/templates/post_answers/post_answer_list.html | 24 +++++++++++++----------- 5 files changed, 80 insertions(+), 65 deletions(-) diff --git a/forum/models.py b/forum/models.py index 07cf60a..554b5fe 100644 --- a/forum/models.py +++ b/forum/models.py @@ -6,6 +6,8 @@ from autoslug.fields import AutoSlugField from courses.models import Activity from users.models import User +from datetime import date + """ It's one kind of activity available for a Topic. It works like a 'topic' of forum, which users can post to it and answer posts of it. @@ -23,6 +25,11 @@ class Forum(Activity): def __str__(self): return self.name + def is_closed(self): + today = date.today() + + return self.limit_date < today + """ It represents a post made in a forum (topic) diff --git a/forum/static/js/forum.js b/forum/static/js/forum.js index 43d958d..b732088 100644 --- a/forum/static/js/forum.js +++ b/forum/static/js/forum.js @@ -62,6 +62,7 @@ function createForum(url, topic) { function setForumCreateFormSubmit(topic) { $('.date-picker').datepicker({ language: locale, + startDate: "dateToday" }); var frm = $('#forum_create'); @@ -114,6 +115,7 @@ function editForum(url, forum, success_message) { function setForumUpdateFormSubmit(success_message) { $('.date-picker').datepicker({ language: locale, + startDate: "dateToday" }); var frm = $('#forum_create'); diff --git a/forum/templates/forum/forum_view.html b/forum/templates/forum/forum_view.html index c331937..8351b2b 100644 --- a/forum/templates/forum/forum_view.html +++ b/forum/templates/forum/forum_view.html @@ -59,45 +59,47 @@

{% trans 'Opened in' %}: {{ forum.create_date }}

-
-
-
- {% csrf_token %} - {% for field in form %} - {% if field.field.widget.input_type == 'hidden' %} - {% render_field field class='form-control' value=forum.id %} - {% else %} -
-
- {% render_field field class='form-control' placeholder="Post a message" %} - {{ field.help_text }} - {% if field.errors %} -
-
- - {% endif %} - {% endfor %} - -
-
+ {% endif %} + {% endfor %} + +
+
+ {% endif %}
{% list_posts request forum %}
diff --git a/forum/templates/post/post_list.html b/forum/templates/post/post_list.html index 7a1cdaf..509cc79 100644 --- a/forum/templates/post/post_list.html +++ b/forum/templates/post/post_list.html @@ -6,23 +6,25 @@

{{ post.user }} -
- - {% trans 'reply' %} - - {% if request.user|has_role:'system_admin' or request.user == post.user %} - {% csrf_token %} - - {% endif %} -
+ {% if not post.forum.is_closed %} +
+ + {% trans 'reply' %} + + {% if request.user|has_role:'system_admin' or request.user == post.user %} + {% csrf_token %} + + {% endif %} +
+ {% endif %}

diff --git a/forum/templates/post_answers/post_answer_list.html b/forum/templates/post_answers/post_answer_list.html index 5d0e066..8e7f2b6 100644 --- a/forum/templates/post_answers/post_answer_list.html +++ b/forum/templates/post_answers/post_answer_list.html @@ -7,18 +7,20 @@

{{ answer.user }} - {% if request.user|has_role:'system_admin' or request.user == answer.user %} -
-
- - + {% if not answer.post.forum.is_closed %} + {% if request.user|has_role:'system_admin' or request.user == answer.user %} + -
+ {% endif %} {% endif %}

-- libgit2 0.21.2