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 | $(document).ready(function(){ | 1 | $(document).ready(function(){ |
2 | $('[data-toggle="tooltip"]').tooltip(); //activate tooltip on all elements that has attribute data-toggle | 2 | $('[data-toggle="tooltip"]').tooltip(); //activate tooltip on all elements that has attribute data-toggle |
3 | -}); | ||
4 | \ No newline at end of file | 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 | \ No newline at end of file | 27 | \ No newline at end of file |
core/views.py
@@ -6,7 +6,7 @@ from .decorators import log_decorator | @@ -6,7 +6,7 @@ from .decorators import log_decorator | ||
6 | from django.contrib import messages | 6 | from django.contrib import messages |
7 | from django.shortcuts import render, redirect | 7 | from django.shortcuts import render, redirect |
8 | from django.views.generic import CreateView, UpdateView | 8 | from django.views.generic import CreateView, UpdateView |
9 | -from django.http import HttpResponse | 9 | +from django.http import HttpResponse, JsonResponse |
10 | from django.core.mail import send_mail,BadHeaderError | 10 | from django.core.mail import send_mail,BadHeaderError |
11 | from django.conf import settings | 11 | from django.conf import settings |
12 | from core.mixins import NotificationMixin | 12 | from core.mixins import NotificationMixin |
@@ -95,6 +95,18 @@ def processNotification(self, notificationId): | @@ -95,6 +95,18 @@ def processNotification(self, notificationId): | ||
95 | notification.save() | 95 | notification.save() |
96 | return redirect(notification.action_resource.resource.url) | 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 | # class LoginClass(LoginView): | 110 | # class LoginClass(LoginView): |
99 | # template_name='index.html' | 111 | # template_name='index.html' |
100 | # | 112 | # |