Commit 5f472d6bb35a4a4cd61c9c7127f80da1b9a0b6a9
1 parent
91e85324
Exists in
master
and in
3 other branches
Adding mural post notifications badge
Showing
9 changed files
with
56 additions
and
10 deletions
Show diff stats
amadeus/context_processors.py
... | ... | @@ -2,6 +2,7 @@ from datetime import datetime |
2 | 2 | |
3 | 3 | from themes.models import Themes |
4 | 4 | from notifications.models import Notification |
5 | +from mural.models import MuralVisualizations | |
5 | 6 | |
6 | 7 | def theme(request): |
7 | 8 | context = {} |
... | ... | @@ -22,4 +23,16 @@ def notifies(request): |
22 | 23 | |
23 | 24 | context['notifications_count'] = notifications |
24 | 25 | |
26 | + return context | |
27 | + | |
28 | +def mural_notifies(request): | |
29 | + context = {} | |
30 | + | |
31 | + notifications = 0 | |
32 | + | |
33 | + if request.user.is_authenticated: | |
34 | + notifications = MuralVisualizations.objects.filter(viewed = False, user = request.user).count() | |
35 | + | |
36 | + context['mural_notifications_count'] = notifications | |
37 | + | |
25 | 38 | return context |
26 | 39 | \ No newline at end of file | ... | ... |
amadeus/settings.py
amadeus/static/css/base/amadeus.css
... | ... | @@ -1043,7 +1043,7 @@ li.item .notify_badge { |
1043 | 1043 | padding: 10px 0px 8px 0px; |
1044 | 1044 | } |
1045 | 1045 | |
1046 | -.post .post-comment .user-img { | |
1046 | +.post .post-comment .user-img div { | |
1047 | 1047 | display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */ |
1048 | 1048 | display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */ |
1049 | 1049 | display: -ms-flexbox; /* TWEENER - IE 10 */ | ... | ... |
amadeus/static/css/base/amadeus_responsive.css
1 | 1 | @media(min-width: 1200px) { |
2 | - .mural .post_make .user-img { | |
2 | + .mural .post_make .user-img, .post .post-img { | |
3 | 3 | height: 70px; |
4 | 4 | } |
5 | 5 | |
6 | + .post .post-comment .user-img div { | |
7 | + height: 38px; | |
8 | + } | |
9 | + | |
6 | 10 | .mural .post_make .user-img img { |
7 | 11 | max-width: 70px; |
8 | 12 | max-height: 70px; |
... | ... | @@ -18,10 +22,14 @@ |
18 | 22 | padding: 15px; |
19 | 23 | } |
20 | 24 | |
21 | - .mural .post_make .user-img { | |
25 | + .mural .post_make .user-img, .post .post-img { | |
22 | 26 | height: 65px; |
23 | 27 | } |
24 | 28 | |
29 | + .post .post-comment .user-img div { | |
30 | + height: 38px; | |
31 | + } | |
32 | + | |
25 | 33 | .mural .post_make .user-img img { |
26 | 34 | max-width: 65px; |
27 | 35 | max-height: 65px; |
... | ... | @@ -87,7 +95,7 @@ |
87 | 95 | display:none; |
88 | 96 | } |
89 | 97 | |
90 | - .mural .post_make .user-img { | |
98 | + .mural .post_make .user-img, .post .post-img { | |
91 | 99 | height: 60px; |
92 | 100 | } |
93 | 101 | |
... | ... | @@ -161,7 +169,7 @@ |
161 | 169 | } |
162 | 170 | |
163 | 171 | @media(max-width: 680px) { |
164 | - .mural .post_make .user-img { | |
172 | + .mural .post_make .user-img, .post .post-img { | |
165 | 173 | height: 50px; |
166 | 174 | } |
167 | 175 | ... | ... |
amadeus/static/css/themes/green.css
amadeus/static/js/socket.js
... | ... | @@ -15,6 +15,22 @@ socket.onmessage = function(e) { |
15 | 15 | $('.posts').prepend(content.complete); |
16 | 16 | |
17 | 17 | $('.no-subjects').attr('style', 'display:none'); |
18 | + } else { | |
19 | + $('.mural_badge').each(function () { | |
20 | + var actual = $(this).text(); | |
21 | + | |
22 | + if (actual != "+99") { | |
23 | + actual = parseInt(actual, 10) + 1; | |
24 | + | |
25 | + if (actual > 99) { | |
26 | + actual = "+99"; | |
27 | + } | |
28 | + | |
29 | + $(this).text(actual); | |
30 | + } | |
31 | + | |
32 | + $(this).show(); | |
33 | + }); | |
18 | 34 | } |
19 | 35 | |
20 | 36 | if (("Notification" in window)) { | ... | ... |
amadeus/templates/base.html
... | ... | @@ -190,9 +190,10 @@ |
190 | 190 | <i class="fa fa-graduation-cap" aria-hidden="true"></i> |
191 | 191 | </a> |
192 | 192 | </li> |
193 | - <li class="item {{ mural_menu_active }}" data-toggle="tooltip" data-placement="right" title="{% trans "Timeline" %}"> | |
193 | + <li class="item {{ mural_menu_active }} action_icon" data-toggle="tooltip" data-placement="right" title="{% trans "Timeline" %}"> | |
194 | 194 | <a href="{% url 'mural:manage_general' %}"> |
195 | 195 | <i class="fa fa-list" aria-hidden="true" ></i> |
196 | + <span class="badge notify_badge mural_badge" {% if mural_notifications_count == 0 %} style="display:none" {% endif %}>{% if mural_notifications_count > 99 %} +99 {% else %} {{ mural_notifications_count }} {% endif %}</span> | |
196 | 197 | </a> |
197 | 198 | </li> |
198 | 199 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Messages" %}"> |
... | ... | @@ -241,9 +242,10 @@ |
241 | 242 | <i class="fa fa-graduation-cap" aria-hidden="true"></i> |
242 | 243 | </a> |
243 | 244 | </li> |
244 | - <li class="item {{ mural_menu_active }}" data-toggle="tooltip" data-placement="top" title="{% trans "Timeline" %}"> | |
245 | + <li class="item {{ mural_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Timeline" %}"> | |
245 | 246 | <a href="{% url 'mural:manage_general' %}" |
246 | 247 | <i class="fa fa-list" aria-hidden="true" ></i> |
248 | + <span class="badge notify_badge mural_badge" {% if mural_notifications_count == 0 %} style="display:none" {% endif %}>{% if mural_notifications_count > 99 %} +99 {% else %} {{ mural_notifications_count }} {% endif %}</span> | |
247 | 249 | </a> |
248 | 250 | </li> |
249 | 251 | <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Messages" %}"> | ... | ... |
mural/templates/mural/_view.html
... | ... | @@ -45,7 +45,9 @@ |
45 | 45 | </div> |
46 | 46 | <div class="col-md-12 post-comment"> |
47 | 47 | <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 user-img"> |
48 | - <img src="{{ request.user.image_url }}" class="img-responsive" /> | |
48 | + <div> | |
49 | + <img src="{{ request.user.image_url }}" class="img-responsive" /> | |
50 | + </div> | |
49 | 51 | </div> |
50 | 52 | <div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 comment-field"> |
51 | 53 | <div> | ... | ... |
mural/views.py
... | ... | @@ -33,10 +33,14 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): |
33 | 33 | |
34 | 34 | general = GeneralPost.objects.extra(select={"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).order_by("-most_recent") |
35 | 35 | |
36 | - self.totals['general'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__generalpost__isnull = False) | Q(comment__post__generalpost__isnull = False))).distinct().count() | |
36 | + general_visualizations = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__generalpost__isnull = False) | Q(comment__post__generalpost__isnull = False))).distinct() | |
37 | + | |
38 | + self.totals['general'] = general_visualizations.count() | |
37 | 39 | self.totals['category'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__categorypost__space__coordinators = user) | Q(comment__post__categorypost__space__coordinators = user) | Q(post__categorypost__space__subject_category__professor = user) | Q(post__categorypost__space__subject_category__students = user) | Q(comment__post__categorypost__space__subject_category__professor = user) | Q(comment__post__categorypost__space__subject_category__students = user))).distinct().count() |
38 | 40 | self.totals['subject'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__subjectpost__space__professor = user) | Q(comment__post__subjectpost__space__professor = user) | Q(post__subjectpost__space__students = user) | Q(comment__post__subjectpost__space__students = user))).distinct().count() |
39 | 41 | |
42 | + general_visualizations.update(viewed = True) | |
43 | + | |
40 | 44 | return general |
41 | 45 | |
42 | 46 | def get_context_data(self, **kwargs): | ... | ... |