views.py
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from django.shortcuts import render
from django.views.generic import TemplateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.urlresolvers import reverse_lazy
from core.mixins import LogMixin, NotificationMixin
from core.models import Notification, Action, Resource, Action_Resource
from users.models import User
from courses.models import Course
class AppIndex(LoginRequiredMixin, LogMixin, TemplateView, NotificationMixin):
log_action = "Acessar"
log_resource = "Home"
login_url = reverse_lazy("core:home")
redirect_field_name = 'next'
template_name = "home_professor.html"
not_action = "Acessar"
not_resource = "home"
def render_to_response(self, context, **response_kwargs):
context = {}
if self.request.user.type_profile == 2:
template = "home_student.html"
context['courses'] = Course.objects.filter(user = self.request.user)
else:
template = self.get_template_names()
context['courses'] = Course.objects.filter(user = self.request.user)
context['title'] = 'Amadeus'
#super(AppIndex, self).createNotification("teste", not_resource="home", resource_link="users")
notifications = Notification.objects.filter(user= self.request.user, read=False)
context['notifications'] = notifications
return self.response_class(request = self.request, template = template, context = context, using = self.template_engine, **response_kwargs)