Commit dd123e2207fd7a5edb0354705574bf430346e286
1 parent
afce7b17
Exists in
master
and in
5 other branches
created js functions and views
Showing
2 changed files
with
36 additions
and
2 deletions
Show diff stats
core/static/js/base/header.js
1 | 1 | $(document).ready(function(){ |
2 | 2 | $('[data-toggle="tooltip"]').tooltip(); //activate tooltip on all elements that has attribute data-toggle |
3 | -}); | |
4 | 3 | \ No newline at end of file |
4 | +}); | |
5 | + | |
6 | + | |
7 | +/* | |
8 | + | |
9 | +*/ | |
10 | +function loadNotifications(step){ | |
11 | + $.ajax('/loadNotifications',{ | |
12 | + steps: step, | |
13 | + amount: 5, | |
14 | + sucess: function(response){ | |
15 | + | |
16 | + } | |
17 | + }); | |
18 | +} | |
19 | + | |
20 | + | |
21 | +/* | |
22 | + | |
23 | +*/ | |
24 | +function checkIfNewNotification(){ | |
25 | + | |
26 | +} | |
5 | 27 | \ No newline at end of file | ... | ... |
core/views.py
... | ... | @@ -6,7 +6,7 @@ from .decorators import log_decorator |
6 | 6 | from django.contrib import messages |
7 | 7 | from django.shortcuts import render, redirect |
8 | 8 | from django.views.generic import CreateView, UpdateView |
9 | -from django.http import HttpResponse | |
9 | +from django.http import HttpResponse, JsonResponse | |
10 | 10 | from django.core.mail import send_mail,BadHeaderError |
11 | 11 | from django.conf import settings |
12 | 12 | from core.mixins import NotificationMixin |
... | ... | @@ -95,6 +95,18 @@ def processNotification(self, notificationId): |
95 | 95 | notification.save() |
96 | 96 | return redirect(notification.action_resource.resource.url) |
97 | 97 | |
98 | + | |
99 | + | |
100 | +def getNotifications(self, amount, step=0): | |
101 | + if self.request.is_ajax and self.request.user.is_authenticated: | |
102 | + notifications = Notification.objects.filter(user= self.request.user, read=False).orderby('-datetime')[step:amount] | |
103 | + else: #go to login page | |
104 | + return response('teste') | |
105 | + | |
106 | + return JsonResponse(notifications) | |
107 | + | |
108 | + | |
109 | + | |
98 | 110 | # class LoginClass(LoginView): |
99 | 111 | # template_name='index.html' |
100 | 112 | # | ... | ... |