merge
This commit is contained in:
commit
5901025aee
6 changed files with 141 additions and 6 deletions
60
app/API/mobile_access.py
Normal file
60
app/API/mobile_access.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
import json
|
||||
import requests
|
||||
|
||||
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']}"
|
||||
})
|
||||
|
||||
headers = {
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
"User-Agent": "Wulkanowy-web :)"
|
||||
}
|
||||
|
||||
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']}"
|
||||
})
|
||||
|
||||
headers = {
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
"User-Agent": "Wulkanowy-web :)"
|
||||
}
|
||||
|
||||
register_data = requests.post(oun+'/RejestracjaUrzadzeniaToken.mvc/Get', headers=headers, cookies=cookies)
|
||||
|
||||
return register_data.json()
|
25
app/views.py
25
app/views.py
|
@ -14,6 +14,7 @@ from .API.notes import get_notes
|
|||
from .API.attendance import get_attendance
|
||||
from .API.messages import get_messages
|
||||
from .API.homeworks import get_homeworks
|
||||
from .API.mobile_access import get_registered_devices, register_device
|
||||
|
||||
#views
|
||||
def default_view(request, *args, **kwargs):
|
||||
|
@ -122,5 +123,29 @@ def notes(request, *args, **kwargs):
|
|||
s = data['data']['s']
|
||||
notes = get_notes(register_id, register_r, oun, s)
|
||||
return JsonResponse(notes)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
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']
|
||||
oun = data['data']['oun']
|
||||
s = data['data']['s']
|
||||
registered = get_registered_devices(register_id, register_r, oun, s)
|
||||
return JsonResponse(registered)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
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']
|
||||
oun = data['data']['oun']
|
||||
s = data['data']['s']
|
||||
register_data = register_device(register_id, register_r, oun, s)
|
||||
return JsonResponse(register_data)
|
||||
else:
|
||||
return redirect('../')
|
|
@ -31,11 +31,6 @@ body {
|
|||
font-family: 'Quicksand', sans-serif;
|
||||
}
|
||||
.option{
|
||||
display: inline;
|
||||
color: white;
|
||||
margin-top: 3.650431902835478167382628592617195404756384%;
|
||||
margin-right: 2.2%;
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
|
41
files/js/mobile_access.js
Normal file
41
files/js/mobile_access.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
const registered_ = document.querySelector('#mobile_access_');
|
||||
|
||||
myStorage = window.sessionStorage;
|
||||
|
||||
const getRegisteredDevices = () => {
|
||||
document.querySelector('#content').innerHTML = '<button id="register_device_">ZAJERESTRUJ URZĄDZENIE</button><div id="register_device_data"></div><br />Here is registered mobile devices (in my imagination)';
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/mobile/registered', {
|
||||
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 register_device_ = document.querySelector('#register_device_');
|
||||
register_device_.addEventListener('click', registerDevice);
|
||||
})
|
||||
}
|
||||
|
||||
const registerDevice = () => {
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/mobile/register', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': csrfcookie_
|
||||
},
|
||||
body: cookies_data
|
||||
}).then(response => response.json()).then(data => {
|
||||
console.log(data);
|
||||
document.querySelector('#register_device_data').innerHTML = data.data.QrCodeImage+'<br /> TOKEN:'+data.data.TokenKey+'<br /> PIN:'+data.data.PIN+'<br /> SYMBOL:'+data.data.CustomerGroup;
|
||||
})
|
||||
}
|
||||
|
||||
registered_.addEventListener('click', getRegisteredDevices);
|
|
@ -14,6 +14,7 @@
|
|||
<script src="{% static 'js/attendance.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/homeworks.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/messages.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/mobile_access.js' %}" type="text/javascript" defer></script>
|
||||
<link rel="shortcut icon" href="{% static 'images/27146352.png' %}">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@500&display=swap" rel="stylesheet">
|
||||
|
@ -41,6 +42,7 @@
|
|||
<a href="#name"><span class="white-text name">John Doe</span></a>
|
||||
<a href="#email"><span class="white-text email">jdandturk@gmail.com</span></a>
|
||||
</div></li>
|
||||
<<<<<<< HEAD
|
||||
<li><a id="grades_">Oceny</a></li>
|
||||
<li><a id="timetable_">Plan Lekcji</a></li>
|
||||
<li><a id="exams_">Sprawdziany</a></li>
|
||||
|
@ -54,6 +56,16 @@
|
|||
<li><a href="#!">Usunięte</a></li>
|
||||
</ul>
|
||||
<li><a id="notes_">Uwagi</a></li>
|
||||
=======
|
||||
<li><a id="grades_" class='option'>Oceny</a></li>
|
||||
<li><a id="timetable_" class='option'>Plan Lekcji</a></li>
|
||||
<li><a id="exams_" class='option'>Sprawdziany</a></li>
|
||||
<li><a id="homeworks_" class='option'>Zadania Domowe</a></li>
|
||||
<li><a id="attendance_" class='option'>Frekwencja</a></li>
|
||||
<li><a id="messages_" class='option'>Wiadomości</a></li>
|
||||
<li><a id="notes_" class='option'>Uwagi</a></li>
|
||||
<li><a id="mobile_access_" class='option'>Dostęp Mobilny</a></li>
|
||||
>>>>>>> b7c706ad482b5705a8aad6e92c31d1bb95d2d735
|
||||
</ul>
|
||||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
|
||||
|
|
|
@ -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
|
||||
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_
|
||||
|
||||
urlpatterns = [
|
||||
#views
|
||||
|
@ -31,6 +31,8 @@ urlpatterns = [
|
|||
path('api/homeworks', homeworks, name='homeworks'),
|
||||
path('api/attendance', attendance, name='attendance'),
|
||||
path('api/notes', notes, name='notes'),
|
||||
path('api/mobile/registered', registered_devices, name='registered_devices'),
|
||||
path('api/mobile/register', register_device_, name='register_device'),
|
||||
]
|
||||
|
||||
urlpatterns += staticfiles_urlpatterns()
|
Loading…
Reference in a new issue