Commit 84de9b89b9fed6d9c017ba5ae3e3de39ee82a2b7

Authored by fbormann
1 parent 86c2739f

Added context processor to Notifications #41

amadeus/settings.py
... ... @@ -77,6 +77,8 @@ TEMPLATES = [
77 77 'django.template.context_processors.request',
78 78 'django.contrib.auth.context_processors.auth',
79 79 'django.contrib.messages.context_processors.messages',
  80 +
  81 + 'core.context_processors.notifications',
80 82 ],
81 83 },
82 84 },
... ...
app/views.py
... ... @@ -39,10 +39,6 @@ class AppIndex(LoginRequiredMixin, LogMixin, ListView, NotificationMixin):
39 39 self.template_name = "home_admin_content.html"
40 40  
41 41 super(AppIndex, self).createNotification("teste", not_resource="home", resource_link="/register")
42   -
43   - notifications = Notification.objects.filter(user= self.request.user, read=False)
44   - context['notifications'] = notifications
45   -
46 42 return self.response_class(request = self.request, template = self.template_name, context = context, using = self.template_engine, **response_kwargs)
47 43  
48 44  
... ...
core/context_processors.py 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +from .models import Notification
  2 +
  3 +def notifications(request):
  4 + return {
  5 + 'notifications': Notifications.objects.filter(user= request.user, read=False).order_by('-datetime')
  6 + }
0 7 \ No newline at end of file
... ...