Merge branch 'master' into feature/finish_grades
This commit is contained in:
commit
bc0a1f6500
7 changed files with 94 additions and 30 deletions
31
app/API/school_data.py
Normal file
31
app/API/school_data.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import json
|
||||
import requests
|
||||
|
||||
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']}"
|
||||
})
|
||||
|
||||
headers = {
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept': '*/*',
|
||||
'Connection': 'keep-alive',
|
||||
"User-Agent": "Wulkanowy-web :)"
|
||||
}
|
||||
|
||||
school_data = requests.post(oun+'/SzkolaINauczyciele.mvc/Get', headers=headers, cookies=cookies)
|
||||
|
||||
return school_data.json()
|
19
app/views.py
19
app/views.py
|
@ -15,6 +15,7 @@ from .API.attendance import get_attendance
|
|||
from .API.messages import get_received_messages, get_sent_messages, get_deleted_messages
|
||||
from .API.homeworks import get_homeworks
|
||||
from .API.mobile_access import get_registered_devices, register_device
|
||||
from .API.school_data import get_school_data
|
||||
|
||||
#views
|
||||
def default_view(request, *args, **kwargs):
|
||||
|
@ -161,7 +162,7 @@ def received_messages(request, *args, **kwargs):
|
|||
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)
|
||||
return JsonResponse(received_messages, safe=False)
|
||||
return JsonResponse(received_messages)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
|
@ -176,7 +177,7 @@ def sent_messages(request, *args, **kwargs):
|
|||
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)
|
||||
return JsonResponse(sent_messages, safe=False)
|
||||
return JsonResponse(sent_messages)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
|
@ -191,6 +192,18 @@ def deleted_messages(request, *args, **kwargs):
|
|||
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)
|
||||
return JsonResponse(deleted_messages, safe=False)
|
||||
return JsonResponse(deleted_messages)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
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']
|
||||
oun = data['data']['oun']
|
||||
s = data['data']['s']
|
||||
school_data = get_school_data(register_id, register_r, oun, s)
|
||||
return JsonResponse(school_data)
|
||||
else:
|
||||
return redirect('../')
|
|
@ -33,7 +33,8 @@ const login = () => {
|
|||
if(data['success']){
|
||||
myStorage = window.sessionStorage;
|
||||
sessionStorage.setItem('cookies_data', JSON.stringify(data));
|
||||
sessionStorage.setItem('csrfcookie', csrfcookie())
|
||||
sessionStorage.setItem('csrfcookie', csrfcookie());
|
||||
sessionStorage.setItem('email', document.querySelector('#id_loginName').value);
|
||||
window.location.href = "/content/";
|
||||
}
|
||||
else{
|
||||
|
|
22
files/js/school_data.js
Normal file
22
files/js/school_data.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const school_data = document.querySelector('#school_data_');
|
||||
|
||||
myStorage = window.sessionStorage;
|
||||
|
||||
const getSchoolData = () => {
|
||||
document.querySelector('#content').innerHTML = 'Here is school data (in my imagination)';
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/school_data', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': csrfcookie_
|
||||
},
|
||||
body: cookies_data
|
||||
}).then(response => response.json()).then(data => {
|
||||
console.log(data);
|
||||
})
|
||||
}
|
||||
|
||||
school_data_.addEventListener('click', getSchoolData);
|
|
@ -1,22 +1,16 @@
|
|||
function grade_action(id) {
|
||||
var x = document.getElementById(id);
|
||||
var element = x.getElementsByTagName('li')[0];
|
||||
if(element.style.display == 'none'){
|
||||
element.style.display = 'block';
|
||||
}
|
||||
else if(element.style.display == 'block'){
|
||||
element.style.display = 'none';
|
||||
}
|
||||
}
|
||||
const name_ = document.querySelector('#name');
|
||||
const email_ = document.querySelector('#email');
|
||||
|
||||
function change_message_content(id) {
|
||||
$.ajax({
|
||||
url: '/change_messages_content/',
|
||||
data: {
|
||||
'id': id
|
||||
},
|
||||
success: function(data) {
|
||||
document.querySelector('#messages_content').innerHTML = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
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']
|
||||
};
|
||||
|
||||
const studentEmail = () => {
|
||||
email_.innerHTML = sessionStorage.getItem('email')
|
||||
};
|
||||
|
||||
window.addEventListener('load', studentName);
|
||||
window.addEventListener('load', studentEmail);
|
|
@ -6,8 +6,8 @@
|
|||
<meta charset="utf-8">
|
||||
<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" ></script>
|
||||
<script src="{% static 'js/dist/out-grades.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/start.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'js/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>
|
||||
<script src="{% static 'js/notes.js' %}" type="text/javascript" defer></script>
|
||||
|
@ -15,6 +15,7 @@
|
|||
<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>
|
||||
<script src="{% static 'js/school_data.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,8 +42,8 @@
|
|||
<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">John Doe</span></a>
|
||||
<a href="#email"><span class="white-text email">jdandturk@gmail.com</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>
|
||||
</div></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>
|
||||
|
@ -51,6 +52,7 @@
|
|||
<li><a id="attendance_" class='option'><i class="material-icons">date_range</i>Frekwencja</a></li>
|
||||
<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>
|
||||
<ul id='dropdown1' class='dropdown-content'>
|
||||
<li><a id='received_' class='option'>Odebrane</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
|
||||
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data
|
||||
|
||||
urlpatterns = [
|
||||
#views
|
||||
|
@ -31,6 +31,7 @@ urlpatterns = [
|
|||
path('api/homeworks', homeworks, name='homeworks'),
|
||||
path('api/attendance', attendance, name='attendance'),
|
||||
path('api/notes', notes, name='notes'),
|
||||
path('api/school_data', school_data, name='school_data'),
|
||||
#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