diff --git a/core/static/js/base/header.js b/core/static/js/base/header.js index 08c7fbb..9375087 100644 --- a/core/static/js/base/header.js +++ b/core/static/js/base/header.js @@ -1,3 +1,25 @@ $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); //activate tooltip on all elements that has attribute data-toggle -}); \ No newline at end of file +}); + + +/* + +*/ +function loadNotifications(step){ + $.ajax('/loadNotifications',{ + steps: step, + amount: 5, + sucess: function(response){ + + } + }); +} + + +/* + +*/ +function checkIfNewNotification(){ + +} \ No newline at end of file diff --git a/core/views.py b/core/views.py index a548478..f3e27c7 100644 --- a/core/views.py +++ b/core/views.py @@ -6,7 +6,7 @@ from .decorators import log_decorator from django.contrib import messages from django.shortcuts import render, redirect from django.views.generic import CreateView, UpdateView -from django.http import HttpResponse +from django.http import HttpResponse, JsonResponse from django.core.mail import send_mail,BadHeaderError from django.conf import settings from core.mixins import NotificationMixin @@ -95,6 +95,18 @@ def processNotification(self, notificationId): notification.save() return redirect(notification.action_resource.resource.url) + + +def getNotifications(self, amount, step=0): + if self.request.is_ajax and self.request.user.is_authenticated: + notifications = Notification.objects.filter(user= self.request.user, read=False).orderby('-datetime')[step:amount] + else: #go to login page + return response('teste') + + return JsonResponse(notifications) + + + # class LoginClass(LoginView): # template_name='index.html' # -- libgit2 0.21.2