Commit f0701a3ae5ebdd21696e7d15296217d08dfed970
Committed by
GitHub
Exists in
amadeus_univasf
Merge pull request #582 from amadeusproject/refactoring
Daily Update - 09_10_2017
Showing
5 changed files
with
85 additions
and
56 deletions
Show diff stats
amadeus/static/css/base/amadeus_responsive.css
amadeus/templates/base.html
... | ... | @@ -363,7 +363,7 @@ |
363 | 363 | </a> |
364 | 364 | </li> |
365 | 365 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Analytics" %}"> |
366 | - <a href="{% url 'dashboards:view_general' %}"><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | |
366 | + <a href=""><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | |
367 | 367 | </li> |
368 | 368 | </ul> |
369 | 369 | {% endblock %} |
... | ... | @@ -424,42 +424,9 @@ |
424 | 424 | </li> |
425 | 425 | |
426 | 426 | <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Analytics" %}"> |
427 | - <a href="{% url 'dashboards:view_general' %}"><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | |
427 | + <a href=""><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | |
428 | 428 | </li> |
429 | 429 | </ul> |
430 | - <!-- | |
431 | - | |
432 | - <ul class="mobile-menu"> | |
433 | - <li class="item {{ subjects_menu_active }}" data-toggle="tooltip" data-placement="top" title="{% trans "Subjects" %}"> | |
434 | - <a href="{% url 'subjects:index' %}"> | |
435 | - <i class="fa fa-graduation-cap" aria-hidden="true"></i> | |
436 | - </a> | |
437 | - </li> | |
438 | - <li class="item {{ mural_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Mural" %}"> | |
439 | - <a href="{% url 'mural:manage_general' %}"> | |
440 | - <i class="fa fa-list" aria-hidden="true" ></i> | |
441 | - <span class="badge notify_badge mural_badge" {% if mural_notifications_count == 0 %} style="display:none" {% endif %}>{% if mural_notifications_count > 99 %} +99 {% else %} {{ mural_notifications_count }} {% endif %}</span> | |
442 | - </a> | |
443 | - </li> | |
444 | - <li class="item {{ chat_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Messages" %}"> | |
445 | - <a href="{% url 'chat:manage_general' %}"> | |
446 | - <i class="fa fa-envelope-o" aria-hidden="true"></i> | |
447 | - <span class="badge notify_badge chat_badge" {% if chat_notifications_count == 0 %} style="display:none" {% endif %}>{% if chat_notifications_count > 99 %} +99 {% else %} {{ chat_notifications_count }} {% endif %}</span> | |
448 | - </a> | |
449 | - </li> | |
450 | - <li class="item {{ pendencies_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Pendencies" %}"> | |
451 | - <a href="{% url 'notifications:manage' %}"> | |
452 | - <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | |
453 | - {% if notifications_count > 0 %} | |
454 | - <span class="badge notify_badge">{% if notifications_count > 99 %} +99 {% else %} {{ notifications_count }} {% endif %}</span> | |
455 | - {% endif %} | |
456 | - </a> | |
457 | - </li> | |
458 | - <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Analytics" %}"> | |
459 | - <a href="{% url 'dashboards:view_general' %}"><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | |
460 | - </li> | |
461 | - </ul> | |
462 | - --> | |
463 | 430 | </div> |
464 | 431 | </div> |
465 | 432 | </div> | ... | ... |
api/views.py
... | ... | @@ -23,6 +23,9 @@ from security.models import Security |
23 | 23 | from chat.serializers import ChatSerializer |
24 | 24 | from chat.models import TalkMessages, Conversation, ChatVisualizations |
25 | 25 | |
26 | +from log.models import Log | |
27 | +from log.mixins import LogMixin | |
28 | + | |
26 | 29 | from subjects.serializers import SubjectSerializer |
27 | 30 | from subjects.models import Subject |
28 | 31 | |
... | ... | @@ -83,7 +86,7 @@ def getToken(request): |
83 | 86 | |
84 | 87 | return HttpResponse(response) |
85 | 88 | |
86 | -class LoginViewset(viewsets.ReadOnlyModelViewSet): | |
89 | +class LoginViewset(viewsets.ReadOnlyModelViewSet, LogMixin): | |
87 | 90 | """ |
88 | 91 | login: |
89 | 92 | Log a user in the system |
... | ... | @@ -96,6 +99,11 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet): |
96 | 99 | serializer_class = UserSerializer |
97 | 100 | permissions_classes = (IsAuthenticated,) |
98 | 101 | |
102 | + log_component = 'mobile' | |
103 | + log_action = 'access' | |
104 | + log_resource = 'system' | |
105 | + log_context = {} | |
106 | + | |
99 | 107 | @csrf_exempt |
100 | 108 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
101 | 109 | def login(self, request): |
... | ... | @@ -121,7 +129,9 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet): |
121 | 129 | user_info['extra'] = 0 |
122 | 130 | |
123 | 131 | response = json.dumps(user_info) |
124 | - | |
132 | + | |
133 | + super(LoginViewset, self).createLog(user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
134 | + | |
125 | 135 | return HttpResponse(response) |
126 | 136 | |
127 | 137 | @csrf_exempt |
... | ... | @@ -208,7 +218,7 @@ class SubjectViewset(viewsets.ReadOnlyModelViewSet): |
208 | 218 | |
209 | 219 | return HttpResponse(response) |
210 | 220 | |
211 | -class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): | |
221 | +class ParticipantsViewset(viewsets.ReadOnlyModelViewSet, LogMixin): | |
212 | 222 | """ |
213 | 223 | get_participants: |
214 | 224 | Get all users that participates in some subject. Require the logged user email and the subject slug |
... | ... | @@ -218,17 +228,26 @@ class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): |
218 | 228 | serializer_class = UserSerializer |
219 | 229 | permissions_classes = (IsAuthenticated, ) |
220 | 230 | |
231 | + log_component = 'mobile' | |
232 | + log_action = 'view' | |
233 | + log_resource = 'subject_participants' | |
234 | + log_context = {} | |
235 | + | |
221 | 236 | @csrf_exempt |
222 | 237 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
223 | 238 | def get_participants(self, request): |
224 | 239 | username = request.data['email'] |
225 | 240 | subject_slug = request.data['subject_slug'] |
226 | 241 | |
242 | + user = User.objects.get(email = username) | |
243 | + | |
227 | 244 | participants = None |
228 | 245 | |
229 | 246 | response = "" |
230 | 247 | |
231 | 248 | if not subject_slug == "": |
249 | + subject = Subject.objects.get(slug = subject_slug) | |
250 | + | |
232 | 251 | participants = User.objects.filter(Q(is_staff = True) | Q(subject_student__slug = subject_slug) | Q(professors__slug = subject_slug) | Q(coordinators__subject_category__slug = subject_slug)).exclude(email = username).distinct() |
233 | 252 | |
234 | 253 | serializer = UserSerializer(participants, many = True, context = {"request_user": username}) |
... | ... | @@ -250,9 +269,15 @@ class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): |
250 | 269 | |
251 | 270 | response = json.dumps(info) |
252 | 271 | |
272 | + self.log_context['subject_id'] = subject.id | |
273 | + self.log_context['subject_slug'] = subject_slug | |
274 | + self.log_context['subject_name'] = subject.name | |
275 | + | |
276 | + super(ParticipantsViewset, self).createLog(user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
277 | + | |
253 | 278 | return HttpResponse(response) |
254 | 279 | |
255 | -class ChatViewset(viewsets.ModelViewSet): | |
280 | +class ChatViewset(viewsets.ModelViewSet, LogMixin): | |
256 | 281 | """ |
257 | 282 | get_messages: |
258 | 283 | Get messages of a conversation |
... | ... | @@ -265,17 +290,26 @@ class ChatViewset(viewsets.ModelViewSet): |
265 | 290 | serializer_class = ChatSerializer |
266 | 291 | permissions_classes = (IsAuthenticated, ) |
267 | 292 | |
293 | + log_component = 'mobile' | |
294 | + log_action = 'view' | |
295 | + log_resource = 'talk' | |
296 | + log_context = {} | |
297 | + | |
268 | 298 | @csrf_exempt |
269 | 299 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
270 | 300 | def get_messages(self, request): |
271 | 301 | username = request.data['email'] |
272 | 302 | user_two = request.data['user_two'] |
273 | 303 | |
304 | + user = User.objects.get(email = username) | |
305 | + | |
274 | 306 | messages = None |
275 | 307 | |
276 | 308 | response = "" |
277 | 309 | |
278 | 310 | if not user_two == "": |
311 | + user2 = User.objects.get(email = user_two) | |
312 | + | |
279 | 313 | messages = TalkMessages.objects.filter((Q(talk__user_one__email = username) & Q(talk__user_two__email = user_two)) | (Q(talk__user_one__email = user_two) & Q(talk__user_two__email = username))).order_by('-create_date') |
280 | 314 | |
281 | 315 | serializer = ChatSerializer(messages, many = True) |
... | ... | @@ -298,11 +332,27 @@ class ChatViewset(viewsets.ModelViewSet): |
298 | 332 | |
299 | 333 | response = json.dumps(info) |
300 | 334 | |
335 | + try: | |
336 | + talk = Conversation.objects.get((Q(user_one__email = username) & Q(user_two__email = user_two)) | (Q(user_two__email = username) & Q(user_one__email = user_two))) | |
337 | + self.log_context['talk_id'] = talk.id | |
338 | + except Conversation.DoesNotExist: | |
339 | + pass | |
340 | + | |
341 | + self.log_context['user_id'] = user2.id | |
342 | + self.log_context['user_name'] = str(user2) | |
343 | + self.log_context['user_email'] = user_two | |
344 | + | |
345 | + super(ChatViewset, self).createLog(user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
346 | + | |
301 | 347 | return HttpResponse(response) |
302 | 348 | |
303 | 349 | @csrf_exempt |
304 | 350 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
305 | 351 | def send_message(self, request): |
352 | + self.log_action = 'send' | |
353 | + self.log_resource = 'message' | |
354 | + self.log_context = {} | |
355 | + | |
306 | 356 | if 'file' in request.data: |
307 | 357 | file = request.FILES['file'] |
308 | 358 | |
... | ... | @@ -342,6 +392,10 @@ class ChatViewset(viewsets.ModelViewSet): |
342 | 392 | subject = Subject.objects.get(slug = subject) |
343 | 393 | space = subject.slug |
344 | 394 | space_type = "subject" |
395 | + | |
396 | + self.log_context['subject_id'] = subject.id | |
397 | + self.log_context['subject_slug'] = space | |
398 | + self.log_context['subject_name'] = subject.name | |
345 | 399 | else: |
346 | 400 | subject = None |
347 | 401 | space = 0 |
... | ... | @@ -358,6 +412,11 @@ class ChatViewset(viewsets.ModelViewSet): |
358 | 412 | |
359 | 413 | message.save() |
360 | 414 | |
415 | + self.log_context['talk_id'] = talk.id | |
416 | + self.log_context['user_id'] = user_to.id | |
417 | + self.log_context['user_name'] = str(user_to) | |
418 | + self.log_context['user_email'] = user_two | |
419 | + | |
361 | 420 | if not message.pk is None: |
362 | 421 | simple_notify = textwrap.shorten(strip_tags(message.text), width = 30, placeholder = "...") |
363 | 422 | |
... | ... | @@ -393,6 +452,8 @@ class ChatViewset(viewsets.ModelViewSet): |
393 | 452 | info["number"] = 1 |
394 | 453 | |
395 | 454 | sendChatPushNotification(user_to, message) |
455 | + | |
456 | + super(ChatViewset, self).createLog(user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
396 | 457 | else: |
397 | 458 | info["message"] = _("Error while sending message!") |
398 | 459 | info["success"] = False | ... | ... |
pdf_file/templates/pdf_file/view.html
... | ... | @@ -33,23 +33,24 @@ |
33 | 33 | <div class="panel panel-info topic-panel-invisible"> |
34 | 34 | <div class="panel-heading panel-invisible"> |
35 | 35 | {% endif %} |
36 | - <div class="row"> | |
37 | - <div class="col-md-12 category-header"> | |
38 | - <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | |
39 | - <span>{{pdf_file}}</span> | |
40 | - </h4> | |
41 | - | |
42 | - <div class="col-md-5 pull-right category-card-items"> | |
43 | - <a href="{% url 'mural:resource_view' pdf_file.slug %}" class="pull-right action_icon"> | |
44 | - <i class="fa fa-list" aria-hidden="true"></i> | |
45 | - {% resource_mural_number pdf_file request.user %} | |
46 | - </a> | |
36 | + <div class="row"> | |
37 | + <div class="col-md-12 category-header"> | |
38 | + <h4 class="panel-title" style="margin-top: 10px; margin-bottom: 8px"> | |
39 | + <span>{{pdf_file}}</span> | |
40 | + </h4> | |
41 | + | |
42 | + <div class="col-md-5 pull-right category-card-items"> | |
43 | + <a href="{% url 'mural:resource_view' pdf_file.slug %}" class="pull-right action_icon"> | |
44 | + <i class="fa fa-list" aria-hidden="true"></i> | |
45 | + {% resource_mural_number pdf_file request.user %} | |
46 | + </a> | |
47 | + </div> | |
47 | 48 | </div> |
48 | 49 | </div> |
49 | 50 | </div> |
51 | + <object width="100%" height="800px" type="application/pdf" data="{{pdf_file.file.url}}" id="pdf_content"> | |
52 | + <iframe id="pdfviewer" src="https://docs.google.com/gview?embedded=true&url={{ absolute_url }}" frameborder="0" width="100%" height="800px"></iframe> | |
53 | + {# <p>{% trans "PDF could not be displayed" %}</p> #} | |
54 | + </object> | |
50 | 55 | </div> |
51 | - <object width="100%" height="800px" type="application/pdf" data="{{pdf_file.file.url}}" id="pdf_content"> | |
52 | - <iframe id="pdfviewer" src="https://docs.google.com/gview?embedded=true&url={{ absolute_url }}" frameborder="0" width="100%" height="800px"></iframe> | |
53 | - {# <p>{% trans "PDF could not be displayed" %}</p> #} | |
54 | - </object> | |
55 | 56 | {% endblock content %} |
56 | 57 | \ No newline at end of file | ... | ... |
subjects/templates/subjects/subject_card.html
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | </ul> |
37 | 37 | {% endif %} |
38 | 38 | |
39 | - <a href="{% url 'subjects:reports:create_interaction' %}?subject_id={{subject.id}}" class="pull-right action_icon" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Analytics' %}"><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
39 | + <a href="" class="pull-right action_icon" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Analytics' %}"><i class="fa fa-bar-chart" aria-hidden="true"></i></a> | |
40 | 40 | <a href="{% url 'notifications:view' subject.slug %}" class="pull-right action_icon" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Pendencies' %}"> |
41 | 41 | <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> |
42 | 42 | {% notifies_number subject request.user %} | ... | ... |