Merge branch 'master' into feature/react

This commit is contained in:
Pengwius 2021-02-05 12:18:59 +01:00 committed by GitHub
commit f1d0be74e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 3293 additions and 371 deletions

View file

@ -1,30 +1,14 @@
import requests
import json
from .generate_cookies import autogenerate_cookies
def get_attendance(register_id, register_r, oun, s, date):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_attendance(register_id, students, oun, s, date):
cookies = autogenerate_cookies(students, s)
with open('app/API/headers.json') as f:
headers = json.load(f)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
attendance_lessons = requests.post(oun+'/FrekwencjaStatystykiPrzedmioty.mvc/Get', headers=headers, cookies=cookies)
attendance_json_id = attendance_lessons.json()['data'][0]['Id']

View file

@ -2,46 +2,31 @@ import json
import requests
import re
from bs4 import BeautifulSoup
from .generate_cookies import autogenerate_cookies
def get_dashboard(register_id, register_r, s, diary_url, symbol):
cookies = s
def get_dashboard(register_id, students, s, diary_url, symbol):
if diary_url != 'http://cufs.fakelog.cf/':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
diary_url = 'http://uonetplus.vulcan.net.pl/'
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
diary_url = 'http://uonetplus.fakelog.cf/'
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
cookies = autogenerate_cookies(students, s)
with open('app/API/headers.json') as f:
headers = json.load(f)
index = requests.get(f'{diary_url}{symbol}/Start.mvc/Index', headers=headers, cookies=cookies)
permissions_value = re.search("permissions: '(.)*'", index.text)
permissions_value = permissions_value.group()
permissions_value = permissions_value.replace('permissions: ', '').replace("'", "")
json = {
permissions = {
"permissions": permissions_value
}
last_notes = requests.post(f'{diary_url}{symbol}/Start.mvc/GetLastNotes', headers=headers, cookies=cookies, json=json)
free_days = requests.post(f'{diary_url}{symbol}/Start.mvc/GetFreeDays', headers=headers, cookies=cookies, json=json)
lucky_number = requests.post(f'{diary_url}{symbol}/Start.mvc/GetKidsLuckyNumbers', headers=headers, cookies=cookies, json=json)
last_notes = requests.post(f'{diary_url}{symbol}/Start.mvc/GetLastNotes', headers=headers, cookies=cookies, json=permissions)
free_days = requests.post(f'{diary_url}{symbol}/Start.mvc/GetFreeDays', headers=headers, cookies=cookies, json=permissions)
lucky_number = requests.post(f'{diary_url}{symbol}/Start.mvc/GetKidsLuckyNumbers', headers=headers, cookies=cookies, json=permissions)
return_data = {
"last_notes": last_notes.json(),

View file

@ -1,30 +1,13 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_exams(register_id, register_r, oun, s, date, school_year):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_exams(register_id, students, oun, s, date, school_year):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
exams = requests.post(oun+'/Sprawdziany.mvc/Get', headers=headers, cookies=cookies, json={'data': date, 'rokSzkolny': school_year})

View file

@ -0,0 +1,12 @@
import json
def autogenerate_cookies(students, s):
cookies = s
cookies.update({
"biezacyRokSzkolny": f"{students['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{students['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{students['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{students['data'][0]['IdUczen']}"
})
return cookies

View file

@ -1,30 +1,13 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_grades(register_id, register_r, oun, s):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_grades(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
grades = requests.post(oun+'/Oceny.mvc/Get', headers=headers, cookies=cookies, json={'okres': register_id})

6
app/API/headers.json Normal file
View file

@ -0,0 +1,6 @@
{
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "keep-alive",
"User-Agent": "Wulkanowy-web :)"
}

View file

@ -1,31 +1,14 @@
import requests
import json
from .generate_cookies import autogenerate_cookies
def get_homeworks(register_id, register_r, oun, s, date, school_year):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_homeworks(register_id, students, oun, s, date, school_year):
cookies = autogenerate_cookies(students, s)
headres = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
'User-Agent': 'Wulkanowy-web :)'
}
with open('app/API/headers.json') as f:
headers = json.load(f)
homeworks = requests.post(oun+'/Homework.mvc/Get', headers=headres, cookies=cookies, json={'schoolYear': school_year, 'date': date, 'statusFilter': '-1'})
homeworks = requests.post(oun+'/Homework.mvc/Get', headers=headers, cookies=cookies, json={'schoolYear': school_year, 'date': date, 'statusFilter': '-1'})
return homeworks.json()

View file

@ -4,13 +4,9 @@ import calendar
import time
import re
def get_received_messages(register_id, register_r, oun, s, date, school_year, symbol):
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
def get_received_messages(register_id, students, oun, s, date, school_year, symbol):
with open('app/API/headers.json') as f:
headers = json.load(f)
now = calendar.timegm(time.gmtime())
@ -21,13 +17,9 @@ def get_received_messages(register_id, register_r, oun, s, date, school_year, sy
return received_messages.json()
def get_sent_messages(register_id, register_r, oun, s, date, school_year, symbol):
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
def get_sent_messages(register_id, students, oun, s, date, school_year, symbol):
with open('app/API/headers.json') as f:
headers = json.load(f)
now = calendar.timegm(time.gmtime())
@ -38,13 +30,9 @@ def get_sent_messages(register_id, register_r, oun, s, date, school_year, symbol
return sent_messages.json()
def get_deleted_messages(register_id, register_r, oun, s, date, school_year, symbol):
headers = {
'Accept-Encoding': 'gzip, deflate, br7',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
def get_deleted_messages(register_id, students, oun, s, date, school_year, symbol):
with open('app/API/headers.json') as f:
headers = json.load(f)
now = calendar.timegm(time.gmtime())
@ -55,13 +43,9 @@ def get_deleted_messages(register_id, register_r, oun, s, date, school_year, sym
return deleted_messages.json()
def get_recipients(register_id, register_r, oun, s, date, school_year, symbol):
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
def get_recipients(register_id, students, oun, s, date, school_year, symbol):
with open('app/API/headers.json') as f:
headers = json.load(f)
if oun == 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
link = f'http://uonetplus-uzytkownik.fakelog.cf/{symbol}'
@ -77,22 +61,16 @@ def get_recipients(register_id, register_r, oun, s, date, school_year, symbol):
return {'addressee': get_addressee.json(), 'unitId': id_jednostka}
def send_message(register_id, register_r, oun, s, date, school_year, symbol, send_data):
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accet': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)",
'Content-Type': 'application/json',
'TE': "Trailers"
}
def send_message(register_id, students, oun, s, date, school_year, symbol, send_data):
with open('app/API/headers.json') as f:
headers = json.load(f)
if oun == 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
link = f'http://uonetplus-uzytkownik.fakelog.cf/{symbol}'
else:
link = f'https://uonetplus-uzytkownik.vulcan.net.pl/{symbol}'
student_data = register_r['data'][0]['UczenNazwisko']+' '+register_r['data'][0]['UczenImie']
student_data = students['data'][0]['UczenNazwisko']+' '+students['data'][0]['UczenImie']
sess = requests.Session()
@ -111,7 +89,9 @@ def send_message(register_id, register_r, oun, s, date, school_year, symbol, sen
sess.headers.update({
'X-V-RequestVerificationToken': antiForgeryToken,
'X-V-AppGuid': appGuid
'X-V-AppGuid': appGuid,
'Content-Type': 'application/json',
'TE': "Trailers"
})
payload = {
@ -157,13 +137,9 @@ def send_message(register_id, register_r, oun, s, date, school_year, symbol, sen
return send.json()
def get_message_content(register_id, register_r, oun, s, date, school_year, symbol, message_id):
headers = {
'Accept-Encoding': 'gzip, deflate, br',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
def get_message_content(register_id, students, oun, s, date, school_year, symbol, message_id):
with open('app/API/headers.json') as f:
headers = json.load(f)
if oun == 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
link = f'http://uonetplus-uzytkownik.fakelog.cf/{symbol}'
@ -196,4 +172,10 @@ def get_message_content(register_id, register_r, oun, s, date, school_year, symb
content = sess.post(f'{link}/Wiadomosc.mvc/GetInboxMessageDetails', data=json.dumps(payload))
if content.status_code != 200:
while True:
content = sess.post(f'{link}/Wiadomosc.mvc/GetInboxMessageDetails', data=json.dumps(payload))
if content.status_code == 200:
break
return content.json()

View file

@ -1,59 +1,24 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_registered_devices(register_id, register_r, oun, s):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_registered_devices(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
registered = requests.post(oun+'/ZarejestrowaneUrzadzenia.mvc/Get', headers=headers, cookies=cookies)
return registered.json()
def register_device(register_id, register_r, oun, s):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def register_device(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
register_data = requests.post(oun+'/RejestracjaUrzadzeniaToken.mvc/Get', headers=headers, cookies=cookies)

View file

@ -1,30 +1,13 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_notes(register_id, register_r, oun, s):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_notes(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
notes = requests.post(oun+'/UwagiIOsiagniecia.mvc/Get', headers=headers, cookies=cookies)

View file

@ -1,30 +1,13 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_school_data(register_id, register_r, oun, s):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_school_data(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
school_data = requests.post(oun+'/SzkolaINauczyciele.mvc/Get', headers=headers, cookies=cookies)

25
app/API/stats.py Normal file
View file

@ -0,0 +1,25 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_partial(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
with open('app/API/headers.json') as f:
headers = json.load(f)
partial = requests.post(oun+'/Statystyki.mvc/GetOcenyCzastkowe', headers=headers, cookies=cookies, json={'idOkres': register_id})
return partial.json()
def get_year(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
with open('app/API/headers.json') as f:
headers = json.load(f)
year = requests.post(oun+'/Statystyki.mvc/GetOcenyRoczne', headers=headers, cookies=cookies, json={'idOkres': register_id})
return year.json()

View file

@ -1,30 +1,13 @@
import json
import requests
from .generate_cookies import autogenerate_cookies
def get_student_data(register_id, register_r, oun, s):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_student_data(register_id, students, oun, s):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
student_data = requests.post(f'{oun}/Uczen.mvc/Get', headers=headers, cookies=cookies)

View file

@ -1,31 +1,14 @@
import json
import requests
from bs4 import BeautifulSoup
from .generate_cookies import autogenerate_cookies
def get_timetable(register_id, register_r, oun, s, date):
cookies = s
if oun != 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyDziennikWychowankowie": f"{register_r['data'][0]['IdWychowankowieDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
else:
cookies.update({
"biezacyRokSzkolny": f"{register_r['data'][0]['DziennikRokSzkolny']}",
"idBiezacyDziennik": f"{register_r['data'][0]['IdDziennik']}",
"idBiezacyDziennikPrzedszkole": f"{register_r['data'][0]['IdPrzedszkoleDziennik']}",
"idBiezacyUczen": f"{register_r['data'][0]['IdUczen']}"
})
def get_timetable(register_id, students, oun, s, date):
cookies = autogenerate_cookies(students, s)
headers = {
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
"User-Agent": "Wulkanowy-web :)"
}
with open('app/API/headers.json') as f:
headers = json.load(f)
timetable = requests.post(oun+'/PlanZajec.mvc/Get', headers=headers, cookies=cookies, json={'data': date})

View file

@ -52,8 +52,8 @@ def send(url, data, fail, diary_url, symbol, s):
return cookies
def get_cookies(symbol, oun, s, diary_url):
register_r = s.post(oun+'/UczenDziennik.mvc/Get')
register_id = register_r.json()['data'][0]['Okresy'][0]['Id']
students = s.post(oun+'/UczenDziennik.mvc/Get')
register_id = students.json()['data'][0]['Okresy'][0]['Id']
now = datetime.datetime.now()
weekday = now.weekday()
@ -70,11 +70,11 @@ def get_cookies(symbol, oun, s, diary_url):
date = f'{date}T00:00:00'
school_year = register_r.json()['data'][0]['DziennikRokSzkolny']
school_year = students.json()['data'][0]['DziennikRokSzkolny']
data = {
'register_id': register_id,
'register_r': register_r.json(),
'students': students.json(),
'oun': oun,
'date': str(date),
'school_year': school_year,

View file

@ -20,7 +20,9 @@ from .API.mobile_access import get_registered_devices, register_device
from .API.school_data import get_school_data
from .API.dashboard import get_dashboard
from .API.student_data import get_student_data
from .API.stats import get_partial, get_year
from .decrypt import decrypt_cookies
import datetime
#API
def login(request, *args, **kwargs):
@ -55,12 +57,12 @@ def grades(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
grades = get_grades(register_id, register_r, oun, s)
grades = get_grades(register_id, students, oun, s)
return JsonResponse(grades)
else:
return redirect('../')
@ -68,14 +70,31 @@ def grades(request, *args, **kwargs):
def timetable(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
week = data['week']
data = json.loads(data['cookies'])
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
date = data['data']['date']
timetable = get_timetable(register_id, register_r, oun, s, date)
now = datetime.datetime.now()
weekday = now.weekday()
for x in range(7):
if weekday == x:
now = now - datetime.timedelta(days=x)
now = now + datetime.timedelta(days=week*7)
day = now.day
month = now.month
year = now.year
date = datetime.date(year, month, day).isoformat()
date = f'{date}T00:00:00'
timetable = get_timetable(register_id, students, oun, s, date)
return JsonResponse(timetable)
else:
return redirect('../')
@ -83,15 +102,32 @@ def timetable(request, *args, **kwargs):
def exams(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
week = data['week']
data = json.loads(data['cookies'])
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
date = data['data']['date']
now = datetime.datetime.now()
weekday = now.weekday()
for x in range(7):
if weekday == x:
now = now - datetime.timedelta(days=x)
now = now + datetime.timedelta(days=week*7)
day = now.day
month = now.month
year = now.year
date = datetime.date(year, month, day).isoformat()
date = f'{date}T00:00:00'
school_year = data['data']['school_year']
exams = get_exams(register_id, register_r, oun, s, date, school_year)
exams = get_exams(register_id, students, oun, s, date, school_year)
return JsonResponse(exams)
else:
return redirect('../')
@ -99,15 +135,32 @@ def exams(request, *args, **kwargs):
def homeworks(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
week = data['week']
data = json.loads(data['cookies'])
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
date = data['data']['date']
now = datetime.datetime.now()
weekday = now.weekday()
for x in range(7):
if weekday == x:
now = now - datetime.timedelta(days=x)
now = now + datetime.timedelta(days=week*7)
day = now.day
month = now.month
year = now.year
date = datetime.date(year, month, day).isoformat()
date = f'{date}T00:00:00'
school_year = data['data']['school_year']
homeworks = get_homeworks(register_id, register_r, oun, s, date, school_year)
homeworks = get_homeworks(register_id, students, oun, s, date, school_year)
return JsonResponse(homeworks)
else:
return redirect('../')
@ -115,14 +168,31 @@ def homeworks(request, *args, **kwargs):
def attendance(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
week = data['week']
data = json.loads(data['cookies'])
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
date = data['data']['date']
attendance = get_attendance(register_id, register_r, oun, s, date)
now = datetime.datetime.now()
weekday = now.weekday()
for x in range(7):
if weekday == x:
now = now - datetime.timedelta(days=x)
now = now + datetime.timedelta(days=week*7)
day = now.day
month = now.month
year = now.year
date = datetime.date(year, month, day).isoformat()
date = f'{date}T00:00:00'
attendance = get_attendance(register_id, students, oun, s, date)
return JsonResponse(attendance, safe=False)
else:
return redirect('../')
@ -131,12 +201,12 @@ def notes(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
notes = get_notes(register_id, register_r, oun, s)
notes = get_notes(register_id, students, oun, s)
return JsonResponse(notes)
else:
return redirect('../')
@ -145,12 +215,12 @@ def registered_devices(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
registered = get_registered_devices(register_id, register_r, oun, s)
registered = get_registered_devices(register_id, students, oun, s)
return JsonResponse(registered)
else:
return redirect('../')
@ -159,12 +229,12 @@ def register_device_(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
register_data = register_device(register_id, register_r, oun, s)
register_data = register_device(register_id, students, oun, s)
return JsonResponse(register_data)
else:
return redirect('../')
@ -173,7 +243,7 @@ def received_messages(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
@ -181,7 +251,7 @@ def received_messages(request, *args, **kwargs):
date = data['data']['date']
school_year = data['data']['school_year']
symbol = data['data']['symbol']
received_messages = get_received_messages(register_id, register_r, oun, s, date, school_year, symbol)
received_messages = get_received_messages(register_id, students, oun, s, date, school_year, symbol)
return JsonResponse(received_messages)
else:
return redirect('../')
@ -190,7 +260,7 @@ def sent_messages(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
@ -198,7 +268,7 @@ def sent_messages(request, *args, **kwargs):
date = data['data']['date']
school_year = data['data']['school_year']
symbol = data['data']['symbol']
sent_messages = get_sent_messages(register_id, register_r, oun, s, date, school_year, symbol)
sent_messages = get_sent_messages(register_id, students, oun, s, date, school_year, symbol)
return JsonResponse(sent_messages)
else:
return redirect('../')
@ -207,7 +277,7 @@ def deleted_messages(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
@ -215,7 +285,7 @@ def deleted_messages(request, *args, **kwargs):
date = data['data']['date']
school_year = data['data']['school_year']
symbol = data['data']['symbol']
deleted_messages = get_deleted_messages(register_id, register_r, oun, s, date, school_year, symbol)
deleted_messages = get_deleted_messages(register_id, students, oun, s, date, school_year, symbol)
return JsonResponse(deleted_messages)
else:
return redirect('../')
@ -224,7 +294,7 @@ def recipients(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
@ -232,7 +302,7 @@ def recipients(request, *args, **kwargs):
date = data['data']['date']
school_year = data['data']['school_year']
symbol = data['data']['symbol']
recipients = get_recipients(register_id, register_r, oun, s, date, school_year, symbol)
recipients = get_recipients(register_id, students, oun, s, date, school_year, symbol)
return JsonResponse(recipients)
else:
return redirect('../')
@ -241,12 +311,12 @@ def school_data(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
school_data = get_school_data(register_id, register_r, oun, s)
school_data = get_school_data(register_id, students, oun, s)
return JsonResponse(school_data)
else:
return redirect('../')
@ -255,13 +325,13 @@ def dashboard(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
diary_url = data['data']['diary_url']
symbol = data['data']['symbol']
dashboard = get_dashboard(register_id, register_r, s, diary_url, symbol)
dashboard = get_dashboard(register_id, students, s, diary_url, symbol)
return JsonResponse(dashboard)
else:
return redirect('../')
@ -271,7 +341,7 @@ def send(request, *args, **kwargs):
data = json.loads(request.body)
cookies_data = json.loads(data['cookies_data'])
register_id = cookies_data['data']['register_id']
register_r = cookies_data['data']['register_r']
students = cookies_data['data']['students']
oun = cookies_data['data']['oun']
s = cookies_data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
@ -280,7 +350,7 @@ def send(request, *args, **kwargs):
school_year = cookies_data['data']['school_year']
symbol = cookies_data['data']['symbol']
send_data = {'data': data['data'], 'subject': data['subject'], 'content': data['content']}
send = send_message(register_id, register_r, oun, s, date, school_year, symbol, send_data)
send = send_message(register_id, students, oun, s, date, school_year, symbol, send_data)
return JsonResponse(send, safe=False)
else:
return redirect('../')
@ -290,7 +360,7 @@ def message_content(request, *args, **kwargs):
data = json.loads(request.body)
cookies_data = json.loads(data['cookies_data'])
register_id = cookies_data['data']['register_id']
register_r = cookies_data['data']['register_r']
students = cookies_data['data']['students']
oun = cookies_data['data']['oun']
s = cookies_data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
@ -299,7 +369,7 @@ def message_content(request, *args, **kwargs):
school_year = cookies_data['data']['school_year']
symbol = cookies_data['data']['symbol']
message_id = data['message_id']
content = get_message_content(register_id, register_r, oun, s, date, school_year, symbol, message_id)
content = get_message_content(register_id, students, oun, s, date, school_year, symbol, message_id)
return JsonResponse(content, safe=False)
else:
return redirect('../')
@ -308,16 +378,45 @@ def student_data(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
register_r = data['data']['register_r']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
data = get_student_data(register_id, register_r, oun, s)
data = get_student_data(register_id, students, oun, s)
return JsonResponse(data)
else:
return redirect('../')
#STATS
def partial(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
partial_stats = get_partial(register_id, students, oun, s)
return JsonResponse(partial_stats)
else:
return redirect('../')
def year(request, *args, **kwargs):
if request.session.has_key('is_logged'):
data = json.loads(request.body)
register_id = data['data']['register_id']
students = data['data']['students']
oun = data['data']['oun']
s = data['data']['s']
key = bytes(request.session[request.session.session_key], 'utf-8')
s = decrypt_cookies(s, key)
year_stats = get_year(register_id, students, oun, s)
return JsonResponse(year_stats)
else:
return redirect('../')
def log_out(request, *args, **kwargs):
del request.session[request.session.session_key]
del request.session['is_logged']

4
batch/Instell.bat Normal file
View file

@ -0,0 +1,4 @@
cd ..
cd frontend
cls
npm install

View file

@ -2,5 +2,6 @@
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
npm install
pause
cd batch
start instell.exe

BIN
batch/instell.exe Normal file

Binary file not shown.

5
batch/webpack.bat Normal file
View file

@ -0,0 +1,5 @@
cd ..
cd frontend
cls
::dir
npm run dev

BIN
batch/webpack.exe Normal file

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
var cookies_data = JSON.parse(sessionStorage.getItem('cookies_data'));
students = cookies_data.data.register_r.data;
students = cookies_data.data.students.data;
const displayData = () => {
var primary = '';
@ -28,7 +28,7 @@ const logIn = () => {
studentName = ele[i].value;
students.forEach((student) => {
if (student.UczenPelnaNazwa == studentName) {
cookies_data.data.register_r.data = [student];
cookies_data.data.students.data = [student];
sessionStorage.setItem('cookies_data', JSON.stringify(cookies_data));
window.location.href = '/content/';
}

View file

@ -1,10 +1,22 @@
const attendance_ = document.querySelector('#attendance_');
myStorage = window.sessionStorage;
weekAttendance = 0
const getAttendance = () => {
const getAttendance = (event) => {
if (event.target.id == 'previous-attendance' || event.target.id == 'previous-attendance_i') {
weekAttendance -= 1
}
else if (event.target.id == 'next-attendance' || event.target.id == 'next-attendance_i') {
weekAttendance += 1
}
document.querySelector('#content').innerHTML = 'Here is attendance (in my imagination)';
cookies_data = sessionStorage.getItem('cookies_data');
document.querySelector('#content').innerHTML += '<button id="previous-attendance" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-attendance_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-attendance" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-attendance_i">keyboard_arrow_right</i></button>';
const left_attendance_ = document.querySelector('#previous-attendance');
const right_attendance_ = document.querySelector('#next-attendance');
left_attendance_.addEventListener('click', getAttendance);
right_attendance_.addEventListener('click', getAttendance);
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/attendance', {
method: 'POST',
@ -13,7 +25,7 @@ const getAttendance = () => {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
body: JSON.stringify({"cookies": cookies_data, "week": weekAttendance})
}).then(response => response.json()).then(data => {
console.log(data);
})

View file

@ -1,9 +1,22 @@
const exams_ = document.querySelector('#exams_');
myStorage = window.sessionStorage;
weekExams = 0
const getExams = () => {
const getExams = (event) => {
if (event.target.id == 'previous-exams' || event.target.id == 'previous-exams_i') {
weekExams -= 1
}
else if (event.target.id == 'next-exams' || event.target.id == 'next-exams_i') {
weekExams += 1
}
document.querySelector('#content').innerHTML = 'Here is exams (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-exams" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-exams_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-exams" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-exams_i">keyboard_arrow_right</i></button>';
const left_exams_ = document.querySelector('#previous-exams');
const right_exams_ = document.querySelector('#next-exams');
left_exams_.addEventListener('click', getExams);
right_exams_.addEventListener('click', getExams);
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/exams', {
@ -13,7 +26,7 @@ const getExams = () => {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
body: JSON.stringify({"cookies": cookies_data, "week": weekExams})
}).then(response => response.json()).then(data => {
console.log(data)
})

View file

@ -1,9 +1,22 @@
const homeworks_ = document.querySelector('#homeworks_');
myStorage = window.sessionStorage;
weekHomeworks = 0
const getHomeworks = () => {
const getHomeworks = (event) => {
if (event.target.id == 'previous-homeworks' || event.target.id == 'previous-homeworks_i') {
weekHomeworks -= 1
}
else if (event.target.id == 'next-homeworks' || event.target.id == 'next-homeworks_i') {
weekHomeworks += 1
}
document.querySelector('#content').innerHTML = 'Here is homeworks (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-homeworks" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-homeworks_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-homeworks" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-homeworks_i">keyboard_arrow_right</i></button>';
const left_homeworks_ = document.querySelector('#previous-homeworks');
const right_homeworks_ = document.querySelector('#next-homeworks');
left_homeworks_.addEventListener('click', getHomeworks);
right_homeworks_.addEventListener('click', getHomeworks);
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/homeworks', {
@ -13,7 +26,7 @@ const getHomeworks = () => {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
body: JSON.stringify({"cookies": cookies_data, "week": weekHomeworks})
}).then(response => response.json()).then(data => {
console.log(data);
})

View file

@ -5,7 +5,7 @@ myStorage = window.sessionStorage;
const studentName = () => {
const cookies_data = JSON.parse(sessionStorage.getItem('cookies_data'))
name_.innerHTML = cookies_data['data']['register_r']['data'][0]['UczenImie']+' '+cookies_data['data']['register_r']['data'][0]['UczenImie2']+' '+cookies_data['data']['register_r']['data'][0]['UczenNazwisko']
name_.innerHTML = cookies_data['data']['students']['data'][0]['UczenImie']+' '+cookies_data['data']['students']['data'][0]['UczenImie2']+' '+cookies_data['data']['students']['data'][0]['UczenNazwisko']
};
const studentEmail = () => {

View file

@ -0,0 +1,46 @@
const stats_ = document.querySelector('#stats_');
myStorage = window.sessionStorage;
const showMenu = () => {
document.querySelector('#content').innerHTML = '<button id="partial" class="waves-light waves-effect btn red darken-1">OCENY CZĄSTKOWE</button>';
document.querySelector('#content').innerHTML += '<button id="year" class="waves-light waves-effect btn red darken-1">OCENY ROCZNE</button>';
const partial_ = document.querySelector('#partial');
const year_ = document.querySelector('#year');
partial_.addEventListener('click', getPartial);
year_.addEventListener('click', getYear);
}
const getPartial = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/stats/partial', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data)
})
}
const getYear = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/stats/year', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data)
})
}
stats_.addEventListener('click', showMenu);

View file

@ -1,9 +1,22 @@
const timetable_ = document.querySelector('#timetable_');
myStorage = window.sessionStorage;
weekTimetable = 0
const getTimetable = () => {
const getTimetable = (event) => {
if (event.target.id == 'previous-timetable' || event.target.id == 'previous-timetable_i') {
weekTimetable -= 1
}
else if (event.target.id == 'next-timetable' || event.target.id == 'next-timetable_i') {
weekTimetable += 1
}
document.querySelector('#content').innerHTML = 'Here is timetable (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-timetable" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-timetable_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-timetable" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-timetable_i">keyboard_arrow_right</i></button>';
const left_timetable_ = document.querySelector('#previous-timetable');
const right_timetable_ = document.querySelector('#next-timetable');
left_timetable_.addEventListener('click', getTimetable);
right_timetable_.addEventListener('click', getTimetable);
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/timetable', {
@ -13,7 +26,7 @@ const getTimetable = () => {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
body: JSON.stringify({"cookies": cookies_data, "week": weekTimetable})
}).then(response => response.json()).then(data => {
console.log(data)
})

View file

@ -10,7 +10,6 @@
</head>
<body>
<div id="content">
</div>
<script src={% static 'frontend/content.js' %}></script>
</body>

Binary file not shown.

View file

@ -1,5 +1,6 @@
cd frontend
start npm run watch
cd ..
cls
python manage.py runserver
@echo off
cd batch
start webpack.exe

View file

@ -39,14 +39,14 @@ class TestViews(TestCase):
self.assertEquals(response.status_code, 200)
students = cookies_data['data']['register_r']['data']
students = cookies_data['data']['students']['data']
#JAN
jan_data = students[0]
cookies_data['data']['register_r']['data'] = [jan_data]
cookies_data['data']['students']['data'] = [jan_data]
get_data_test(self.client, cookies_data, self.assertEquals)
#JOANNA
joanna_data = students[3]
cookies_data['data']['register_r']['data'] = [joanna_data]
cookies_data['data']['students']['data'] = [joanna_data]
get_data_test(self.client, cookies_data, self.assertEquals)
log_out_test(self.client, self.assertEquals)
@ -57,19 +57,19 @@ def get_data_test(client, cookies_data, assertEquals):
assertEquals(response.status_code, 200)
#TIMETABLE
response = client.post(reverse('timetable'), content_type='application/xml', data=json.dumps(cookies_data))
response = client.post(reverse('timetable'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200)
#EXAMS
response = client.post(reverse('exams'), content_type='application/xml', data=json.dumps(cookies_data))
response = client.post(reverse('exams'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200)
#HOMEWORKS
response = client.post(reverse('homeworks'), content_type='application/xml', data=json.dumps(cookies_data))
response = client.post(reverse('homeworks'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200)
#ATTENDANCE
response = client.post(reverse('attendance'), content_type='application/xml', data=json.dumps(cookies_data))
response = client.post(reverse('attendance'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
assertEquals(response.status_code, 200)
#NOTES
@ -120,6 +120,15 @@ def get_data_test(client, cookies_data, assertEquals):
response = client.post(reverse('student_data'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200)
#STATS
#PARTIAL
response = client.post(reverse('partial'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200)
#YEAR
response = client.post(reverse('year'), content_type='application/xml', data=json.dumps(cookies_data))
assertEquals(response.status_code, 200)
#SEND MESSAGE
for recipient in recipients:
send_data = {

View file

@ -17,14 +17,14 @@ from django.urls import path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from frontend.views import default_view, content_view, account_manager_view
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard, recipients, send, message_content, student_data, log_out
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard, recipients, send, message_content, student_data, log_out, partial, year
urlpatterns = [
#views
path('', default_view, name='home'),
path('content/', content_view, name='content'),
path('account-manager/', account_manager_view, name='account_manager'),
#api
#API
path('api/login', login, name='login'),
path('api/grades', grades, name='grades'),
path('api/timetable', timetable, name='timetable'),
@ -36,6 +36,9 @@ urlpatterns = [
path('api/dashboard', dashboard, name='dashboard'),
path('api/student_data', student_data, name='student_data'),
path('api/log_out', log_out, name='log_out'),
#STATS
path('api/stats/partial', partial, name='partial'),
path('api/stats/year', year, name='year'),
#MOBILE ACCESS
path('api/mobile/registered', registered_devices, name='registered_devices'),
path('api/mobile/register', register_device_, name='register_device'),