Commit b6628c9d6b9b7dd68eb8961c601b8f22b639da98
Exists in
master
and in
5 other branches
conflit
Showing
24 changed files
with
214 additions
and
123 deletions
Show diff stats
app/views.py
... | ... | @@ -4,17 +4,14 @@ from django.views import View |
4 | 4 | from rolepermissions.mixins import HasRoleMixin |
5 | 5 | from django.contrib.auth.mixins import LoginRequiredMixin |
6 | 6 | from django.core.urlresolvers import reverse_lazy |
7 | -from core.mixins import LogMixin, NotificationMixin | |
7 | +from core.mixins import NotificationMixin | |
8 | 8 | from core.models import Notification, Action, Resource, Action_Resource |
9 | 9 | from users.models import User |
10 | 10 | from .models import EmailBackend |
11 | 11 | from .forms import EmailBackendForm |
12 | 12 | from courses.models import Course |
13 | 13 | |
14 | -class AppIndex(LoginRequiredMixin, LogMixin, ListView, NotificationMixin): | |
15 | - log_action = "Acessar" | |
16 | - log_resource = "Home" | |
17 | - | |
14 | +class AppIndex(LoginRequiredMixin, ListView, NotificationMixin): | |
18 | 15 | login_url = reverse_lazy("core:home") |
19 | 16 | redirect_field_name = 'next' |
20 | 17 | |
... | ... | @@ -46,7 +43,7 @@ class AppIndex(LoginRequiredMixin, LogMixin, ListView, NotificationMixin): |
46 | 43 | |
47 | 44 | return self.response_class(request = self.request, template = self.template_name, context = context, using = self.template_engine, **response_kwargs) |
48 | 45 | |
49 | -class AmadeusSettings(LoginRequiredMixin, HasRoleMixin, View): | |
46 | +class AmadeusSettings(LoginRequiredMixin, HasRoleMixin, View): | |
50 | 47 | allowed_roles = ['system_admin'] |
51 | 48 | login_url = reverse_lazy("core:home") |
52 | 49 | redirect_field_name = 'next' | ... | ... |
core/decorators.py
1 | 1 | from django.conf import settings |
2 | +import json | |
2 | 3 | from functools import wraps |
3 | 4 | from .models import Action, Resource, Action_Resource, Log, Notification |
4 | 5 | |
5 | -def log_decorator(log_action = '', log_resource = ''): | |
6 | +def log_decorator(log_component = '', log_action = '', log_resource = ''): | |
6 | 7 | |
7 | 8 | def _log_decorator(view_function): |
8 | 9 | |
... | ... | @@ -10,7 +11,7 @@ def log_decorator(log_action = '', log_resource = ''): |
10 | 11 | |
11 | 12 | response = view_function(request, *args, **kwargs) |
12 | 13 | |
13 | - if request.user.is_authenticated and request.POST: | |
14 | + if request.user.is_authenticated: | |
14 | 15 | action = Action.objects.filter(name = log_action) |
15 | 16 | resource = Resource.objects.filter(name = log_resource) |
16 | 17 | |
... | ... | @@ -36,6 +37,8 @@ def log_decorator(log_action = '', log_resource = ''): |
36 | 37 | |
37 | 38 | log = Log() |
38 | 39 | log.user = request.user |
40 | + log.component = log_component | |
41 | + log.context = json.dumps(request.log_context) | |
39 | 42 | log.action_resource = action_resource |
40 | 43 | |
41 | 44 | log.save() | ... | ... |
core/mixins.py
1 | 1 | from django.conf import settings |
2 | +import json | |
3 | + | |
2 | 4 | from .models import Action, Resource, Action_Resource, Log, Notification |
3 | 5 | from users.models import User |
4 | 6 | |
5 | 7 | class LogMixin(object): |
8 | + log_component = "" | |
9 | + log_context = {} | |
6 | 10 | log_action = "" |
7 | 11 | log_resource = "" |
8 | 12 | |
9 | - def dispatch(self, request, *args, **kwargs): | |
10 | - action = Action.objects.filter(name = self.log_action) | |
11 | - resource = Resource.objects.filter(name = self.log_resource) | |
13 | + def createLog(self, actor = None, component = '', log_action = '', log_resource = '', context = {}): | |
14 | + action = Action.objects.filter(name = log_action) | |
15 | + resource = Resource.objects.filter(name = log_resource) | |
12 | 16 | |
13 | 17 | if not action: |
14 | - action = Action(name = self.log_action) | |
18 | + action = Action(name = log_action) | |
15 | 19 | action.save() |
16 | 20 | else: |
17 | 21 | action = action[0] |
18 | 22 | |
19 | 23 | if not resource: |
20 | - resource = Resource(name = self.log_resource) | |
24 | + resource = Resource(name = log_resource) | |
21 | 25 | resource.save() |
22 | 26 | else: |
23 | 27 | resource = resource[0] |
... | ... | @@ -30,12 +34,18 @@ class LogMixin(object): |
30 | 34 | else: |
31 | 35 | action_resource = action_resource[0] |
32 | 36 | |
37 | + print(context) | |
38 | + print(json.dumps(context)) | |
39 | + | |
33 | 40 | log = Log() |
34 | - log.user = request.user | |
41 | + log.user = actor | |
42 | + log.context = json.dumps(context) | |
43 | + log.component = component | |
35 | 44 | log.action_resource = action_resource |
36 | 45 | |
37 | 46 | log.save() |
38 | 47 | |
48 | + def dispatch(self, request, *args, **kwargs): | |
39 | 49 | return super(LogMixin, self).dispatch(request, *args, **kwargs) |
40 | 50 | |
41 | 51 | class NotificationMixin(object): | ... | ... |
core/models.py
core/static/css/base/amadeus.css
... | ... | @@ -420,6 +420,14 @@ ul, li { |
420 | 420 | .course, .subject, .topic{ padding-top: 0px; padding-bottom: 0px; } |
421 | 421 | .course-detail{padding-top: 10px; padding-bottom: 10px;} |
422 | 422 | |
423 | +.course-card{ | |
424 | + margin-bottom: 0.4% !important; | |
425 | +} | |
426 | + | |
427 | +.course-card-group{ | |
428 | + margin-bottom: 1%; | |
429 | +} | |
430 | + | |
423 | 431 | .category-course-link{ |
424 | 432 | font-size: 24px; |
425 | 433 | color: black !important; | ... | ... |
core/templates/base.html
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | |
21 | 21 | <!-- Bootstrap and themes (material) --> |
22 | 22 | <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7/css/bootstrap.css' %}"> |
23 | - | |
23 | + | |
24 | 24 | <link rel="stylesheet" type="text/css" href="{% static 'material/css/bootstrap-material-design.min.css' %}"> |
25 | 25 | <link rel="stylesheet" type="text/css" href="{% static 'material/css/ripples.css' %}"> |
26 | 26 | <link rel="stylesheet" type="text/css" href="{% static 'material/css/ripples.min.css' %}"> |
... | ... | @@ -79,7 +79,7 @@ |
79 | 79 | <input type="text" class="form-control" placeholder="{% trans 'Search Files (.pdf, others) and/or activities' %}" name="search"></div> |
80 | 80 | <span class="input-group-btn input-group-sm"> |
81 | 81 | <button type="submit" class="btn btn-fab btn-fab-mini"> |
82 | - <i class="fa fa-search" aria-hidden="true"></i> | |
82 | + <i class="glyphicon glyphicon-search" aria-hidden="true" style="color:#93C741"></i> | |
83 | 83 | </button> |
84 | 84 | </span> |
85 | 85 | </div> | ... | ... |
core/templates/guest.html
... | ... | @@ -107,6 +107,7 @@ |
107 | 107 | </div> |
108 | 108 | <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10"> |
109 | 109 | {% block breadcrumbs %} |
110 | + | |
110 | 111 | <div class="col-md-12"> |
111 | 112 | <form id="searchform" action="{% url 'course:manage' %}" method="get" accept-charset="utf-8"> |
112 | 113 | <div class="input-group"> |
... | ... | @@ -121,46 +122,34 @@ |
121 | 122 | </form> |
122 | 123 | </div> |
123 | 124 | |
124 | - <div class="col-md-10"> | |
125 | - <div class="btn-group btn-group-justified btn-group-raised"> | |
126 | - <a href="?category=all" class="btn btn-raised btn-info">{% trans 'All' %}</a> | |
127 | - {% for category in categories %} | |
128 | - <a href="?category={{category.name}}" class="btn btn-raised btn-primary">{{category.name}}</a> | |
129 | - {% endfor %} | |
130 | - </div> | |
131 | - </div> | |
132 | - | |
133 | 125 | {% endblock %} |
134 | 126 | {% block render_breadcrumbs %}{% endblock %} |
135 | 127 | <div> |
136 | 128 | </div> |
137 | 129 | <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10 col-xl-12"> |
138 | 130 | {% block content %} |
139 | - {% for course in courses %} | |
140 | - <div class="panel panel-info panel_{{ course.id }}"> | |
141 | - <div class="panel-heading"> | |
142 | - <a href="{{ course.get_absolute_url }}" class="panel-title">{{course.name}}</a> | |
143 | - {% if user|show_course_subscribe:course %} | |
144 | - <a onclick="subscribe($(this), '{% url 'course:subscribe' course.slug %}', {{ course.id}}, '{% trans 'Are you sure you want to subscribe to this course?' %}')" class="btn btn-sm btn-primary btn-raised pull-right" style="margin-top:-4px">{% trans 'Subscribe' %}</a> | |
145 | - {% endif %} | |
146 | - </div> | |
147 | - | |
148 | - <div class="panel-body"> | |
149 | - <p><b>{% trans 'Course Name' %}: </b>{{course.name}}</p> | |
150 | - <p><b>{% trans 'Begining' %}: </b>{{course.init_date}}</p> | |
151 | - <p><b>{% trans 'End' %}: </b>{{course.end_date}}</p> | |
152 | - <p><b>{% trans 'Professor' %}: </b>{{course.professors.name}}</p> | |
153 | - <p> | |
154 | - <b>{% trans 'Description' %}:</b> | |
155 | - <i> | |
156 | - {{course.content}} | |
157 | - </i> | |
158 | - </p> | |
159 | - </div> | |
160 | - </div> | |
161 | - {% endfor %} | |
162 | 131 | |
163 | - {% pagination request paginator page_obj %} | |
132 | + <div class="col-md-12 cards-content"> | |
133 | + {% for category in categorys_courses %} | |
134 | + <div class="panel-group"> | |
135 | + <div class="panel panel-default"> | |
136 | + <div class="panel-heading"> | |
137 | + <h4 class="panel-title"> | |
138 | + <a class="category-course-link" data-toggle="collapse" href="#{{category.slug}}">{{category.name}}</a> | |
139 | + </h4> | |
140 | + | |
141 | + </div> | |
142 | + <div id="{{category.slug}}" class="panel-collapse collapse"> | |
143 | + {% for course in category.course_category.all %} | |
144 | + {%if course.public == True %} | |
145 | + {% include "course/course_card.html" %} | |
146 | + {% endif %} | |
147 | + {% endfor %} | |
148 | + </div> | |
149 | + </div> | |
150 | + </div> | |
151 | + {% endfor %} | |
152 | + </div> | |
164 | 153 | {% endblock %} |
165 | 154 | </div> |
166 | 155 | </div> | ... | ... |
core/views.py
... | ... | @@ -68,7 +68,6 @@ def remember_password(request): |
68 | 68 | context['danger'] = 'E-mail does not send' |
69 | 69 | return render(request, "remember_password.html",context) |
70 | 70 | |
71 | -@log_decorator('Acessar', 'Sistema') | |
72 | 71 | def login(request): |
73 | 72 | context = {} |
74 | 73 | |
... | ... | @@ -87,17 +86,12 @@ def login(request): |
87 | 86 | |
88 | 87 | return render(request,"index.html",context) |
89 | 88 | |
90 | - | |
91 | - | |
92 | 89 | def processNotification(self, notificationId): |
93 | 90 | notification = Notification.objects.get(id= notificationId) |
94 | 91 | notification.read = True |
95 | 92 | notification.save() |
96 | 93 | return redirect(notification.action_resource.resource.url) |
97 | 94 | |
98 | - | |
99 | - | |
100 | - | |
101 | 95 | def getNotifications(request): |
102 | 96 | context = {} |
103 | 97 | if request.user.is_authenticated: |
... | ... | @@ -133,5 +127,5 @@ class GuestView (ListView): |
133 | 127 | |
134 | 128 | def get_context_data (self, **kwargs): |
135 | 129 | context = super(GuestView, self).get_context_data(**kwargs) |
136 | - context['categories'] = CourseCategory.objects.all() | |
137 | - return context | |
130 | + context['categorys_courses'] = CourseCategory.objects.all() | |
131 | + return context | |
138 | 132 | \ No newline at end of file | ... | ... |
courses/forms.py
... | ... | @@ -19,24 +19,24 @@ class CategoryCourseForm(forms.ModelForm): |
19 | 19 | |
20 | 20 | class CourseForm(forms.ModelForm): |
21 | 21 | def clean_end_register_date(self): |
22 | - init_register_date = self.data['init_register_date'] | |
23 | - end_register_date = self.data['end_register_date'] | |
22 | + init_register_date = self.cleaned_data['init_register_date'] | |
23 | + end_register_date = self.cleaned_data['end_register_date'] | |
24 | 24 | |
25 | 25 | if init_register_date and end_register_date and end_register_date < init_register_date: |
26 | 26 | raise forms.ValidationError(_('The end date may not be before the start date.')) |
27 | 27 | return end_register_date |
28 | 28 | |
29 | 29 | def clean_init_date(self): |
30 | - end_register_date = self.data['end_register_date'] | |
31 | - init_date = self.data['init_date'] | |
30 | + end_register_date = self.cleaned_data['end_register_date'] | |
31 | + init_date = self.cleaned_data['init_date'] | |
32 | 32 | |
33 | 33 | if end_register_date and init_date and init_date <= end_register_date: |
34 | 34 | raise forms.ValidationError(_('The course start date must be after the end of registration.')) |
35 | 35 | return init_date |
36 | 36 | |
37 | 37 | def clean_end_date(self): |
38 | - init_date = self.data['init_date'] | |
39 | - end_date = self.data['end_date'] | |
38 | + init_date = self.cleaned_data['init_date'] | |
39 | + end_date = self.cleaned_data['end_date'] | |
40 | 40 | |
41 | 41 | if init_date and end_date and end_date < init_date: |
42 | 42 | raise forms.ValidationError(_('The end date may not be before the start date.')) | ... | ... |
courses/templates/course/create.html
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <div class="form-group {% if form.has_error %} has-error {% endif %} is-fileinput"> |
20 | 20 | <label for="{{ field.auto_id }}">{{ field.label }}</label> |
21 | 21 | {% if field.auto_id == 'id_init_register_date' or field.auto_id == 'id_end_register_date' or field.auto_id == 'id_init_date' or field.auto_id == 'id_end_date'%} |
22 | - <input type="text" class="form-control date-picker" name="{{field.name}}" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'Y-m-d'}}"> | |
22 | + <input type="text" class="form-control date-picker" name="{{field.name}}" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
23 | 23 | {% elif field.auto_id == 'id_image' %} |
24 | 24 | {% render_field field class='form-control' %} |
25 | 25 | <div class="input-group"> | ... | ... |
courses/templates/course/index.html
... | ... | @@ -110,17 +110,20 @@ |
110 | 110 | </fieldset> |
111 | 111 | <div class="col-md-12 cards-content"> |
112 | 112 | {% for category in categorys_courses %} |
113 | - <div class="panel-group"> | |
113 | + <div class="panel-group course-card-group"> | |
114 | 114 | <div class="panel panel-default"> |
115 | 115 | <div class="panel-heading"> |
116 | - <h4 class="panel-title"> | |
117 | - <a class="category-course-link" data-toggle="collapse" href="#{{category.slug}}">{{category.name}}</a> | |
118 | - </h4> | |
119 | - | |
116 | + <div class="row"> | |
117 | + <div class="col-md-12"> | |
118 | + <h4 class="panel-title"> | |
119 | + <a class="category-course-link" data-toggle="collapse" href="#{{category.slug}}">{{category.name}}</a> | |
120 | + </h4> | |
121 | + </div> | |
122 | + </div> | |
120 | 123 | </div> |
121 | 124 | <div id="{{category.slug}}" class="panel-collapse collapse"> |
122 | 125 | {% for course in category.course_category.all %} |
123 | - {% if user in course.students.all %} | |
126 | + {% if user in course.students.all or user in course.professors.all or user|has_role:'system_admin' %} | |
124 | 127 | {% include "course/course_card.html" %} |
125 | 128 | {% endif %} |
126 | 129 | {% endfor %} |
... | ... | @@ -130,20 +133,6 @@ |
130 | 133 | |
131 | 134 | |
132 | 135 | {% endfor %} |
133 | - <!--{% if courses|length > 0 %} | |
134 | - {% if request.GET.category == '' or aparece or request.GET.q == '' %} | |
135 | - {% for course in list_courses %} | |
136 | - {% include "course/course_card.html" %} | |
137 | - {% endfor %} | |
138 | - {% endif %} | |
139 | - {% if request.GET.category or request.GET.q %} | |
140 | - {% for course in courses %} | |
141 | - {% include "course/course_card.html" %} | |
142 | - {% endfor %} | |
143 | - {% endif %} | |
144 | - {% else %} | |
145 | - {% trans 'No courses found' %} | |
146 | - {% endif %}--> | |
147 | 136 | </div> |
148 | 137 | {% if user|has_role:'professor' or user|has_role:'system_admin' %} |
149 | 138 | <a href="{% url 'course:create' %}" class="btn btn-primary btn-fab float-button"><i class="fa fa-plus material-icons"></i></a> | ... | ... |
courses/templates/course/replicate.html
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | <label for="id_init_register_date">{% trans 'Course registration start date' %}</label> |
58 | 58 | |
59 | 59 | |
60 | - <input type="date" class="form-control" name="init_register_date" value="None" min="2016-10-24"> | |
60 | + <input type="text" class="form-control date-picker" name="init_register_date" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
61 | 61 | |
62 | 62 | <span class="help-block">{% trans 'Date that starts the registration period of the course (dd/mm/yyyy)' %}</span> |
63 | 63 | |
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | <label for="id_end_register_date">{% trans 'Course registration end date' %}</label> |
68 | 68 | |
69 | 69 | |
70 | - <input type="date" class="form-control" name="end_register_date" value="None" min="2016-10-24"> | |
70 | + <input type="text" class="form-control date-picker" name="end_register_date" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
71 | 71 | |
72 | 72 | <span class="help-block">{% trans 'Date that ends the registration period of the course (dd/mm/yyyy)' %}</span> |
73 | 73 | |
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | <label for="id_init_date">{% trans 'Course start date' %}</label> |
78 | 78 | |
79 | 79 | |
80 | - <input type="date" class="form-control" name="init_date" value="None" min="2016-10-24"> | |
80 | + <input type="text" class="form-control date-picker" name="init_date" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
81 | 81 | |
82 | 82 | <span class="help-block">{% trans 'Date that the course starts (dd/mm/yyyy)' %}</span> |
83 | 83 | |
... | ... | @@ -87,7 +87,7 @@ |
87 | 87 | <label for="id_end_date">{% trans 'Course end date' %}</label> |
88 | 88 | |
89 | 89 | |
90 | - <input type="date" class="form-control" name="end_date" value="None" min="2016-10-24"> | |
90 | + <input type="text" class="form-control date-picker" name="end_date" value="{{field.value|date:'SHORT_DATE_FORMAT'}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
91 | 91 | |
92 | 92 | <span class="help-block">{% trans 'Date that the course ends (dd/mm/yyyy)' %}</span> |
93 | 93 | ... | ... |
courses/views.py
... | ... | @@ -15,7 +15,8 @@ from rolepermissions.verifications import has_object_permission |
15 | 15 | from django.http import HttpResponseRedirect, JsonResponse |
16 | 16 | from .forms import CourseForm, UpdateCourseForm, CategoryCourseForm, SubjectForm,TopicForm,ActivityForm |
17 | 17 | from .models import Course, Subject, CourseCategory,Topic, SubjectCategory,Activity, CategorySubject |
18 | -from core.mixins import NotificationMixin | |
18 | +from core.decorators import log_decorator | |
19 | +from core.mixins import LogMixin, NotificationMixin | |
19 | 20 | from users.models import User |
20 | 21 | from files.forms import FileForm |
21 | 22 | from files.models import TopicFile |
... | ... | @@ -141,7 +142,11 @@ class AllCoursesView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
141 | 142 | |
142 | 143 | return context |
143 | 144 | |
144 | -class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): | |
145 | +class CreateCourseView(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin, generic.edit.CreateView): | |
146 | + log_component = "course" | |
147 | + log_resource = "course" | |
148 | + log_action = "create" | |
149 | + log_context = {} | |
145 | 150 | |
146 | 151 | allowed_roles = ['professor', 'system_admin'] |
147 | 152 | login_url = reverse_lazy("core:home") |
... | ... | @@ -153,6 +158,15 @@ class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,gener |
153 | 158 | def form_valid(self, form): |
154 | 159 | self.object = form.save() |
155 | 160 | self.object.professors.add(self.request.user) |
161 | + | |
162 | + self.log_context['course_id'] = self.object.id | |
163 | + self.log_context['course_name'] = self.object.name | |
164 | + self.log_context['course_slug'] = self.object.slug | |
165 | + self.log_context['course_category_id'] = self.object.category.id | |
166 | + self.log_context['course_category_name'] = self.object.category.name | |
167 | + | |
168 | + super(CreateCourseView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
169 | + | |
156 | 170 | return super(CreateCourseView, self).form_valid(form) |
157 | 171 | |
158 | 172 | def get_context_data(self, **kwargs): |
... | ... | @@ -166,7 +180,11 @@ class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,gener |
166 | 180 | context['now'] = date.today() |
167 | 181 | return context |
168 | 182 | |
169 | -class ReplicateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): | |
183 | +class ReplicateCourseView(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin,generic.edit.CreateView): | |
184 | + log_component = "courses" | |
185 | + log_action = "replicate" | |
186 | + log_resource = "course" | |
187 | + log_context = {} | |
170 | 188 | |
171 | 189 | allowed_roles = ['professor', 'system_admin'] |
172 | 190 | login_url = reverse_lazy("core:home") |
... | ... | @@ -188,6 +206,15 @@ class ReplicateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,ge |
188 | 206 | elif has_role(self.request.user,'professor'): |
189 | 207 | courses = self.request.user.courses_professors.all() |
190 | 208 | categorys_courses = CourseCategory.objects.all() |
209 | + | |
210 | + self.log_context['course_id'] = course.id | |
211 | + self.log_context['course_name'] = course.name | |
212 | + self.log_context['course_slug'] = course.slug | |
213 | + self.log_context['course_category_id'] = course.category.id | |
214 | + self.log_context['course_category_name'] = course.category.name | |
215 | + | |
216 | + super(ReplicateCourseView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
217 | + | |
191 | 218 | context['courses'] = courses |
192 | 219 | context['course'] = course |
193 | 220 | context['categorys_courses'] = categorys_courses |
... | ... | @@ -198,7 +225,11 @@ class ReplicateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,ge |
198 | 225 | def get_success_url(self): |
199 | 226 | return reverse_lazy('course:view', kwargs={'slug' : self.object.slug}) |
200 | 227 | |
201 | -class UpdateCourseView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): | |
228 | +class UpdateCourseView(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.UpdateView): | |
229 | + log_component = "courses" | |
230 | + log_action = "update" | |
231 | + log_resource = "course" | |
232 | + log_context = {} | |
202 | 233 | |
203 | 234 | allowed_roles = ['professor', 'system_admin'] |
204 | 235 | login_url = reverse_lazy("core:home") |
... | ... | @@ -213,6 +244,19 @@ class UpdateCourseView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): |
213 | 244 | return self.handle_no_permission() |
214 | 245 | return super(UpdateCourseView, self).dispatch(*args, **kwargs) |
215 | 246 | |
247 | + def form_valid(self, form): | |
248 | + self.object = form.save() | |
249 | + | |
250 | + self.log_context['course_id'] = self.object.id | |
251 | + self.log_context['course_name'] = self.object.name | |
252 | + self.log_context['course_slug'] = self.object.slug | |
253 | + self.log_context['course_category_id'] = self.object.category.id | |
254 | + self.log_context['course_category_name'] = self.object.category.name | |
255 | + | |
256 | + super(UpdateCourseView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
257 | + | |
258 | + return super(UpdateCourseView, self).form_valid(form) | |
259 | + | |
216 | 260 | def get_context_data(self, **kwargs): |
217 | 261 | context = super(UpdateCourseView, self).get_context_data(**kwargs) |
218 | 262 | course = get_object_or_404(Course, slug = self.kwargs.get('slug')) |
... | ... | @@ -229,7 +273,11 @@ class UpdateCourseView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): |
229 | 273 | def get_success_url(self): |
230 | 274 | return reverse_lazy('course:view', kwargs={'slug' : self.object.slug}) |
231 | 275 | |
232 | -class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): | |
276 | +class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DeleteView): | |
277 | + log_component = "courses" | |
278 | + log_action = "delete" | |
279 | + log_resource = "course" | |
280 | + log_context = {} | |
233 | 281 | |
234 | 282 | allowed_roles = ['professor', 'student'] |
235 | 283 | login_url = reverse_lazy("core:home") |
... | ... | @@ -242,6 +290,15 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
242 | 290 | course = get_object_or_404(Course, slug = self.kwargs.get('slug')) |
243 | 291 | if(not has_object_permission('delete_course', self.request.user, course)): |
244 | 292 | return self.handle_no_permission() |
293 | + | |
294 | + self.log_context['course_id'] = course.id | |
295 | + self.log_context['course_name'] = course.name | |
296 | + self.log_context['course_slug'] = course.slug | |
297 | + self.log_context['course_category_id'] = course.category.id | |
298 | + self.log_context['course_category_name'] = course.category.name | |
299 | + | |
300 | + super(DeleteCourseView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
301 | + | |
245 | 302 | return super(DeleteCourseView, self).dispatch(*args, **kwargs) |
246 | 303 | |
247 | 304 | def get_context_data(self, **kwargs): |
... | ... | @@ -258,7 +315,11 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
258 | 315 | return context |
259 | 316 | |
260 | 317 | |
261 | -class CourseView(NotificationMixin, generic.DetailView): | |
318 | +class CourseView(LogMixin, NotificationMixin, generic.DetailView): | |
319 | + log_component = "courses" | |
320 | + log_action = "viewed" | |
321 | + log_resource = "course" | |
322 | + log_context = {} | |
262 | 323 | |
263 | 324 | login_url = reverse_lazy("core:home") |
264 | 325 | redirect_field_name = 'next' |
... | ... | @@ -272,6 +333,14 @@ class CourseView(NotificationMixin, generic.DetailView): |
272 | 333 | context = super(CourseView, self).get_context_data(**kwargs) |
273 | 334 | course = get_object_or_404(Course, slug = self.kwargs.get('slug')) |
274 | 335 | |
336 | + self.log_context['course_id'] = course.id | |
337 | + self.log_context['course_name'] = course.name | |
338 | + self.log_context['course_slug'] = course.slug | |
339 | + self.log_context['course_category_id'] = course.category.id | |
340 | + self.log_context['course_category_name'] = course.category.name | |
341 | + | |
342 | + super(CourseView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
343 | + | |
275 | 344 | category_sub = self.kwargs.get('category', None) |
276 | 345 | |
277 | 346 | if has_role(self.request.user,'system_admin'): |
... | ... | @@ -329,12 +398,23 @@ class DeleteView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, generic.De |
329 | 398 | return self.response_class(request=self.request, template=self.get_template_names(), context=context, using=self.template_engine) |
330 | 399 | |
331 | 400 | @login_required |
401 | +@log_decorator("course", "subscribe", "course") | |
332 | 402 | def subscribe_course(request, slug): |
333 | 403 | course = get_object_or_404(Course, slug = slug) |
334 | 404 | |
335 | 405 | course.students.add(request.user) |
336 | 406 | |
337 | 407 | if request.user in course.students.all(): |
408 | + | |
409 | + log_context = {} | |
410 | + log_context['course_id'] = course.id | |
411 | + log_context['course_name'] = course.name | |
412 | + log_context['course_slug'] = course.slug | |
413 | + log_context['course_category_id'] = course.category.id | |
414 | + log_context['course_category_name'] = course.category.name | |
415 | + | |
416 | + request.log_context = log_context | |
417 | + | |
338 | 418 | return JsonResponse({"status": "ok", "message": _("Successfully subscribed to the course!")}) |
339 | 419 | else: |
340 | 420 | return JsonResponse({"status": "erro", "message": _("An error has occured. Could not subscribe to this course, try again later")}) |
... | ... | @@ -436,7 +516,11 @@ class DeleteCatView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
436 | 516 | messages.success(self.request, _('Category deleted successfully!')) |
437 | 517 | return reverse_lazy('course:manage_cat') |
438 | 518 | |
439 | -class SubjectsView(LoginRequiredMixin, generic.ListView): | |
519 | +class SubjectsView(LoginRequiredMixin, LogMixin, generic.ListView): | |
520 | + log_component = "course" | |
521 | + log_resource = "subject" | |
522 | + log_action = "viewed" | |
523 | + log_context = {} | |
440 | 524 | |
441 | 525 | login_url = reverse_lazy("core:home") |
442 | 526 | redirect_field_name = 'next' |
... | ... | @@ -450,6 +534,17 @@ class SubjectsView(LoginRequiredMixin, generic.ListView): |
450 | 534 | if(not has_object_permission('view_subject', self.request.user, subject)): |
451 | 535 | return self.handle_no_permission() |
452 | 536 | |
537 | + self.log_context['subject_id'] = subject.id | |
538 | + self.log_context['subject_name'] = subject.name | |
539 | + self.log_context['subject_slug'] = subject.slug | |
540 | + self.log_context['course_id'] = subject.course.id | |
541 | + self.log_context['course_name'] = subject.course.name | |
542 | + self.log_context['course_slug'] = subject.course.slug | |
543 | + self.log_context['course_category_id'] = subject.course.category.id | |
544 | + self.log_context['course_category_name'] = subject.course.category.name | |
545 | + | |
546 | + super(SubjectsView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
547 | + | |
453 | 548 | return super(SubjectsView, self).dispatch(*args, **kwargs) |
454 | 549 | |
455 | 550 | def get_queryset(self): |
... | ... | @@ -594,7 +689,11 @@ class UpdateTopicView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): |
594 | 689 | context['subjects'] = topic.subject.course.subjects.all() |
595 | 690 | return context |
596 | 691 | |
597 | -class CreateSubjectView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, generic.edit.CreateView): | |
692 | +class CreateSubjectView(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin, generic.edit.CreateView): | |
693 | + log_component = "course" | |
694 | + log_resource = "subject" | |
695 | + log_action = "create" | |
696 | + log_context = {} | |
598 | 697 | |
599 | 698 | allowed_roles = ['professor', 'system_admin'] |
600 | 699 | login_url = reverse_lazy("core:home") |
... | ... | @@ -626,6 +725,17 @@ class CreateSubjectView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, gen |
626 | 725 | resource_slug = self.object.slug, actor=self.request.user, users= self.object.course.students.all(), |
627 | 726 | resource_link = reverse('course:view_subject', args=[self.object.slug])) |
628 | 727 | |
728 | + self.log_context['subject_id'] = self.object.id | |
729 | + self.log_context['subject_name'] = self.object.name | |
730 | + self.log_context['subject_slug'] = self.object.slug | |
731 | + self.log_context['course_id'] = course.id | |
732 | + self.log_context['course_name'] = course.name | |
733 | + self.log_context['course_slug'] = course.slug | |
734 | + self.log_context['course_category_id'] = course.category.id | |
735 | + self.log_context['course_category_name'] = course.category.name | |
736 | + | |
737 | + super(CreateSubjectView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
738 | + | |
629 | 739 | return super(CreateSubjectView, self).form_valid(form) |
630 | 740 | |
631 | 741 | ... | ... |
files/templates/files/create_file.html
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | <span id="helpBlock" class="help-block">{{ field.help_text }}</span> |
48 | 48 | {% endif %} |
49 | 49 | </div> |
50 | - | |
50 | + | |
51 | 51 | {% if field.errors %} |
52 | 52 | <div class="alert alert-danger alert-dismissible clearfix" role="alert"> |
53 | 53 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
... | ... | @@ -71,7 +71,7 @@ |
71 | 71 | |
72 | 72 | <div class="form-group"> |
73 | 73 | <div class="col-md-12"> |
74 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
74 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
75 | 75 | <button class="btn btn-raised btn-primary" type="submit">{% trans 'Submit' %}</button> |
76 | 76 | </div> |
77 | 77 | </div> |
... | ... | @@ -85,7 +85,7 @@ |
85 | 85 | </div> |
86 | 86 | |
87 | 87 | {% block script_file %} |
88 | - | |
88 | + | |
89 | 89 | {# // <script src="{% static 'js/file.js' %}"></script> #} |
90 | 90 | <script type="text/javascript"> |
91 | 91 | $("#form-file").submit(function(event) { | ... | ... |
files/templates/files/delete_file.html
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | </div> |
32 | 32 | <div class="form-group"> |
33 | 33 | <div class="col-md-12"> |
34 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
34 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
35 | 35 | <button class="btn btn-raised btn-primary" type="submit">{% trans 'Delete' %}</button> |
36 | 36 | </div> |
37 | 37 | </div> |
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | </div> |
46 | 46 | |
47 | 47 | {% block script_file %} |
48 | - | |
48 | + | |
49 | 49 | {# // <script src="{% static 'js/file.js' %}"></script> #} |
50 | 50 | <script type="text/javascript"> |
51 | 51 | $("#form-delete-file").submit(function(event) { | ... | ... |
files/templates/files/update_file.html
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | <span id="helpBlock" class="help-block">{{ field.help_text }}</span> |
53 | 53 | {% endif %} |
54 | 54 | </div> |
55 | - | |
55 | + | |
56 | 56 | {% if field.errors %} |
57 | 57 | <div class="alert alert-danger alert-dismissible clearfix" role="alert"> |
58 | 58 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
... | ... | @@ -76,7 +76,7 @@ |
76 | 76 | |
77 | 77 | <div class="form-group"> |
78 | 78 | <div class="col-md-12"> |
79 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
79 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
80 | 80 | <button class="btn btn-raised btn-primary" type="submit">{% trans 'Submit' %}</button> |
81 | 81 | </div> |
82 | 82 | </div> |
... | ... | @@ -90,7 +90,7 @@ |
90 | 90 | </div> |
91 | 91 | |
92 | 92 | {% block script_file %} |
93 | - | |
93 | + | |
94 | 94 | {# // <script src="{% static 'js/file.js' %}"></script> #} |
95 | 95 | <script type="text/javascript"> |
96 | 96 | $("#form-update-file").submit(function(event) { | ... | ... |
forum/templates/forum/forum_view.html
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | {% else %} |
18 | 18 | <li class="active">{{ forum.name }}</li> |
19 | 19 | {% endif %} |
20 | - | |
20 | + | |
21 | 21 | </ol> |
22 | 22 | {% endblock %} |
23 | 23 | |
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | </ul> |
34 | 34 | </div> |
35 | 35 | </div> |
36 | - | |
36 | + | |
37 | 37 | {% if request.user|has_role:'system_admin' or request.user|has_role:'professor' and request.user in forum.topic.subject.professors.all %} |
38 | 38 | <div class="panel panel-primary navigation"> |
39 | 39 | <div class="panel-heading"> |
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | </section> |
122 | 122 | </div> |
123 | 123 | <div class="modal-footer"> |
124 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans 'Close' %}</button> | |
124 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans 'Close' %}</button> | |
125 | 125 | <button type="button" onclick="$('#forum_create').submit();" class="btn btn-primary btn-raised">{% trans 'Update' %}</button> |
126 | 126 | </div> |
127 | 127 | </div> | ... | ... |
links/static/links.js
links/templates/links/create_link.html
1 | 1 | {% load widget_tweaks i18n %} |
2 | - | |
3 | 2 | <!--MODAL CREATE LINK--> |
4 | 3 | <div class="modal fade" id="createLinksModal" tabindex="-1" role="dialog" aria-labelledby="createLink"> |
5 | 4 | <div class="modal-dialog" role="document"> |
... | ... | @@ -33,7 +32,7 @@ |
33 | 32 | </div> |
34 | 33 | {% endfor %} |
35 | 34 | <div class="form-group"> |
36 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Cancel" %}</button> | |
35 | + <button type="button" class="btn btn-raised btn-default " data-dismiss="modal">{% trans "Cancel" %}</button> | |
37 | 36 | <button class="btn btn-raised btn-primary" type="submit">{% trans 'Submit' %}</button> |
38 | 37 | </div> |
39 | 38 | <!-- .end Card --> | ... | ... |
links/templates/links/delete_link.html
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | </div> |
22 | 22 | <div class="form-group"> |
23 | 23 | <div class="col-md-12"> |
24 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
24 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
25 | 25 | <button class="btn btn-raised btn-primary" type="submit">{% trans 'Delete' %}</button> |
26 | 26 | </div> |
27 | 27 | </div> | ... | ... |
links/templates/links/update_link.html
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | {% endif %} |
37 | 37 | {% endfor %} |
38 | 38 | <div class="form-group"> |
39 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Cancel" %}</button> | |
39 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Cancel" %}</button> | |
40 | 40 | <button class="btn btn-raised btn-primary" type="submit">{% trans 'Submit' %}</button> |
41 | 41 | </div> |
42 | 42 | <!-- .end Card --> | ... | ... |
links/templates/links/view_link.html
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | <div class="card-block"> |
15 | 15 | <b class="card-title">{{link.name}}</b><p></p> |
16 | 16 | <p class="card-text"> </p><p>{{link.link_description}}</p> |
17 | - <a href="{{ link.link_url }}" class="btn btn-primary">{% trans 'Read more' %}</a> | |
17 | + <a href="{{ link.link_url }}" class="btn btn-raised btn-primary">{% trans 'Read more' %}</a> | |
18 | 18 | </div> |
19 | 19 | </article> |
20 | 20 | <!-- .end Card --> | ... | ... |
poll/templates/poll/create.html
... | ... | @@ -151,7 +151,7 @@ |
151 | 151 | <div class="modal-footer"> |
152 | 152 | |
153 | 153 | <!-- Don't remove that!!! --> |
154 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
154 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
155 | 155 | {% block button_save %} |
156 | 156 | <!-- Put curtom buttons here!!! --> |
157 | 157 | <button type="submite" id="button" form="form" class="btn btn-primary btn-raised">{% trans "Create" %}</button> | ... | ... |
users/templates/users/create.html
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | {% else %} |
39 | 39 | <label for="{{ field.auto_id }}">{{ field.label }}</label> |
40 | 40 | {% endif %} |
41 | - <input type="text" class="form-control input-sm date-picker" name="{{field.name}}" min="{{now|date:'d-m-Y'}}"> | |
41 | + <input type="text" class="form-control input-sm date-picker" name="{{field.name}}" min="{{now|date:'SHORT_DATE_FORMAT'}}"> | |
42 | 42 | |
43 | 43 | {% elif field.auto_id == 'id_image' %} |
44 | 44 | {% if field.field.required %} | ... | ... |