Simple grades display
This commit is contained in:
parent
988b43a401
commit
3d132dfa0a
8 changed files with 237 additions and 27 deletions
|
@ -33,4 +33,32 @@ def get_attendance(register_id, register_r, oun, s, date):
|
|||
json.dump(attendance_lessons_json, f)
|
||||
|
||||
with open('json/attendance.json', 'w') as f:
|
||||
json.dump(attendance_json, f)
|
||||
json.dump(attendance_json, f)
|
||||
|
||||
def prepare_attendance_for_display():
|
||||
#with open('json/attendance_lessons.json') as f:
|
||||
#timetable_lessons = json.load(f)
|
||||
with open('json/attendance.json') as f:
|
||||
timetable = json.load(f)
|
||||
|
||||
i = 0
|
||||
|
||||
print('<--------------------FREKWENCJA-------------------->')
|
||||
print('--------------------PONIEDZIAŁEK--------------------')
|
||||
while True:
|
||||
print('Treść: '+timetable['data']['Frekwencje'][i]['Symbol'])
|
||||
print('Przedmiot: '+timetable['data']['Frekwencje'][i]['PrzedmiotNazwa'])
|
||||
print('-----------------------------------------------------')
|
||||
if timetable['data']['Frekwencje'][i] == timetable['data']['Frekwencje'][-1]:
|
||||
i = 0
|
||||
break
|
||||
if timetable['data']['Frekwencje'][i]['NrDnia'] != timetable['data']['Frekwencje'][i+1]['NrDnia']:
|
||||
if timetable['data']['Frekwencje'][i+1]['NrDnia'] == 2:
|
||||
print('--------------------WTOREK--------------------')
|
||||
elif timetable['data']['Frekwencje'][i+1]['NrDnia'] == 3:
|
||||
print('--------------------ŚRODA--------------------')
|
||||
elif timetable['data']['Frekwencje'][i+1]['NrDnia'] == 4:
|
||||
print('--------------------CZWARTEK--------------------')
|
||||
elif timetable['data']['Frekwencje'][i+1]['NrDnia'] == 5:
|
||||
print('--------------------PIĄTEK--------------------')
|
||||
i += 1
|
|
@ -32,28 +32,27 @@ def prepare_grades_for_display():
|
|||
i = 0
|
||||
a = 0
|
||||
|
||||
json_grades = {}
|
||||
|
||||
lesson_name = []
|
||||
|
||||
while True:
|
||||
#lessons = grades.json()['data']['Oceny'][i]['Pozycja']
|
||||
lesson_name.append(grades['data']['Oceny'][i]['Przedmiot'])
|
||||
print('------------------------------------------------')
|
||||
print(lesson_name[i])
|
||||
print('------------------------------------------------')
|
||||
json_grades.update({grades['data']['Oceny'][i]['Przedmiot']: []})
|
||||
if grades['data']['Oceny'][i]['OcenyCzastkowe'] != []:
|
||||
while True:
|
||||
print('<----------------------------------------------------------->')
|
||||
print('Ocena: '+grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['Wpis'])
|
||||
print('Nauczyciel: '+grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['Nauczyciel'])
|
||||
print('Opis: '+grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['NazwaKolumny'])
|
||||
print('Data: '+grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['DataOceny'])
|
||||
print('Waga Oceny: '+str(grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['Waga']))
|
||||
json_grades[lesson_name[i]].append({'Ocena': grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['Wpis'],
|
||||
'Nauczyciel': grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['Nauczyciel'],
|
||||
'Opis': grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['NazwaKolumny'],
|
||||
'Data': grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['DataOceny'],
|
||||
'Waga Oceny': grades['data']['Oceny'][i]['OcenyCzastkowe'][a]['Waga']})
|
||||
if grades['data']['Oceny'][i]['OcenyCzastkowe'][a] == grades['data']['Oceny'][i]['OcenyCzastkowe'][-1]:
|
||||
a = 0
|
||||
break
|
||||
a += 1
|
||||
else:
|
||||
print('Brak Ocen!')
|
||||
if grades['data']['Oceny'][i]['Pozycja'] == grades['data']['Oceny'][-1]['Pozycja']:
|
||||
break
|
||||
i += 1
|
||||
i += 1
|
||||
|
||||
return [json_grades, lesson_name]
|
|
@ -29,8 +29,6 @@ def prepare_notes_for_display():
|
|||
with open('json/notes.json') as f:
|
||||
notes = json.load(f)
|
||||
|
||||
print(notes)
|
||||
|
||||
i = 0
|
||||
|
||||
print('------------------UWAGI------------------')
|
||||
|
|
0
mypage/Wulkanowy/templatetags/__init__.py
Normal file
0
mypage/Wulkanowy/templatetags/__init__.py
Normal file
13
mypage/Wulkanowy/templatetags/custom_filters_tags.py
Normal file
13
mypage/Wulkanowy/templatetags/custom_filters_tags.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def return_item(l, i):
|
||||
try:
|
||||
if l[i] == []:
|
||||
return ['Brak Ocen']
|
||||
else:
|
||||
return l[i]
|
||||
except:
|
||||
return None
|
|
@ -11,8 +11,8 @@ from .API.homework import prepare_homework_for_display
|
|||
from .API.exams import prepare_exams_for_display
|
||||
from .API.timetable import prepare_timetable_for_display
|
||||
from .API.notes import prepare_notes_for_display
|
||||
from .API.attendance import prepare_attendance_for_display
|
||||
|
||||
# Create your views here.
|
||||
def default_view(request, *args, **kwargs):
|
||||
new_form = loginForm()
|
||||
if request.method == "POST":
|
||||
|
@ -67,8 +67,19 @@ def error_view(request, *args, **kwargs):
|
|||
return render(request, 'form_error.html', context)
|
||||
|
||||
def grades_view(request, *args, **kwargs):
|
||||
prepare_grades_for_display()
|
||||
content = {'json_data': None}
|
||||
grades = prepare_grades_for_display()
|
||||
|
||||
grade = {}
|
||||
description = {}
|
||||
|
||||
for i in grades[1]:
|
||||
grade.update({i: []})
|
||||
description.update({i: []})
|
||||
for items in grades[0][i]:
|
||||
grade[i].append(items['Ocena'])
|
||||
description[i].append(items['Opis'])
|
||||
|
||||
content = {'gc': grade, 'dc': description, 'lesson': grades[1]}
|
||||
return render(request, 'oceny.html', content)
|
||||
|
||||
def homework_view(request, *args, **kwargs):
|
||||
|
@ -82,11 +93,8 @@ def timetable_view(request, *args, **kwargs):
|
|||
return render(request, 'plan.html', content)
|
||||
|
||||
def attendance_view(request, *args, **kwargs):
|
||||
with open('json/attendance_lessons.json') as f:
|
||||
timetable_lessons_load = json.load(f)
|
||||
with open('json/attendance.json') as f:
|
||||
timetable_load = json.load(f)
|
||||
content = {'json_data': timetable_lessons_load, 'json_data2': timetable_load}
|
||||
prepare_attendance_for_display()
|
||||
content = {'json_data': None}
|
||||
return render(request, 'frekwencja.html', content)
|
||||
|
||||
def notes_view(request, *args, **kwargs):
|
||||
|
@ -100,4 +108,4 @@ def exams_view(request, *args, **kwargs):
|
|||
return render(request, 'sprawdziany.html', content)
|
||||
|
||||
def messeges_view(request, *args, **kwargs):
|
||||
return render(request, 'wiadomosci.html')
|
||||
return render(request, 'wiadomosci.html')
|
|
@ -58,4 +58,79 @@ body {
|
|||
box-shadow: 10px 10px 15px;
|
||||
font-family: 'Lora', serif;
|
||||
font-size: 200%;
|
||||
}
|
||||
.lesson{
|
||||
background-color: #fefefe;
|
||||
border-radius: 24px;
|
||||
font-family: 'Open Sans Condensed', sans-serif;
|
||||
font-family: 'Quicksand', sans-serif;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
font-size: 150%;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
padding-top: 3vh;
|
||||
padding-bottom: 0.5vh;
|
||||
}
|
||||
ul{
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
li{
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
li > ul > li{
|
||||
display: none;
|
||||
}
|
||||
|
||||
li:active > ul > li{
|
||||
display: block;
|
||||
}
|
||||
|
||||
#grades{
|
||||
float: left;
|
||||
}
|
||||
|
||||
.description{
|
||||
text-align: center;
|
||||
margin-right: 7vw;
|
||||
}
|
||||
|
||||
.description::before{
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.grade{
|
||||
display: absolute;
|
||||
height: 39.75px;
|
||||
width: 39.75px;
|
||||
margin-left: 3vw;
|
||||
font-size: 99%;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.grade::before{
|
||||
position: absolute;
|
||||
border-bottom: 2px solid #cdcdcd;
|
||||
height: 8%;
|
||||
content: '';
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.grade-else{
|
||||
display: absolute;
|
||||
height: 39.75px;
|
||||
width: block;
|
||||
margin-left: 3vw;
|
||||
font-size: 99%;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.grade-else::before{
|
||||
position: absolute;
|
||||
border-bottom: 2px solid #cdcdcd;
|
||||
height: 8%;
|
||||
content: '';
|
||||
width: 80%;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{% load static %}
|
||||
{% load custom_filters_tags %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -29,8 +30,96 @@
|
|||
</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
{{ json_data }}
|
||||
{% for l in lesson %}
|
||||
<div class="lesson">
|
||||
<li>{{ l }}
|
||||
<ul>
|
||||
<li>
|
||||
{% for i in gc %}
|
||||
{% if i == l %}
|
||||
<div id='grades_content'>
|
||||
<div id='grades'>
|
||||
{% for grade in gc|return_item:i %}
|
||||
{% if grade != 'Brak Ocen' %}
|
||||
{% if grade == '6' %}
|
||||
<div class='grade' style='background-color: #3dbbf5;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '6-' %}
|
||||
<div class='grade' style='background-color: #3dbbf5;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '5' %}
|
||||
<div class='grade' style='background-color: #4caf50;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '5-' %}
|
||||
<div class='grade' style='background-color: #4caf50;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '5+' %}
|
||||
<div class='grade' style='background-color: #4caf50;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '4' %}
|
||||
<div class='grade' style='background-color: #a0c431;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '4-' %}
|
||||
<div class='grade' style='background-color: #a0c431;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '4+' %}
|
||||
<div class='grade' style='background-color: #a0c431;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '3' %}
|
||||
<div class='grade' style='background-color: #ffb940;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '3-' %}
|
||||
<div class='grade' style='background-color: #ffb940;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '3+' %}
|
||||
<div class='grade' style='background-color: #ffb940;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '2' %}
|
||||
<div class='grade' style='background-color: #ff774d;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '2-' %}
|
||||
<div class='grade' style='background-color: #ff774d;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '2+' %}
|
||||
<div class='grade' style='background-color: #ff774d;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '1' %}
|
||||
<div class='grade' style='background-color: #d43f3f;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% elif grade == '1+' %}
|
||||
<div class='grade' style='background-color: #d43f3f;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% else %}
|
||||
<div class='grade-else' style='background-color: #607d8b;'>{{ grade }}</div>
|
||||
<br />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id='descriptions'>
|
||||
{% for description in dc|return_item:i %}
|
||||
{% if description == 'Brak Ocen' %}
|
||||
<div class='description' style='margin-right: 2vw;'>Brak Ocen</div>
|
||||
<br />
|
||||
{% elif description == '' %}
|
||||
<div class='description'>Brak Opisu</div>
|
||||
<br />
|
||||
{% else %}
|
||||
<div class='description'>{{ description }}</div>
|
||||
<br />
|
||||
{% endif %}
|
||||
{% endfor%}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</div>
|
||||
<br />
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue