Commit ed90db29fef6d4370802020766241402bda83bcb
1 parent
6f82ec2d
Exists in
master
and in
3 other branches
Adding notifications count badge
Showing
11 changed files
with
126 additions
and
32 deletions
Show diff stats
amadeus/context_processors.py
| 1 | +from datetime import datetime | |
| 2 | + | |
| 1 | 3 | from themes.models import Themes |
| 4 | +from notifications.models import Notification | |
| 2 | 5 | |
| 3 | 6 | def theme(request): |
| 4 | 7 | context = {} |
| ... | ... | @@ -7,4 +10,13 @@ def theme(request): |
| 7 | 10 | |
| 8 | 11 | context['theme'] = theme |
| 9 | 12 | |
| 13 | + return context | |
| 14 | + | |
| 15 | +def notifies(request): | |
| 16 | + context = {} | |
| 17 | + | |
| 18 | + notifications = Notification.objects.filter(creation_date = datetime.now()).count() | |
| 19 | + | |
| 20 | + context['notifications_count'] = notifications | |
| 21 | + | |
| 10 | 22 | return context |
| 11 | 23 | \ No newline at end of file | ... | ... |
amadeus/settings.py
| ... | ... | @@ -103,6 +103,7 @@ TEMPLATES = [ |
| 103 | 103 | 'django.contrib.auth.context_processors.auth', |
| 104 | 104 | 'django.contrib.messages.context_processors.messages', |
| 105 | 105 | 'amadeus.context_processors.theme', |
| 106 | + 'amadeus.context_processors.notifies', | |
| 106 | 107 | ], |
| 107 | 108 | }, |
| 108 | 109 | }, |
| ... | ... | @@ -171,7 +172,7 @@ STATICFILES_DIRS = [ |
| 171 | 172 | ] |
| 172 | 173 | |
| 173 | 174 | CRON_CLASSES = [ |
| 174 | - 'notifications.cron.Test' | |
| 175 | + 'notifications.cron.Notify' | |
| 175 | 176 | ] |
| 176 | 177 | |
| 177 | 178 | #SECURITY | ... | ... |
amadeus/static/css/base/amadeus.css
| ... | ... | @@ -30,36 +30,28 @@ a:focus { |
| 30 | 30 | |
| 31 | 31 | .users-cloud .small a { |
| 32 | 32 | font-size: 1.25em; |
| 33 | - color: #2E8B57; | |
| 34 | 33 | } |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | .users-cloud .big a { |
| 38 | 37 | font-size: 2.25em; |
| 39 | - color: #6B8E23; | |
| 40 | 38 | } |
| 41 | 39 | |
| 42 | 40 | .users-cloud .medium a { |
| 43 | 41 | font-size: 1.75em; |
| 44 | - color: #66CDAA; | |
| 45 | 42 | } |
| 46 | 43 | |
| 47 | 44 | .users-cloud .tiny a { |
| 48 | 45 | font-size: 0.75em; |
| 49 | - color: #654321; | |
| 50 | 46 | } |
| 51 | 47 | .users-cloud a { |
| 52 | 48 | text-decoration: none; |
| 53 | 49 | } |
| 54 | 50 | |
| 55 | -#search-results-title{ | |
| 56 | - color: #BDBDBD; | |
| 57 | -} | |
| 58 | - | |
| 59 | 51 | .div-users-cloud{ |
| 60 | - height: 100%; | |
| 61 | - margin-left: -10px; | |
| 62 | - width: 100%; | |
| 52 | + height: 100%; | |
| 53 | + margin-left: -10px; | |
| 54 | + width: 100%; | |
| 63 | 55 | } |
| 64 | 56 | |
| 65 | 57 | .my-subjects-title { |
| ... | ... | @@ -590,11 +582,6 @@ a:focus { |
| 590 | 582 | .subscribe-subject { |
| 591 | 583 | border:none; |
| 592 | 584 | } |
| 593 | - | |
| 594 | -.no-subscribe-btn{ | |
| 595 | - background-color: #BDBDBD !important; | |
| 596 | - color: #F5F5F5 !important; | |
| 597 | -} | |
| 598 | 585 | /* subjects app ends */ |
| 599 | 586 | |
| 600 | 587 | /* Themes */ |
| ... | ... | @@ -827,4 +814,24 @@ a.add-row { |
| 827 | 814 | |
| 828 | 815 | .add_resource ul { |
| 829 | 816 | width: 100%; |
| 817 | +} | |
| 818 | + | |
| 819 | +.action_icon { | |
| 820 | + position: relative; | |
| 821 | +} | |
| 822 | + | |
| 823 | +li.item .notify_badge { | |
| 824 | + top: 0px; | |
| 825 | + right: 0px; | |
| 826 | +} | |
| 827 | + | |
| 828 | +.notify_badge { | |
| 829 | + position: absolute; | |
| 830 | + right: 4px; | |
| 831 | + top: -5px; | |
| 832 | + width: 1.9rem; | |
| 833 | + line-height: 1.9rem; | |
| 834 | + font-size: 0.9rem; | |
| 835 | + border-radius: 50%; | |
| 836 | + padding: 0px; | |
| 830 | 837 | } |
| 831 | 838 | \ No newline at end of file | ... | ... |
amadeus/static/css/themes/green.css
| ... | ... | @@ -397,6 +397,35 @@ a.add-row { |
| 397 | 397 | background-color: initial !important; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | +.notify_badge { | |
| 401 | + background-color: #FF0000 !important; | |
| 402 | +} | |
| 403 | + | |
| 404 | +#search-results-title{ | |
| 405 | + color: #BDBDBD; | |
| 406 | +} | |
| 407 | + | |
| 408 | +.users-cloud .small a { | |
| 409 | + color: #2E8B57; | |
| 410 | +} | |
| 411 | + | |
| 412 | +.users-cloud .big a { | |
| 413 | + color: #6B8E23; | |
| 414 | +} | |
| 415 | + | |
| 416 | +.users-cloud .medium a { | |
| 417 | + color: #66CDAA; | |
| 418 | +} | |
| 419 | + | |
| 420 | +.users-cloud .tiny a { | |
| 421 | + color: #654321; | |
| 422 | +} | |
| 423 | + | |
| 424 | +.no-subscribe-btn{ | |
| 425 | + background-color: #BDBDBD !important; | |
| 426 | + color: #F5F5F5 !important; | |
| 427 | +} | |
| 428 | + | |
| 400 | 429 | @media(max-width: 768px) { |
| 401 | 430 | .navbar .navbar-nav .dropdown .dropdown-menu li > a { |
| 402 | 431 | color: #333333 !important; | ... | ... |
amadeus/templates/base.html
| ... | ... | @@ -160,8 +160,13 @@ |
| 160 | 160 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Messages" %}"> |
| 161 | 161 | <i class="fa fa-envelope-o" aria-hidden="true"></i> |
| 162 | 162 | </li> |
| 163 | - <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Pendencias" %}"> | |
| 164 | - <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
| 163 | + <li class="item action_icon" data-toggle="tooltip" data-placement="right" title="{% trans "Pendencias" %}"> | |
| 164 | + <a href=""> | |
| 165 | + <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
| 166 | + {% if notifications_count > 0 %} | |
| 167 | + <span class="badge notify_badge">{% if notifications_count > 99 %} +99 {% else %} {{ notifications_count }} {% endif %}</span> | |
| 168 | + {% endif %} | |
| 169 | + </a> | |
| 165 | 170 | </li> |
| 166 | 171 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Analytics" %}"> |
| 167 | 172 | <i class="fa fa-bar-chart" aria-hidden="true"></i> |
| ... | ... | @@ -204,8 +209,13 @@ |
| 204 | 209 | <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Messages" %}"> |
| 205 | 210 | <i class="fa fa-envelope-o" aria-hidden="true"></i> |
| 206 | 211 | </li> |
| 207 | - <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Pendencias" %}"> | |
| 208 | - <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
| 212 | + <li class="item action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Pendencias" %}"> | |
| 213 | + <a href=""> | |
| 214 | + <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
| 215 | + {% if notifications_count > 0 %} | |
| 216 | + <span class="badge notify_badge">{% if notifications_count > 99 %} +99 {% else %} {{ notifications_count }} {% endif %}</span> | |
| 217 | + {% endif %} | |
| 218 | + </a> | |
| 209 | 219 | </li> |
| 210 | 220 | <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Analytics" %}"> |
| 211 | 221 | <i class="fa fa-bar-chart" aria-hidden="true"></i> | ... | ... |
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +from django import template | |
| 2 | +from datetime import datetime | |
| 3 | + | |
| 4 | +from notifications.models import Notification | |
| 5 | + | |
| 6 | +register = template.Library() | |
| 7 | + | |
| 8 | +@register.inclusion_tag('subjects/badge.html') | |
| 9 | +def notifies_cat_number(category): | |
| 10 | + context = {} | |
| 11 | + | |
| 12 | + context['number'] = Notification.objects.filter(task__resource__topic__subject__category = category, creation_date = datetime.now()).count() | |
| 13 | + | |
| 14 | + return context | |
| 0 | 15 | \ No newline at end of file | ... | ... |
notifications/cron.py
subjects/templates/subjects/list.html
| 1 | 1 | {% extends 'categories/home.html' %} |
| 2 | 2 | |
| 3 | 3 | {% load static i18n pagination %} |
| 4 | -{% load django_bootstrap_breadcrumbs subject_counter %} | |
| 4 | +{% load django_bootstrap_breadcrumbs subject_counter category_counters %} | |
| 5 | 5 | |
| 6 | 6 | {% block javascript%} |
| 7 | 7 | {{ block.super }} |
| ... | ... | @@ -79,10 +79,14 @@ |
| 79 | 79 | <a href="javascript:delete_course.get('{% url 'categories:delete' category.slug %}?view=index','#category','#modal_course')" aria-hidden="true"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans 'Remove' %}</a></li> |
| 80 | 80 | </ul> |
| 81 | 81 | {% endif %} |
| 82 | - <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
| 83 | - <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | |
| 84 | - <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | |
| 85 | - <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> | |
| 82 | + | |
| 83 | + <a href="" class="pull-right action_icon"><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
| 84 | + <a href="" class="pull-right action_icon"> | |
| 85 | + <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
| 86 | + {% notifies_cat_number category %} | |
| 87 | + </a> | |
| 88 | + <a href="" class="pull-right action_icon"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | |
| 89 | + <a href="" class="pull-right action_icon"><i class="fa fa-list" aria-hidden="true"></i></a> | |
| 86 | 90 | </div> |
| 87 | 91 | </div> |
| 88 | 92 | </div> | ... | ... |
subjects/templates/subjects/subject_card.html
| ... | ... | @@ -36,10 +36,13 @@ |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - <a href=""><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
| 40 | - <a href=""><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></a> | |
| 41 | - <a href=""><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | |
| 42 | - <a href="" ><i class="fa fa-list" aria-hidden="true"></i></a> | |
| 39 | + <a href="" class="pull-right action_icon"><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
| 40 | + <a href="" class="pull-right action_icon"> | |
| 41 | + <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
| 42 | + {% notifies_number subject %} | |
| 43 | + </a> | |
| 44 | + <a href="" class="pull-right action_icon"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> | |
| 45 | + <a href="" class="pull-right action_icon"><i class="fa fa-list" aria-hidden="true"></i></a> | |
| 43 | 46 | </div> |
| 44 | 47 | </div> |
| 45 | 48 | </div> | ... | ... |
subjects/templatetags/subject_counter.py
| 1 | -from django import template | |
| 2 | 1 | import datetime |
| 2 | +from django import template | |
| 3 | +from django.db.models import Q | |
| 4 | + | |
| 5 | +from notifications.models import Notification | |
| 6 | + | |
| 3 | 7 | register = template.Library() |
| 4 | 8 | |
| 5 | 9 | @register.filter(name = 'subject_count') |
| ... | ... | @@ -15,6 +19,13 @@ def subject_count(category, user): |
| 15 | 19 | |
| 16 | 20 | return total |
| 17 | 21 | |
| 22 | +@register.inclusion_tag('subjects/badge.html') | |
| 23 | +def notifies_number(subject): | |
| 24 | + context = {} | |
| 25 | + | |
| 26 | + context['number'] = Notification.objects.filter(task__resource__topic__subject = subject, creation_date = datetime.datetime.now()).count() | |
| 27 | + | |
| 28 | + return context | |
| 18 | 29 | |
| 19 | 30 | @register.filter(name = 'aftertoday') |
| 20 | 31 | def after_today(date): | ... | ... |