Simple notes and achievements display
This commit is contained in:
parent
19cded4533
commit
59d2009f71
5 changed files with 70 additions and 27 deletions
|
@ -17,34 +17,33 @@ def get_notes(register_id, register_r, oun, s):
|
|||
def prepare_notes_for_display(register_id, register_r, oun, s):
|
||||
notes = get_notes(register_id, register_r, oun, s)
|
||||
|
||||
i = 0
|
||||
|
||||
print('------------------UWAGI------------------')
|
||||
while True:
|
||||
if notes['data']['Uwagi'] == []:
|
||||
print('Brak uwag!')
|
||||
break
|
||||
else:
|
||||
print('------------------------------------')
|
||||
print('Treść: '+notes['data']['Uwagi'][i]['TrescUwagi'])
|
||||
print('Kategoria: '+notes['data']['Uwagi'][i]['Kategoria'])
|
||||
print('Data: '+notes['data']['Uwagi'][i]['DataWpisu'])
|
||||
print('Nauczyciel: '+notes['data']['Uwagi'][i]['Nauczyciel'])
|
||||
print('Punkty: '+notes['data']['Uwagi'][i]['Punkty'])
|
||||
list_notes = []
|
||||
list_achievements = []
|
||||
|
||||
i = 0
|
||||
|
||||
if notes['data']['Uwagi'] == []:
|
||||
list_notes.append({'content': 'Brak uwag!'})
|
||||
else:
|
||||
while True:
|
||||
list_notes.append({'content': notes['data']['Uwagi'][i]['TrescUwagi'],
|
||||
'category': notes['data']['Uwagi'][i]['Kategoria'],
|
||||
'date': notes['data']['Uwagi'][i]['DataWpisu'],
|
||||
'teacher': notes['data']['Uwagi'][i]['Nauczyciel'],
|
||||
'points': notes['data']['Uwagi'][i]['Punkty']})
|
||||
if notes['data']['Uwagi'][i] == notes['data']['Uwagi'][-1]:
|
||||
i = 0
|
||||
break
|
||||
i += 1
|
||||
|
||||
print('------------------OSIĄGNIĘCIA------------------')
|
||||
while True:
|
||||
if notes['data']['Osiagniecia'] == []:
|
||||
print('Brak osiągnięć!')
|
||||
break
|
||||
else:
|
||||
print(notes['data']['Osiagniecia'][i])
|
||||
if notes['data']['Osiagniecia'] == []:
|
||||
list_achievements.append({'content': 'Brak osiągnięć!'})
|
||||
else:
|
||||
while True:
|
||||
list_achievements.append({'content': notes['data']['Osiagniecia'][i]})
|
||||
if notes['data']['Osiagniecia'][i] == notes['data']['Osiagniecia'][-1]:
|
||||
i = 0
|
||||
break
|
||||
i += 1
|
||||
|
||||
return list_notes, list_achievements
|
||||
|
|
|
@ -64,4 +64,22 @@ def week_homework(no):
|
|||
for i in range(4):
|
||||
homework.append(homework_all[i][no])
|
||||
|
||||
return homework
|
||||
return homework
|
||||
|
||||
@register.filter
|
||||
def points_color(points):
|
||||
if int(points) < 0:
|
||||
return 'red;'
|
||||
elif int(points) > 0:
|
||||
return 'green;'
|
||||
else:
|
||||
return 'black;'
|
||||
|
||||
@register.filter
|
||||
def suffix(points):
|
||||
if int(points) == 0 or int(points) >= 5 or int(points) <= -5:
|
||||
return points+' punktów'
|
||||
elif int(points) == -1 or int(points) == 1:
|
||||
return points+' punkt'
|
||||
elif int(points) > -5 and int(points) <= -2:
|
||||
return points+' punkty'
|
|
@ -110,8 +110,14 @@ def attendance_view(request, *args, **kwargs):
|
|||
def notes_view(request, *args, **kwargs):
|
||||
if request.session.has_key('is_logged'):
|
||||
cookies = get_cookies()
|
||||
prepare_notes_for_display(cookies[0], cookies[1], cookies[2], cookies[3])
|
||||
content = {'json_data': None}
|
||||
notes = prepare_notes_for_display(cookies[0], cookies[1], cookies[2], cookies[3])
|
||||
|
||||
content = {
|
||||
'notes': notes[0],
|
||||
'achievements': notes[1]
|
||||
}
|
||||
|
||||
print(content)
|
||||
return render(request, 'uwagi.html', content)
|
||||
else:
|
||||
return redirect(default_view)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300&family=Quicksand:wght@300&display=swap" rel="stylesheet">
|
||||
<title>Wulkanowy | Aplikacja ucznia i rodzica</title>
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
||||
<div data-v-cd2b8d62 data-v-09be56d6 id="container">
|
||||
<div id="menu">
|
||||
<h1 data-v-cd2b8d62="" class="logo">
|
||||
|
@ -82,5 +82,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +1,5 @@
|
|||
{% load static %}
|
||||
{%load custom_filters_tags %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -29,7 +30,26 @@
|
|||
</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
{{ json_data }}
|
||||
<div class='column' style='width: 50%;'>
|
||||
<div class='header' style='background-color: #bcbcbc;'>UWAGI</div>
|
||||
{% if notes.0.content == 'Brak uwag!' %}
|
||||
<div class='item'>Brak uwag!</div>
|
||||
{% else %}
|
||||
{% for i in notes %}
|
||||
<div class='item'>{{ i.content|force_escape }}<br /><i>{{ i.category|force_escape }}</i><br /><div class='line'></div>{{ i.date|force_escape }}<br />{{ i.teacher|force_escape }}<br /><span style='color: {{ i.points|points_color }}'>{{ i.points|suffix|force_escape }}</span><br /></div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class='column' style='width: 50%;'>
|
||||
<div class='header' style='background-color: #bcbcbc;'>OSIĄGNIĘCIA</div>
|
||||
{% if achievements.0.content == 'Brak osiągnięć!' %}
|
||||
<div class='item'>Brak osiągnięć!</div>
|
||||
{% else %}
|
||||
{% for i in achievements %}
|
||||
<div class='item'>{{ i.content|force_escape }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue