diff --git a/amadeus/settings.py b/amadeus/settings.py index 6773eaa..6878198 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -77,6 +77,8 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + + 'core.context_processors.notifications', ], }, }, diff --git a/app/views.py b/app/views.py index be009f0..18f5e22 100644 --- a/app/views.py +++ b/app/views.py @@ -39,10 +39,6 @@ class AppIndex(LoginRequiredMixin, LogMixin, ListView, NotificationMixin): self.template_name = "home_admin_content.html" super(AppIndex, self).createNotification("teste", not_resource="home", resource_link="/register") - - notifications = Notification.objects.filter(user= self.request.user, read=False) - context['notifications'] = notifications - return self.response_class(request = self.request, template = self.template_name, context = context, using = self.template_engine, **response_kwargs) diff --git a/core/context_processors.py b/core/context_processors.py new file mode 100644 index 0000000..d0f4aa6 --- /dev/null +++ b/core/context_processors.py @@ -0,0 +1,6 @@ +from .models import Notification + +def notifications(request): + return { + 'notifications': Notifications.objects.filter(user= request.user, read=False).order_by('-datetime') + } \ No newline at end of file -- libgit2 0.21.2