Spline work on some URLs and views
- Author
- Maarten 'Vngngdn' Vangeneugden
- Date
- Jan. 29, 2018, 2:25 a.m.
- Hash
- 141c227a80e2994519c0d87bf17fd69cad9d47e7
- Parent
- b8e9de04855e787d25bdd347f29c3217a170a0bc
- Modified files
- administration/urls.py
- administration/views.py
- static/css/base.css
administration/urls.py ¶
1 addition and 0 deletions.
View changes Hide changes
1 |
1 |
from django.contrib.auth import views as auth_views |
2 |
2 |
from . import views |
3 |
3 |
from django.utils.translation import gettext_lazy as _ |
4 |
4 |
|
5 |
5 |
urlpatterns = ([ |
6 |
6 |
path('', views.index, name='administration-index'), |
7 |
7 |
path(_('pre-registration'), views.pre_registration, name='administration-pre-registration'), |
8 |
8 |
path(_('settings'), views.settings, name='administration-settings'), |
9 |
9 |
path(_('curriculum'), views.curriculum, name='administration-curriculum'), |
10 |
10 |
path(_('results'), views.results, name='administration-results'), |
11 |
11 |
path(_('results/<slug:course>'), views.result, name='administration-results'), |
12 |
12 |
path(_('results/<int:student_id>'), views.result, name='administration-results'), |
13 |
13 |
path(_('forms'), views.forms, name='administration-forms'), # In Dutch: "Attesten" |
14 |
14 |
path(_('forms/<str:form>'), views.forms, name='administration-forms'), |
15 |
15 |
path(_('rooms'), views.rooms, name='administration-rooms'), |
16 |
16 |
path(_('rooms/<str:room>'), views.rooms, name='administration-rooms'), |
17 |
17 |
path(_('rooms/reservate'), views.room_reservate, name='administration-room-reservate'), |
18 |
18 |
path(_('roster'), views.roster, name='administration-roster'), |
19 |
19 |
|
+ |
20 |
|
20 |
21 |
path('login', views.login, name='administration-login'), |
21 |
22 |
]) |
22 |
23 |
administration/views.py ¶
6 additions and 0 deletions.
View changes Hide changes
1 |
1 |
import datetime |
2 |
2 |
from django.urls import reverse # Why? |
3 |
3 |
from django.utils.translation import gettext as _ |
4 |
4 |
from .models import * |
5 |
5 |
from .forms import UserDataForm |
6 |
6 |
import administration |
7 |
7 |
from django.contrib.auth.decorators import login_required |
8 |
8 |
|
9 |
9 |
@login_required |
10 |
10 |
def roster(request, begin=None, end=None): |
11 |
11 |
"""Collects and renders the data that has to be displayed in the roster. |
12 |
12 |
|
13 |
13 |
The begin and end date can be specified. Only roster points in that range |
14 |
14 |
will be included in the response. If no begin and end are specified, it will |
15 |
15 |
take the current week as begin and end point. If it's |
16 |
16 |
weekend, it will take next week.""" |
17 |
17 |
|
18 |
18 |
template = "administration/roster.djhtml" |
19 |
19 |
|
20 |
20 |
if begin is None or end is None: |
21 |
21 |
today = datetime.date.today() |
22 |
22 |
if today.isoweekday() in {6,7}: # Weekend |
23 |
23 |
begin = today + datetime.timedelta(days=8-today.isoweekday()) |
24 |
24 |
end = today + datetime.timedelta(days=13-today.isoweekday()) |
25 |
25 |
else: # Same week |
26 |
26 |
begin = today - datetime.timedelta(days=today.weekday()) |
27 |
27 |
end = today + datetime.timedelta(days=5-today.isoweekday()) |
28 |
28 |
|
29 |
29 |
|
30 |
30 |
return render(request, template, context) |
31 |
31 |
# TODO Finish! |
32 |
32 |
|
33 |
33 |
def index(request): |
34 |
34 |
template = "administration/index.djhtml" |
35 |
35 |
context = {} |
36 |
36 |
return render(request, template, context) |
37 |
37 |
|
38 |
38 |
pass |
39 |
39 |
|
40 |
40 |
def pre_registration(request): |
41 |
41 |
user_data_form = UserDataForm() |
42 |
42 |
template = "administration/pre_registration.djhtml" |
43 |
43 |
context = dict() |
44 |
44 |
|
45 |
45 |
if request.method == 'POST': |
46 |
46 |
user_data_form = UserDataForm(request.POST) |
47 |
47 |
context['user_data_form'] = user_data_form |
48 |
48 |
if user_data_form.is_valid(): |
49 |
49 |
user_data_form.save() |
50 |
50 |
context['messsage'] = _("Your registration has been completed. You will receive an e-mail shortly.") |
51 |
51 |
else: |
52 |
52 |
context['messsage'] = _("The data you supplied had errors. Please review your submission.") |
53 |
53 |
else: |
54 |
54 |
context['user_data_form'] = UserDataForm(instance = user_data) |
55 |
55 |
|
56 |
56 |
return render(request, template, context) |
57 |
57 |
pass |
58 |
58 |
|
59 |
59 |
@login_required |
60 |
60 |
def settings(request): |
61 |
61 |
user_data = UserData.objects.get(user=request.user) |
62 |
62 |
user_data_form = UserDataForm(instance = user_data) |
63 |
63 |
template = "administration/settings.djhtml" |
64 |
64 |
context = dict() |
65 |
65 |
|
66 |
66 |
if request.method == 'POST': |
67 |
67 |
user_data_form = UserDataForm(request.POST, instance = user_data) |
68 |
68 |
context['user_data_form'] = user_data_form |
69 |
69 |
if user_data_form.is_valid(): |
70 |
70 |
user_data_form.save() |
71 |
71 |
context['messsage'] = _("Your settings were successfully updated.") |
72 |
72 |
else: |
73 |
73 |
context['messsage'] = _("The data you supplied had errors. Please review your submission.") |
74 |
74 |
else: |
75 |
75 |
context['user_data_form'] = UserDataForm(instance = user_data) |
76 |
76 |
|
77 |
77 |
return render(request, template, context) |
78 |
78 |
|
79 |
79 |
@login_required |
80 |
80 |
def exam_commission_decisions(request): |
81 |
81 |
context = dict() |
82 |
82 |
context['decisions'] = ExamCommissionDecision.objects.filter(user=request.user) |
83 |
83 |
template = "administration/exam_commission.djhtml" |
84 |
84 |
return render(request, template, context) |
85 |
85 |
|
86 |
86 |
|
+ |
87 |
context = dict() |
+ |
88 |
template = "administration/jobs.djhtml" |
+ |
89 |
context['decisions'] = ExamCommissionDecision.objects.filter(user=request.user) |
+ |
90 |
return render(request, template, context) |
+ |
91 |
|
+ |
92 |
|
87 |
93 |
def curriculum(request): |
88 |
94 |
return render(request, template, context) |
89 |
95 |
|
90 |
96 |
def result(request): |
91 |
97 |
return render(request, template, context) |
92 |
98 |
|
93 |
99 |
@login_required |
94 |
100 |
def results(request): |
95 |
101 |
results = CourseResult.objects.filter(student=request.user) |
96 |
102 |
template = "administration/results.djhtml" |
97 |
103 |
# TODO |
98 |
104 |
return render(request, template, context) |
99 |
105 |
|
100 |
106 |
def forms(request): |
101 |
107 |
return render(request, template, context) |
102 |
108 |
|
103 |
109 |
def rooms(request): |
104 |
110 |
template = "administration/rooms.djhtml" |
105 |
111 |
return render(request, template, context) |
106 |
112 |
|
107 |
113 |
def room_reservate(request): |
108 |
114 |
return render(request, template, context) |
109 |
115 |
|
110 |
116 |
def login(request): |
111 |
117 |
if request.method == "POST": |
112 |
118 |
name = request.POST['name'] |
113 |
119 |
passphrase = request.POST['password'] |
114 |
120 |
user = authenticate(username=name, password=passphrase) |
115 |
121 |
if user is not None: # The user was successfully authenticated. |
116 |
122 |
login(request, user) |
117 |
123 |
# Because of Leen, I now track when and where is logged in: |
118 |
124 |
loginRecord = Login() |
119 |
125 |
loginRecord.ip = request.META['REMOTE_ADDR'] |
120 |
126 |
loginRecord.name = name |
121 |
127 |
loginRecord.save() |
122 |
128 |
return HttpResponseRedirect(reverse('ITdays-index')) |
123 |
129 |
|
124 |
130 |
template = 'administration/login.djhtml' |
125 |
131 |
|
126 |
132 |
footer_links = [ |
127 |
133 |
["Home", "/"], |
128 |
134 |
["Contact", "mailto:maarten.vangeneugden@student.uhasselt.be"], |
129 |
135 |
] |
130 |
136 |
|
131 |
137 |
context = { |
132 |
138 |
'materialDesign_color': "deep-purple", |
133 |
139 |
'materialDesign_accentColor': "amber", |
134 |
140 |
'navbar_title': "Authentication", |
135 |
141 |
'navbar_fixed': True, |
136 |
142 |
'navbar_backArrow': True, |
137 |
143 |
'footer_title': "Quotebook", |
138 |
144 |
'footer_description': "Een lijst van citaten uit 2BACH Informatica @ UHasselt.", |
139 |
145 |
'footer_links': footer_links, |
140 |
146 |
} |
141 |
147 |
return render(request, template, context) |
142 |
148 |
static/css/base.css ¶
16 additions and 0 deletions.
View changes Hide changes
1 |
1 |
font-family: Verdana, Futura, Arial, sans-serif; |
2 |
2 |
background-color: #dedede; |
3 |
3 |
} |
4 |
4 |
|
+ |
5 |
a.btn { |
+ |
6 |
border-style: solid; |
+ |
7 |
text-transform: uppercase; |
+ |
8 |
border-size: 3em; |
+ |
9 |
border-color: blue; |
+ |
10 |
padding: 0.5em; |
+ |
11 |
text-decoration: none; |
+ |
12 |
color: blue; |
+ |
13 |
font-weight: bold; |
+ |
14 |
} |
+ |
15 |
a.btn:hover { |
+ |
16 |
background-color: blue; |
+ |
17 |
color: white; |
+ |
18 |
} |
+ |
19 |
|
+ |
20 |