Commit 1e1cb4a418486a846d4c5aa1306fa71ab3081796
Exists in
master
and in
5 other branches
Merge branch 'master' of https://github.com/amadeusproject/amadeuslms
Showing
10 changed files
with
86 additions
and
126 deletions
Show diff stats
amadeus/settings.py
app/templates/home_app.html
... | ... | @@ -1,74 +0,0 @@ |
1 | -{% extends 'base.html' %} | |
2 | - | |
3 | -{% load i18n %} | |
4 | - | |
5 | -{% block breadcrumbs %} | |
6 | - <div class="row"> | |
7 | - <div class="col-md-12"> | |
8 | - <h4>{{ user }}</h4> | |
9 | - </div> | |
10 | - </div> | |
11 | - <div class="row"> | |
12 | - <div class="col-md-12"> | |
13 | - <ul class="breadcrumb" style="margin-bottom: 5px;"> | |
14 | - <li><a href="{% url 'core:index' %}">{% trans 'Home' %}</a></li> | |
15 | - <li><a href="{% url 'core:logout' %}">{% trans 'Logout' %}</a></li> | |
16 | - </ul> | |
17 | - </div> | |
18 | - </div> | |
19 | -{% endblock %} | |
20 | - | |
21 | -{% block sidebar %} | |
22 | - <div class="btn-group-vertical"> | |
23 | - <a href="javascript:void(0)" class="btn btn-raised">{% trans 'Pending tasks' %}</a> | |
24 | - <a href="javascript:void(0)" class="btn btn-raised" type="button" data-container="body" data-toggle="popover" data-placement="right" data-content="Gerson Rodriguez" >{% trans 'Users Online (1)' %}</a> | |
25 | - <a href="javascript:void(0)" class="btn btn-raised" button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{% trans 'Course' %} <span class="caret"></span></a> | |
26 | - <ul class="dropdown-menu" aria-labelledby="dLabel"> | |
27 | - <a href="{% url 'course:create' %}" class="btn btn">{% trans 'Create Course' %}</a> | |
28 | - <a href="{% url 'course:manage' %}" class="btn btn">{% trans 'Manage Course' %}</a> | |
29 | - </ul> | |
30 | - </div> | |
31 | -{% endblock %} | |
32 | - | |
33 | -{% block content %} | |
34 | - <h4> | |
35 | - <strong> | |
36 | - <center>{% trans 'Courses' %}</center> | |
37 | - </strong> | |
38 | - </h4> | |
39 | - | |
40 | - {% if courses|length > 0 %} | |
41 | - {% for course in courses %} | |
42 | - <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-{{ course.slug }}-modal-sm">{{ course }}</button> | |
43 | - <div class="modal fade bs-{{ course.slug }}-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"> | |
44 | - <div class="modal-dialog modal-sm" role="document"> | |
45 | - <div class="modal-content"> | |
46 | - <p> {{ course }}</p> | |
47 | - </div> | |
48 | - </div> | |
49 | - </div> | |
50 | - {% endfor %} | |
51 | - {% else %} | |
52 | - <p>{% trans "You didn't create any course yet." %}</p> | |
53 | - {% endif %} | |
54 | -{% endblock %} | |
55 | - | |
56 | -{% block rightbar %} | |
57 | - <div class="bs-callout bs-callout-info" id="callout-helper-context-color-specificity"> | |
58 | - <h4> | |
59 | - <strong> | |
60 | - <center>{% trans 'Goals' %}</center> | |
61 | - </strong> | |
62 | - </h4> | |
63 | - <table class="table"> | |
64 | - <tr> | |
65 | - <th scope="row"><input type="checkbox"/></th> | |
66 | - <td>70% de Presenca nas aulas</td> | |
67 | - </tr> | |
68 | - <tr> | |
69 | - <th scope="row"><input type="checkbox"/></th> | |
70 | - <td>30/11 - Entrega das notas finais</td> | |
71 | - </tr> | |
72 | - </table> | |
73 | - </div> | |
74 | -{% endblock rightbar %} |
app/templates/home_student.html
app/views.py
1 | 1 | from django.shortcuts import render |
2 | 2 | from django.views.generic import TemplateView |
3 | 3 | from django.contrib.auth.mixins import LoginRequiredMixin |
4 | +from django.utils.decorators import decorator_from_middleware_with_args | |
5 | +from django.utils.decorators import decorator_from_middleware | |
6 | +from django.utils.decorators import method_decorator | |
7 | +from core.mixins import LogMixin | |
4 | 8 | |
5 | 9 | from courses.models import Course |
6 | 10 | |
7 | -class AppIndex(LoginRequiredMixin, TemplateView): | |
11 | +class AppIndex(LoginRequiredMixin, LogMixin, TemplateView): | |
12 | + log_action = "Acessou home" | |
8 | 13 | template_name = "home_professor.html" |
9 | 14 | |
10 | 15 | def render_to_response(self, context, **response_kwargs): | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +import os | |
2 | +import datetime | |
3 | +from django.conf import settings | |
4 | +from functools import wraps | |
5 | + | |
6 | +def log_decorator(log_action = ''): | |
7 | + | |
8 | + def _log_decorator(view_function): | |
9 | + | |
10 | + def _decorator(request, *args, **kwargs): | |
11 | + | |
12 | + response = view_function(request, *args, **kwargs) | |
13 | + | |
14 | + if request.user.is_authenticated and request.POST: | |
15 | + date = datetime.datetime.now() | |
16 | + | |
17 | + message = date.strftime("%d/%m/%Y %H:%M:%S") + ' - ' + request.user.username + ' - ' + log_action + '\n' | |
18 | + | |
19 | + file_name = 'log_file_' + date.strftime("%d-%m-%Y") + '.txt' | |
20 | + | |
21 | + log_path = os.path.join(settings.LOGS_URL, file_name) | |
22 | + | |
23 | + log_file = open(log_path,'a+') | |
24 | + log_file.write(message) | |
25 | + log_file.close() | |
26 | + | |
27 | + return response | |
28 | + | |
29 | + return wraps(view_function)(_decorator) | |
30 | + | |
31 | + return _log_decorator | |
0 | 32 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +import os | |
2 | +import datetime | |
3 | +from django.conf import settings | |
4 | + | |
5 | +class LogMixin(object): | |
6 | + log_action = "" | |
7 | + | |
8 | + def dispatch(self, request, *args, **kwargs): | |
9 | + date = datetime.datetime.now() | |
10 | + | |
11 | + message = date.strftime("%d/%m/%Y %H:%M:%S") + ' - ' + request.user.username + ' - ' + self.log_action + '\n' | |
12 | + | |
13 | + file_name = 'log_file_' + date.strftime("%d-%m-%Y") + '.txt' | |
14 | + | |
15 | + log_path = os.path.join(settings.LOGS_URL, file_name) | |
16 | + | |
17 | + log_file = open(log_path,'a+') | |
18 | + log_file.write(message) | |
19 | + log_file.close() | |
20 | + | |
21 | + return super(LogMixin, self).dispatch(request, *args, **kwargs) | |
0 | 22 | \ No newline at end of file | ... | ... |
core/templates/index.html
... | ... | @@ -3,37 +3,17 @@ |
3 | 3 | {% load static i18n %} |
4 | 4 | {% load widget_tweaks %} |
5 | 5 | |
6 | -{% block style %} | |
7 | - <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css"> | |
8 | - <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | |
9 | - | |
10 | - <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7/css/bootstrap.min.css' %}"> | |
11 | - <link rel="stylesheet" type="text/css" href="{% static 'material/css/bootstrap-material-design.min.css' %}"> | |
12 | - <link rel="stylesheet" type="text/css" href="{% static 'material/css/ripples.min.css' %}"> | |
13 | - | |
14 | -{% endblock %} | |
15 | - | |
16 | - | |
17 | -{% block javascript %} | |
18 | -<!-- Jquery --> | |
19 | - <script src="{% static 'js/jquery-3.1.0.min.js' %}"></script> | |
20 | - <script src="{% static 'bootstrap-3.3.7/js/bootstrap.min.js' %}"></script> | |
21 | - <script src="{% static 'material/js/material.min.js' %}"></script> | |
22 | - <script src="{% static 'material/js/ripples.min.js' %}"></script> | |
23 | - <script> | |
24 | - $.material.init(); | |
25 | - </script> | |
6 | +{% block nav %} | |
26 | 7 | {% endblock %} |
27 | 8 | |
28 | - | |
29 | 9 | {% block content %} |
30 | - <div class="row logo-row"> | |
10 | + <div class="row logo-row"> | |
31 | 11 | <div class="col-lg-offset-2 col-lg-9"> |
32 | 12 | <img src="..." class="img-responsive center-block " alt="logo amadeus"> |
33 | 13 | </div> |
34 | 14 | </div> |
35 | 15 | |
36 | - <div class="row "> | |
16 | + <div class="row "> | |
37 | 17 | <div class="col-lg-9 col-lg-offset-2"> |
38 | 18 | <div class="card"> |
39 | 19 | {% if message %} |
... | ... | @@ -43,19 +23,17 @@ |
43 | 23 | |
44 | 24 | {% endif %} |
45 | 25 | <div class="card-content"> |
46 | - | |
47 | 26 | <div class="card-body"> |
48 | - <form id="form-login" class="form-group" method="post" action=""> | |
49 | - {% csrf_token %} | |
50 | - <div class="form-group is-empty"> | |
51 | - <label for="inputEmail" class="col-md-4 control-label"> Username</label> | |
52 | - <div class="col-md-8"> | |
53 | - <input form="form-login" type="text" name="username" class="form-control" id="inputEmail" placeholder="Username"> | |
54 | - </div> | |
55 | - </div> | |
27 | + <form id="form-login" class="form-group" method="post" action=""> | |
28 | + {% csrf_token %} | |
29 | + <div class="form-group is-empty"> | |
30 | + <label for="inputEmail" class="col-md-4 control-label"> {% trans 'Username' %}</label> | |
31 | + <div class="col-md-8"> | |
32 | + <input form="form-login" type="text" name="username" class="form-control" id="inputEmail" placeholder="Username"> | |
33 | + </div> | |
34 | + </div> | |
56 | 35 | <div class="form-group is-empty"> |
57 | - <label for="inputPassword" class="col-md-4 control-label"> Password</label> | |
58 | - | |
36 | + <label for="inputPassword" class="col-md-4 control-label"> {% trans 'Password' %}</label> | |
59 | 37 | <div class="col-md-8"> |
60 | 38 | <input form="form-login" type="password" name="password" class="form-control" id="inputPassword" placeholder="Password"> |
61 | 39 | </div> |
... | ... | @@ -63,31 +41,28 @@ |
63 | 41 | <div class="col-md-offset-2 col-md-10"> |
64 | 42 | <div class="checkbox"> |
65 | 43 | <label> |
66 | - <input form="form-login" type="checkbox" name="checkbox"><span class="checkbox-material"><span class="check"></span></span> Remember Email | |
44 | + <input form="form-login" type="checkbox" name="checkbox"><span class="checkbox-material"><span class="check"></span></span> {% trans 'Remember Email' %} | |
67 | 45 | </label> |
68 | 46 | </div> |
69 | 47 | </div> |
70 | - </form> | |
48 | + </form> | |
71 | 49 | </div> |
72 | 50 | |
73 | 51 | <footer class="card-footer" style="display: -webkit-box;"> |
74 | 52 | <div class="col-md-6"> |
75 | - <button type="button" class="btn btn-flat" formaction="#" style="position: initial;">Guest</button> | |
53 | + <button type="button" class="btn btn-flat" formaction="#" style="position: initial;">{% trans 'Guest' %}</button> | |
76 | 54 | </div> |
77 | 55 | <div class="col-md-6"> |
78 | - <button type="submite" class="btn btn-flat btn-success" form="form-login" style="position: initial;">Login</button> | |
56 | + <button type="submite" class="btn btn-flat btn-success" form="form-login" style="position: initial;">{% trans 'Login' %}</button> | |
79 | 57 | </div> |
80 | 58 | </footer> |
81 | - | |
82 | 59 | </div> |
83 | 60 | </div> |
84 | 61 | </div> |
85 | 62 | </div> |
86 | 63 | <div class="row"> |
87 | 64 | <div class="col-lg-offset-2 col-lg-9"> |
88 | - <button class="btn btn-raised btn-primary btn-lg btn-block" formaction="{% url 'users:create' %}">Sign Up </button> | |
89 | - | |
65 | + <button class="btn btn-raised btn-primary btn-lg btn-block" formaction="{% url 'users:create' %}">{% trans 'Sign Up' %} </button> | |
90 | 66 | </div> |
91 | - | |
92 | 67 | </div> |
93 | 68 | {% endblock%} | ... | ... |
core/views.py
1 | - | |
2 | 1 | from django.shortcuts import render |
3 | 2 | from django.http import HttpResponse |
3 | + | |
4 | +from django.contrib.auth import authenticate, login as login_user | |
5 | +from django.shortcuts import redirect | |
6 | +from django.core.urlresolvers import reverse | |
7 | + | |
8 | +from .decorators import log_decorator | |
4 | 9 | # from django.contrib.auth.views import LoginView |
5 | 10 | |
6 | 11 | def index(request): |
... | ... | @@ -15,12 +20,7 @@ def create_account(request): |
15 | 20 | def remember_password(request): |
16 | 21 | return render(request, "remember_password.html") |
17 | 22 | |
18 | - | |
19 | - | |
20 | -from django.contrib.auth import authenticate, login as login_user | |
21 | -from django.shortcuts import redirect | |
22 | -from django.urls import reverse | |
23 | - | |
23 | +@log_decorator('Entrou no sistema') | |
24 | 24 | def login(request): |
25 | 25 | context = {} |
26 | 26 | if request.POST: | ... | ... |
db.sqlite3
No preview for this file type