Commit f02ce614e72b2f90ecbbb52830dcb94cace64fe9

Authored by fbormann
1 parent a58f106a

Fixed notification icon and added context-processor fully functional now, error …

…on login when using context-processor fixed #41
amadeus/settings.py
@@ -94,8 +94,8 @@ DATABASES = { @@ -94,8 +94,8 @@ DATABASES = {
94 'default': { 94 'default': {
95 'ENGINE': 'django.db.backends.postgresql', 95 'ENGINE': 'django.db.backends.postgresql',
96 'NAME': 'amadeus', 96 'NAME': 'amadeus',
97 - 'USER': 'amadeus_admin',  
98 - 'PASSWORD': 'amadeus', 97 + 'USER': 'postgres',
  98 + 'PASSWORD': 'felipe',
99 'HOST': '127.0.0.1', 99 'HOST': '127.0.0.1',
100 'PORT': '5432', 100 'PORT': '5432',
101 } 101 }
core/context_processors.py
1 from .models import Notification 1 from .models import Notification
2 2
3 def notifications(request): 3 def notifications(request):
4 - return {  
5 - 'notifications': Notifications.objects.filter(user= request.user, read=False).order_by('-datetime')  
6 - }  
7 \ No newline at end of file 4 \ No newline at end of file
  5 + if request.user.is_authenticated:
  6 + return {
  7 + 'notifications': Notification.objects.filter(user= request.user, read=False).order_by('-datetime')
  8 + }
  9 + else:
  10 + return request
8 \ No newline at end of file 11 \ No newline at end of file
core/static/css/base/header.css
@@ -21,6 +21,10 @@ @@ -21,6 +21,10 @@
21 transform:scale(1.1); 21 transform:scale(1.1);
22 } 22 }
23 23
  24 +.notification-count{
  25 + background-color: #cc0000;
  26 +}
  27 +
24 /* ID */ 28 /* ID */
25 29
26 .notifications{ 30 .notifications{
core/templates/base.html
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
53 <div class="navbar-collapse collapse navbar-responsive-collapse"> 53 <div class="navbar-collapse collapse navbar-responsive-collapse">
54 <ul class="nav navbar-nav navbar-right notifications"> 54 <ul class="nav navbar-nav navbar-right notifications">
55 <li class="" data-toggle="tooltip" data-placement="bottom" title data-original-title="notifications"> 55 <li class="" data-toggle="tooltip" data-placement="bottom" title data-original-title="notifications">
56 - <a class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bell-o" aria-hidden="true"></i></a> 56 + <a class="dropdown-toggle" data-toggle="dropdown"> <span class="badge notification-count">{{notifications.count}}</span><i class="fa fa-bell-o" aria-hidden="true"></i></a>
57 <ul class="dropdown-menu"> 57 <ul class="dropdown-menu">
58 <li class="dropdown-header">Notifications</li> 58 <li class="dropdown-header">Notifications</li>
59 {% for notification in notifications %} 59 {% for notification in notifications %}