Commit e768a3e64ea59c05d195abf3b112dde174884932
Exists in
master
and in
2 other branches
Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring
Showing
6 changed files
with
85 additions
and
45 deletions
Show diff stats
amadeus/static/css/base/amadeus_responsive.css
| @@ -563,7 +563,7 @@ | @@ -563,7 +563,7 @@ | ||
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | /* Height Media */ | 565 | /* Height Media */ |
| 566 | -@media(max-height: 740px) { | 566 | +@media(max-height: 740px) and (max-width: 740px) { |
| 567 | /* Chat Modal */ | 567 | /* Chat Modal */ |
| 568 | #chat-modal-info .modal-dialog { | 568 | #chat-modal-info .modal-dialog { |
| 569 | margin: 0; | 569 | margin: 0; |
amadeus/templates/base.html
| @@ -363,7 +363,7 @@ | @@ -363,7 +363,7 @@ | ||
| 363 | </a> | 363 | </a> |
| 364 | </li> | 364 | </li> |
| 365 | <li class="item" data-toggle="tooltip" data-placement="right" title="{% trans "Analytics" %}"> | 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 | </li> | 367 | </li> |
| 368 | </ul> | 368 | </ul> |
| 369 | {% endblock %} | 369 | {% endblock %} |
| @@ -426,42 +426,9 @@ | @@ -426,42 +426,9 @@ | ||
| 426 | </li> | 426 | </li> |
| 427 | 427 | ||
| 428 | <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Analytics" %}"> | 428 | <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Analytics" %}"> |
| 429 | - <a href="{% url 'dashboards:view_general' %}"><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | 429 | + <a href=""><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> |
| 430 | </li> | 430 | </li> |
| 431 | </ul> | 431 | </ul> |
| 432 | - <!-- | ||
| 433 | - | ||
| 434 | - <ul class="mobile-menu"> | ||
| 435 | - <li class="item {{ subjects_menu_active }}" data-toggle="tooltip" data-placement="top" title="{% trans "Subjects" %}"> | ||
| 436 | - <a href="{% url 'subjects:index' %}"> | ||
| 437 | - <i class="fa fa-graduation-cap" aria-hidden="true"></i> | ||
| 438 | - </a> | ||
| 439 | - </li> | ||
| 440 | - <li class="item {{ mural_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Mural" %}"> | ||
| 441 | - <a href="{% url 'mural:manage_general' %}"> | ||
| 442 | - <i class="fa fa-list" aria-hidden="true" ></i> | ||
| 443 | - <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> | ||
| 444 | - </a> | ||
| 445 | - </li> | ||
| 446 | - <li class="item {{ chat_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Messages" %}"> | ||
| 447 | - <a href="{% url 'chat:manage_general' %}"> | ||
| 448 | - <i class="fa fa-envelope-o" aria-hidden="true"></i> | ||
| 449 | - <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> | ||
| 450 | - </a> | ||
| 451 | - </li> | ||
| 452 | - <li class="item {{ pendencies_menu_active }} action_icon" data-toggle="tooltip" data-placement="top" title="{% trans "Pendencies" %}"> | ||
| 453 | - <a href="{% url 'notifications:manage' %}"> | ||
| 454 | - <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | ||
| 455 | - {% if notifications_count > 0 %} | ||
| 456 | - <span class="badge notify_badge">{% if notifications_count > 99 %} +99 {% else %} {{ notifications_count }} {% endif %}</span> | ||
| 457 | - {% endif %} | ||
| 458 | - </a> | ||
| 459 | - </li> | ||
| 460 | - <li class="item" data-toggle="tooltip" data-placement="top" title="{% trans "Analytics" %}"> | ||
| 461 | - <a href="{% url 'dashboards:view_general' %}"><i class="fa fa-bar-chart" aria-hid{% get_current_language as LANGUAGE_CODE %}den="true"></i></a> | ||
| 462 | - </li> | ||
| 463 | - </ul> | ||
| 464 | - --> | ||
| 465 | </div> | 432 | </div> |
| 466 | </div> | 433 | </div> |
| 467 | </div> | 434 | </div> |
api/views.py
| @@ -23,6 +23,9 @@ from security.models import Security | @@ -23,6 +23,9 @@ from security.models import Security | ||
| 23 | from chat.serializers import ChatSerializer | 23 | from chat.serializers import ChatSerializer |
| 24 | from chat.models import TalkMessages, Conversation, ChatVisualizations | 24 | from chat.models import TalkMessages, Conversation, ChatVisualizations |
| 25 | 25 | ||
| 26 | +from log.models import Log | ||
| 27 | +from log.mixins import LogMixin | ||
| 28 | + | ||
| 26 | from subjects.serializers import SubjectSerializer | 29 | from subjects.serializers import SubjectSerializer |
| 27 | from subjects.models import Subject | 30 | from subjects.models import Subject |
| 28 | 31 | ||
| @@ -83,7 +86,7 @@ def getToken(request): | @@ -83,7 +86,7 @@ def getToken(request): | ||
| 83 | 86 | ||
| 84 | return HttpResponse(response) | 87 | return HttpResponse(response) |
| 85 | 88 | ||
| 86 | -class LoginViewset(viewsets.ReadOnlyModelViewSet): | 89 | +class LoginViewset(viewsets.ReadOnlyModelViewSet, LogMixin): |
| 87 | """ | 90 | """ |
| 88 | login: | 91 | login: |
| 89 | Log a user in the system | 92 | Log a user in the system |
| @@ -96,6 +99,11 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet): | @@ -96,6 +99,11 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet): | ||
| 96 | serializer_class = UserSerializer | 99 | serializer_class = UserSerializer |
| 97 | permissions_classes = (IsAuthenticated,) | 100 | permissions_classes = (IsAuthenticated,) |
| 98 | 101 | ||
| 102 | + log_component = 'mobile' | ||
| 103 | + log_action = 'access' | ||
| 104 | + log_resource = 'system' | ||
| 105 | + log_context = {} | ||
| 106 | + | ||
| 99 | @csrf_exempt | 107 | @csrf_exempt |
| 100 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) | 108 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
| 101 | def login(self, request): | 109 | def login(self, request): |
| @@ -121,7 +129,9 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet): | @@ -121,7 +129,9 @@ class LoginViewset(viewsets.ReadOnlyModelViewSet): | ||
| 121 | user_info['extra'] = 0 | 129 | user_info['extra'] = 0 |
| 122 | 130 | ||
| 123 | response = json.dumps(user_info) | 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 | return HttpResponse(response) | 135 | return HttpResponse(response) |
| 126 | 136 | ||
| 127 | @csrf_exempt | 137 | @csrf_exempt |
| @@ -208,7 +218,7 @@ class SubjectViewset(viewsets.ReadOnlyModelViewSet): | @@ -208,7 +218,7 @@ class SubjectViewset(viewsets.ReadOnlyModelViewSet): | ||
| 208 | 218 | ||
| 209 | return HttpResponse(response) | 219 | return HttpResponse(response) |
| 210 | 220 | ||
| 211 | -class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): | 221 | +class ParticipantsViewset(viewsets.ReadOnlyModelViewSet, LogMixin): |
| 212 | """ | 222 | """ |
| 213 | get_participants: | 223 | get_participants: |
| 214 | Get all users that participates in some subject. Require the logged user email and the subject slug | 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,17 +228,26 @@ class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): | ||
| 218 | serializer_class = UserSerializer | 228 | serializer_class = UserSerializer |
| 219 | permissions_classes = (IsAuthenticated, ) | 229 | permissions_classes = (IsAuthenticated, ) |
| 220 | 230 | ||
| 231 | + log_component = 'mobile' | ||
| 232 | + log_action = 'view' | ||
| 233 | + log_resource = 'subject_participants' | ||
| 234 | + log_context = {} | ||
| 235 | + | ||
| 221 | @csrf_exempt | 236 | @csrf_exempt |
| 222 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) | 237 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
| 223 | def get_participants(self, request): | 238 | def get_participants(self, request): |
| 224 | username = request.data['email'] | 239 | username = request.data['email'] |
| 225 | subject_slug = request.data['subject_slug'] | 240 | subject_slug = request.data['subject_slug'] |
| 226 | 241 | ||
| 242 | + user = User.objects.get(email = username) | ||
| 243 | + | ||
| 227 | participants = None | 244 | participants = None |
| 228 | 245 | ||
| 229 | response = "" | 246 | response = "" |
| 230 | 247 | ||
| 231 | if not subject_slug == "": | 248 | if not subject_slug == "": |
| 249 | + subject = Subject.objects.get(slug = subject_slug) | ||
| 250 | + | ||
| 232 | 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() | 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 | serializer = UserSerializer(participants, many = True, context = {"request_user": username}) | 253 | serializer = UserSerializer(participants, many = True, context = {"request_user": username}) |
| @@ -250,9 +269,15 @@ class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): | @@ -250,9 +269,15 @@ class ParticipantsViewset(viewsets.ReadOnlyModelViewSet): | ||
| 250 | 269 | ||
| 251 | response = json.dumps(info) | 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 | return HttpResponse(response) | 278 | return HttpResponse(response) |
| 254 | 279 | ||
| 255 | -class ChatViewset(viewsets.ModelViewSet): | 280 | +class ChatViewset(viewsets.ModelViewSet, LogMixin): |
| 256 | """ | 281 | """ |
| 257 | get_messages: | 282 | get_messages: |
| 258 | Get messages of a conversation | 283 | Get messages of a conversation |
| @@ -265,17 +290,26 @@ class ChatViewset(viewsets.ModelViewSet): | @@ -265,17 +290,26 @@ class ChatViewset(viewsets.ModelViewSet): | ||
| 265 | serializer_class = ChatSerializer | 290 | serializer_class = ChatSerializer |
| 266 | permissions_classes = (IsAuthenticated, ) | 291 | permissions_classes = (IsAuthenticated, ) |
| 267 | 292 | ||
| 293 | + log_component = 'mobile' | ||
| 294 | + log_action = 'view' | ||
| 295 | + log_resource = 'talk' | ||
| 296 | + log_context = {} | ||
| 297 | + | ||
| 268 | @csrf_exempt | 298 | @csrf_exempt |
| 269 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) | 299 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
| 270 | def get_messages(self, request): | 300 | def get_messages(self, request): |
| 271 | username = request.data['email'] | 301 | username = request.data['email'] |
| 272 | user_two = request.data['user_two'] | 302 | user_two = request.data['user_two'] |
| 273 | 303 | ||
| 304 | + user = User.objects.get(email = username) | ||
| 305 | + | ||
| 274 | messages = None | 306 | messages = None |
| 275 | 307 | ||
| 276 | response = "" | 308 | response = "" |
| 277 | 309 | ||
| 278 | if not user_two == "": | 310 | if not user_two == "": |
| 311 | + user2 = User.objects.get(email = user_two) | ||
| 312 | + | ||
| 279 | 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') | 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 | serializer = ChatSerializer(messages, many = True) | 315 | serializer = ChatSerializer(messages, many = True) |
| @@ -298,11 +332,27 @@ class ChatViewset(viewsets.ModelViewSet): | @@ -298,11 +332,27 @@ class ChatViewset(viewsets.ModelViewSet): | ||
| 298 | 332 | ||
| 299 | response = json.dumps(info) | 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 | return HttpResponse(response) | 347 | return HttpResponse(response) |
| 302 | 348 | ||
| 303 | @csrf_exempt | 349 | @csrf_exempt |
| 304 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) | 350 | @list_route(methods = ['POST'], permissions_classes = [IsAuthenticated]) |
| 305 | def send_message(self, request): | 351 | def send_message(self, request): |
| 352 | + self.log_action = 'send' | ||
| 353 | + self.log_resource = 'message' | ||
| 354 | + self.log_context = {} | ||
| 355 | + | ||
| 306 | if 'file' in request.data: | 356 | if 'file' in request.data: |
| 307 | file = request.FILES['file'] | 357 | file = request.FILES['file'] |
| 308 | 358 | ||
| @@ -342,6 +392,10 @@ class ChatViewset(viewsets.ModelViewSet): | @@ -342,6 +392,10 @@ class ChatViewset(viewsets.ModelViewSet): | ||
| 342 | subject = Subject.objects.get(slug = subject) | 392 | subject = Subject.objects.get(slug = subject) |
| 343 | space = subject.slug | 393 | space = subject.slug |
| 344 | space_type = "subject" | 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 | else: | 399 | else: |
| 346 | subject = None | 400 | subject = None |
| 347 | space = 0 | 401 | space = 0 |
| @@ -358,6 +412,11 @@ class ChatViewset(viewsets.ModelViewSet): | @@ -358,6 +412,11 @@ class ChatViewset(viewsets.ModelViewSet): | ||
| 358 | 412 | ||
| 359 | message.save() | 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 | if not message.pk is None: | 420 | if not message.pk is None: |
| 362 | simple_notify = textwrap.shorten(strip_tags(message.text), width = 30, placeholder = "...") | 421 | simple_notify = textwrap.shorten(strip_tags(message.text), width = 30, placeholder = "...") |
| 363 | 422 | ||
| @@ -393,6 +452,8 @@ class ChatViewset(viewsets.ModelViewSet): | @@ -393,6 +452,8 @@ class ChatViewset(viewsets.ModelViewSet): | ||
| 393 | info["number"] = 1 | 452 | info["number"] = 1 |
| 394 | 453 | ||
| 395 | sendChatPushNotification(user_to, message) | 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 | else: | 457 | else: |
| 397 | info["message"] = _("Error while sending message!") | 458 | info["message"] = _("Error while sending message!") |
| 398 | info["success"] = False | 459 | info["success"] = False |
categories/templates/categories/_form.html
| @@ -63,8 +63,14 @@ | @@ -63,8 +63,14 @@ | ||
| 63 | </div> | 63 | </div> |
| 64 | {% endif %} | 64 | {% endif %} |
| 65 | {% endfor %} | 65 | {% endfor %} |
| 66 | - <div class="row text-center"> | ||
| 67 | - <input type="submit" value="{% trans 'Save' %}" class="btn btn-success btn-raised" /> | 66 | + <div class="row"> |
| 67 | + <div class="col-lg-2 col-md-offset-4 col-md-6 col-sm-12 col-xs-12 text-center"> | ||
| 68 | + <input type="submit" value="{% trans 'Save' %}" class="btn btn-success btn-raised btn-block" /> | ||
| 69 | + </div> | ||
| 70 | + | ||
| 71 | + <div class="col-lg-2 col-md-6 col-sm-12 col-xs-12 text-center"> | ||
| 72 | + <a href="{% url 'home' %}" class="btn btn-default btn-raised btn-block">{% trans 'Cancel' %}</a> | ||
| 73 | + </div> | ||
| 68 | </div> | 74 | </div> |
| 69 | </form> | 75 | </form> |
| 70 | 76 |
subjects/templates/subjects/_form.html
| @@ -87,8 +87,14 @@ | @@ -87,8 +87,14 @@ | ||
| 87 | </div> | 87 | </div> |
| 88 | {% endif %} | 88 | {% endif %} |
| 89 | {% endfor %} | 89 | {% endfor %} |
| 90 | - <div class="row text-center"> | ||
| 91 | - <input type="submit" value="{% trans 'Save' %}" class="btn btn-success btn-raised" /> | 90 | + <div class="row"> |
| 91 | + <div class="col-lg-2 col-md-offset-4 col-md-6 col-sm-12 col-xs-12 text-center"> | ||
| 92 | + <input type="submit" value="{% trans 'Save' %}" class="btn btn-success btn-raised btn-block" /> | ||
| 93 | + </div> | ||
| 94 | + | ||
| 95 | + <div class="col-lg-2 col-md-6 col-sm-12 col-xs-12 text-center"> | ||
| 96 | + <a href="{% url 'home' %}" class="btn btn-default btn-raised btn-block">{% trans 'Cancel' %}</a> | ||
| 97 | + </div> | ||
| 92 | </div> | 98 | </div> |
| 93 | </form> | 99 | </form> |
| 94 | 100 |
subjects/templates/subjects/subject_card.html
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | </ul> | 36 | </ul> |
| 37 | {% endif %} | 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 | <a href="{% url 'notifications:view' subject.slug %}" class="pull-right action_icon" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Pendencies' %}"> | 40 | <a href="{% url 'notifications:view' subject.slug %}" class="pull-right action_icon" data-toggle="tooltip" data-placement="bottom" title="{% trans 'Pendencies' %}"> |
| 41 | <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> | 41 | <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> |
| 42 | {% notifies_number subject request.user %} | 42 | {% notifies_number subject request.user %} |