Commit 7b73050e7e9f1c239b981c441c8f4fe05603137b
1 parent
540405a9
Exists in
master
and in
3 other branches
subject subscribe button date filter is working
Showing
2 changed files
with
15 additions
and
4 deletions
Show diff stats
subjects/templates/subjects/subject_card.html
1 | -{% load static i18n permissions_tags %} | 1 | +{% load static i18n permissions_tags subject_counter %} |
2 | 2 | ||
3 | {% subject_permissions request.user subject as has_subject_permissions %} | 3 | {% subject_permissions request.user subject as has_subject_permissions %} |
4 | {% subject_view_permissions request.user subject as has_subject_view_permissions %} | 4 | {% subject_view_permissions request.user subject as has_subject_view_permissions %} |
@@ -73,8 +73,12 @@ | @@ -73,8 +73,12 @@ | ||
73 | 73 | ||
74 | {% if has_subject_view_permissions %} | 74 | {% if has_subject_view_permissions %} |
75 | <a href="{% url 'subjects:view' subject.slug %}" class="btn btn-success btn-raised"> {% trans "Access Subject" %}</a> | 75 | <a href="{% url 'subjects:view' subject.slug %}" class="btn btn-success btn-raised"> {% trans "Access Subject" %}</a> |
76 | - {% else %} | 76 | + {% elif subject.subscribe_end|aftertoday %} |
77 | <a href="javascript:subscribe_subject.get('{% url 'subjects:subscribe' subject.slug %}?view=index','#subject-subscribe','#modal_subject')" class="subscribe-subject btn btn-primary btn-raised"> {% trans "Subscribe to Subject" %}</a> | 77 | <a href="javascript:subscribe_subject.get('{% url 'subjects:subscribe' subject.slug %}?view=index','#subject-subscribe','#modal_subject')" class="subscribe-subject btn btn-primary btn-raised"> {% trans "Subscribe to Subject" %}</a> |
78 | + | ||
79 | + {% else %} | ||
80 | + <a class="subscribe-subject btn btn-primary btn-raised" disabled="disabled"> {% trans "This subject doesn't allow new subscriptions" %}</a> | ||
81 | + | ||
78 | {% endif %} | 82 | {% endif %} |
79 | 83 | ||
80 | {% endif %} | 84 | {% endif %} |
subjects/templatetags/subject_counter.py
1 | from django import template | 1 | from django import template |
2 | - | 2 | +import datetime |
3 | register = template.Library() | 3 | register = template.Library() |
4 | 4 | ||
5 | @register.filter(name = 'subject_count') | 5 | @register.filter(name = 'subject_count') |
@@ -13,4 +13,11 @@ def subject_count(category, user): | @@ -13,4 +13,11 @@ def subject_count(category, user): | ||
13 | else: | 13 | else: |
14 | total = category.subject_category.count() | 14 | total = category.subject_category.count() |
15 | 15 | ||
16 | - return total | ||
17 | \ No newline at end of file | 16 | \ No newline at end of file |
17 | + return total | ||
18 | + | ||
19 | + | ||
20 | +@register.filter(name = 'aftertoday') | ||
21 | +def after_today(date): | ||
22 | + if date > datetime.datetime.today().date(): | ||
23 | + return True | ||
24 | + return False | ||
18 | \ No newline at end of file | 25 | \ No newline at end of file |