commit
26ba0fee35
8 changed files with 104 additions and 9 deletions
52
app/API/dashboard.py
Normal file
52
app/API/dashboard.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
import json
|
||||
import requests
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
def get_dashboard(register_id, register_r, s, diary_url, symbol):
|
||||
cookies = s
|
||||
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 :)"
|
||||
}
|
||||
|
||||
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_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)
|
||||
|
||||
return_data = {
|
||||
"last_notes": last_notes.json(),
|
||||
"free_days": free_days.json(),
|
||||
"lucky_number": lucky_number.json()
|
||||
}
|
||||
|
||||
return return_data
|
|
@ -44,11 +44,11 @@ def send(url, data, fail, diary_url, symbol, s):
|
|||
if diary_url == 'http://cufs.fakelog.cf/':
|
||||
oun = 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458'
|
||||
|
||||
cookies = get_cookies(symbol, oun, s)
|
||||
cookies = get_cookies(symbol, oun, s, diary_url)
|
||||
|
||||
return cookies
|
||||
|
||||
def get_cookies(symbol, oun, s):
|
||||
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']
|
||||
|
||||
|
@ -76,7 +76,8 @@ def get_cookies(symbol, oun, s):
|
|||
'date': str(date),
|
||||
'school_year': school_year,
|
||||
'symbol': symbol,
|
||||
's': s.cookies.get_dict()
|
||||
's': s.cookies.get_dict(),
|
||||
'diary_url': diary_url
|
||||
}
|
||||
|
||||
return data
|
14
app/views.py
14
app/views.py
|
@ -16,6 +16,7 @@ from .API.messages import get_received_messages, get_sent_messages, get_deleted_
|
|||
from .API.homeworks import get_homeworks
|
||||
from .API.mobile_access import get_registered_devices, register_device
|
||||
from .API.school_data import get_school_data
|
||||
from .API.dashboard import get_dashboard
|
||||
|
||||
#views
|
||||
def default_view(request, *args, **kwargs):
|
||||
|
@ -205,5 +206,18 @@ def school_data(request, *args, **kwargs):
|
|||
s = data['data']['s']
|
||||
school_data = get_school_data(register_id, register_r, oun, s)
|
||||
return JsonResponse(school_data)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
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']
|
||||
s = data['data']['s']
|
||||
diary_url = data['data']['diary_url']
|
||||
symbol = data['data']['symbol']
|
||||
dashboard = get_dashboard(register_id, register_r, s, diary_url, symbol)
|
||||
return JsonResponse(dashboard)
|
||||
else:
|
||||
return redirect('../')
|
22
files/js/dashboard.js
Normal file
22
files/js/dashboard.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const start_ = document.querySelector('#dashboard_');
|
||||
|
||||
const getDashboard = () => {
|
||||
document.querySelector('#content').innerHTML = 'Dashboard';
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/dashboard', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': csrfcookie_
|
||||
},
|
||||
body: cookies_data
|
||||
}).then(response => response.json()).then(data => {
|
||||
console.log(data);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
window.addEventListener('load', getDashboard);
|
||||
start_.addEventListener('click', getDashboard);
|
|
@ -9,10 +9,12 @@ const login = () => {
|
|||
switch(diary){
|
||||
case 'Fakelog':
|
||||
var diaryUrl = 'http://cufs.fakelog.cf/';
|
||||
sessionStorage.setItem('diary_url', 'http://cufs.fakelog.cf/');
|
||||
break;
|
||||
|
||||
case 'Vulcan UONET+':
|
||||
var diaryUrl = 'https://cufs.vulcan.net.pl/';
|
||||
sessionStorage.setItem('diary_url', 'https://cufs.vulcan.net.pl/');
|
||||
break;
|
||||
}
|
||||
data = {
|
||||
|
@ -35,6 +37,7 @@ const login = () => {
|
|||
sessionStorage.setItem('cookies_data', JSON.stringify(data));
|
||||
sessionStorage.setItem('csrfcookie', csrfcookie());
|
||||
sessionStorage.setItem('email', document.querySelector('#id_loginName').value);
|
||||
sessionStorage.setItem('symbol', document.querySelector('#id_Symbol').value);
|
||||
window.location.href = "/content/";
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"description": "🌋 Przeglądarkowy klient dzienniczka VULCAN UONET+ dla ucznia i rodzica",
|
||||
"main": "index.js",
|
||||
"browserslist": [
|
||||
"defaults"
|
||||
"defaults"
|
||||
],
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link rel="stylesheet" href="{% static 'css/start.css' %}" type="text/css" />
|
||||
<script src="{% static 'js/start.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/dashboard.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/dist/out-grades.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/timetable.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/exams.js' %}" type="text/javascript" defer></script>
|
||||
|
@ -41,10 +42,11 @@
|
|||
<div class="background">
|
||||
<img src="{% static 'images/wallpaper.jpg' %}" width="300" height="176">
|
||||
</div>
|
||||
<a href="#user"><img class="circle" src="{% static 'images/27146352.png' %}"></a>
|
||||
<a href="#name"><span class="white-text name" id='name'>John Doe</span></a>
|
||||
<a href="#email"><span class="white-text email" id='email'>jdandturk@gmail.com</span></a>
|
||||
<a><img class="circle" src="{% static 'images/27146352.png' %}"></a>
|
||||
<a><span class="white-text name" id='name'>Imie Imie2 Nazwisko</span></a>
|
||||
<a><span class="white-text email" id='email'>E-mail</span></a>
|
||||
</div></li>
|
||||
<li><a id="dashboard_" class='option'><i class="material-icons">dashboard</i>Start</a></li>
|
||||
<li><a id="grades_" class='option'><i class="material-icons">filter_6</i>Oceny</a></li>
|
||||
<li><a id="timetable_" class='option'><i class="material-icons">event_note</i>Plan Lekcji</a></li>
|
||||
<li><a id="exams_" class='option'><i class="material-icons">event</i>Sprawdziany</a></li>
|
||||
|
@ -53,7 +55,7 @@
|
|||
<li><a id="notes_" class='option'><i class="material-icons">emoji_events</i>Uwagi i Osiągnięcia</a></li>
|
||||
<li><a id="mobile_access_" class='option'><i class="material-icons">devices</i>Dostęp Mobilny</a></li>
|
||||
<li><a id="school_data_" class='option'><i class="material-icons">business</i>Szkoła i Nauczyciele</a></li>
|
||||
<li><a id="messages_" class="dropdown-trigger" href="#!" data-target="dropdown1"><i class="material-icons">email</i>Wiadomości</a></li>
|
||||
<li><a id="messages_" class="dropdown-trigger" data-target="dropdown1"><i class="material-icons">email</i>Wiadomości</a></li>
|
||||
<ul id='dropdown1' class='dropdown-content'>
|
||||
<li><a id='received_' class='option'>Odebrane</a></li>
|
||||
<li><a id='sent_' class='option'>Wysłane</a></li>
|
||||
|
|
|
@ -17,7 +17,7 @@ from django.urls import path
|
|||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
|
||||
from app.views import default_view, content_view
|
||||
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data
|
||||
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard
|
||||
|
||||
urlpatterns = [
|
||||
#views
|
||||
|
@ -32,6 +32,7 @@ urlpatterns = [
|
|||
path('api/attendance', attendance, name='attendance'),
|
||||
path('api/notes', notes, name='notes'),
|
||||
path('api/school_data', school_data, name='school_data'),
|
||||
path('api/dashboard', dashboard, name='dashboard'),
|
||||
#MOBILE ACCESS
|
||||
path('api/mobile/registered', registered_devices, name='registered_devices'),
|
||||
path('api/mobile/register', register_device_, name='register_device'),
|
||||
|
|
Loading…
Reference in a new issue