Getting permissions value
This commit is contained in:
parent
d2c0a7edca
commit
74d25f0ac3
7 changed files with 85 additions and 4 deletions
38
app/API/dashboard.py
Normal file
38
app/API/dashboard.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
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)
|
||||||
|
permissionsValue = re.search("permissions: '(.)*'", index.text)
|
||||||
|
permissionsValue = permissionsValue.group()
|
||||||
|
print(permissionsValue)
|
||||||
|
|
||||||
|
return {"dupa": "dupa"}
|
|
@ -44,11 +44,11 @@ def send(url, data, fail, diary_url, symbol, s):
|
||||||
if diary_url == 'http://cufs.fakelog.cf/':
|
if diary_url == 'http://cufs.fakelog.cf/':
|
||||||
oun = 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458'
|
oun = 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458'
|
||||||
|
|
||||||
cookies = get_cookies(symbol, oun, s)
|
cookies = get_cookies(symbol, oun, s, diary_url)
|
||||||
|
|
||||||
return cookies
|
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_r = s.post(oun+'/UczenDziennik.mvc/Get')
|
||||||
register_id = register_r.json()['data'][0]['Okresy'][0]['Id']
|
register_id = register_r.json()['data'][0]['Okresy'][0]['Id']
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@ def get_cookies(symbol, oun, s):
|
||||||
'date': str(date),
|
'date': str(date),
|
||||||
'school_year': school_year,
|
'school_year': school_year,
|
||||||
'symbol': symbol,
|
'symbol': symbol,
|
||||||
's': s.cookies.get_dict()
|
's': s.cookies.get_dict(),
|
||||||
|
'diary_url': diary_url
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
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.homeworks import get_homeworks
|
||||||
from .API.mobile_access import get_registered_devices, register_device
|
from .API.mobile_access import get_registered_devices, register_device
|
||||||
from .API.school_data import get_school_data
|
from .API.school_data import get_school_data
|
||||||
|
from .API.dashboard import get_dashboard
|
||||||
|
|
||||||
#views
|
#views
|
||||||
def default_view(request, *args, **kwargs):
|
def default_view(request, *args, **kwargs):
|
||||||
|
@ -207,3 +208,16 @@ def school_data(request, *args, **kwargs):
|
||||||
return JsonResponse(school_data)
|
return JsonResponse(school_data)
|
||||||
else:
|
else:
|
||||||
return redirect('../')
|
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){
|
switch(diary){
|
||||||
case 'Fakelog':
|
case 'Fakelog':
|
||||||
var diaryUrl = 'http://cufs.fakelog.cf/';
|
var diaryUrl = 'http://cufs.fakelog.cf/';
|
||||||
|
sessionStorage.setItem('diary_url', 'http://cufs.fakelog.cf/');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Vulcan UONET+':
|
case 'Vulcan UONET+':
|
||||||
var diaryUrl = 'https://cufs.vulcan.net.pl/';
|
var diaryUrl = 'https://cufs.vulcan.net.pl/';
|
||||||
|
sessionStorage.setItem('diary_url', 'https://cufs.vulcan.net.pl/');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
data = {
|
data = {
|
||||||
|
@ -35,6 +37,7 @@ const login = () => {
|
||||||
sessionStorage.setItem('cookies_data', JSON.stringify(data));
|
sessionStorage.setItem('cookies_data', JSON.stringify(data));
|
||||||
sessionStorage.setItem('csrfcookie', csrfcookie());
|
sessionStorage.setItem('csrfcookie', csrfcookie());
|
||||||
sessionStorage.setItem('email', document.querySelector('#id_loginName').value);
|
sessionStorage.setItem('email', document.querySelector('#id_loginName').value);
|
||||||
|
sessionStorage.setItem('symbol', document.querySelector('#id_Symbol').value);
|
||||||
window.location.href = "/content/";
|
window.location.href = "/content/";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<link rel="stylesheet" href="{% static 'css/start.css' %}" type="text/css" />
|
<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/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/dist/out-grades.js' %}" type="text/javascript" defer></script>
|
||||||
<script src="{% static 'js/timetable.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>
|
<script src="{% static 'js/exams.js' %}" type="text/javascript" defer></script>
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
<a href="#name"><span class="white-text name" id='name'>John Doe</span></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 href="#email"><span class="white-text email" id='email'>jdandturk@gmail.com</span></a>
|
||||||
</div></li>
|
</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="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="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>
|
<li><a id="exams_" class='option'><i class="material-icons">event</i>Sprawdziany</a></li>
|
||||||
|
|
|
@ -17,7 +17,7 @@ from django.urls import path
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
|
|
||||||
from app.views import default_view, content_view
|
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 = [
|
urlpatterns = [
|
||||||
#views
|
#views
|
||||||
|
@ -32,6 +32,7 @@ urlpatterns = [
|
||||||
path('api/attendance', attendance, name='attendance'),
|
path('api/attendance', attendance, name='attendance'),
|
||||||
path('api/notes', notes, name='notes'),
|
path('api/notes', notes, name='notes'),
|
||||||
path('api/school_data', school_data, name='school_data'),
|
path('api/school_data', school_data, name='school_data'),
|
||||||
|
path('api/dashboard', dashboard, name='dashboard'),
|
||||||
#MOBILE ACCESS
|
#MOBILE ACCESS
|
||||||
path('api/mobile/registered', registered_devices, name='registered_devices'),
|
path('api/mobile/registered', registered_devices, name='registered_devices'),
|
||||||
path('api/mobile/register', register_device_, name='register_device'),
|
path('api/mobile/register', register_device_, name='register_device'),
|
||||||
|
|
Loading…
Reference in a new issue