Commit e768a3e64ea59c05d195abf3b112dde174884932

Authored by Gustavo
2 parents 6ebc3185 8913cb0c

Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring

amadeus/static/css/base/amadeus_responsive.css
... ... @@ -563,7 +563,7 @@
563 563 }
564 564  
565 565 /* Height Media */
566   -@media(max-height: 740px) {
  566 +@media(max-height: 740px) and (max-width: 740px) {
567 567 /* Chat Modal */
568 568 #chat-modal-info .modal-dialog {
569 569 margin: 0;
... ...
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 %}
... ... @@ -426,42 +426,9 @@
426 426 </li>
427 427  
428 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 430 </li>
431 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 432 </div>
466 433 </div>
467 434 </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
... ...
categories/templates/categories/_form.html
... ... @@ -63,8 +63,14 @@
63 63 </div>
64 64 {% endif %}
65 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 74 </div>
69 75 </form>
70 76  
... ...
subjects/templates/subjects/_form.html
... ... @@ -87,8 +87,14 @@
87 87 </div>
88 88 {% endif %}
89 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 98 </div>
93 99 </form>
94 100  
... ...
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 %}
... ...