Merge pull request #23 from wulkanowy/feature/account_manager

Account manager
This commit is contained in:
Zaptyp 2021-01-26 12:20:22 +01:00 committed by GitHub
commit 54c0e4dc35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 3 deletions

View file

@ -43,7 +43,6 @@ def login(request, *args, **kwargs):
try:
request.session[request.session.session_key] = Fernet.generate_key().decode('utf-8')
rkey = Fernet(bytes(request.session[request.session.session_key], 'utf-8'))
print(bytes(request.session[request.session.session_key], 'utf-8'))
break
except KeyError:
continue

View file

@ -0,0 +1,40 @@
var cookies_data = JSON.parse(sessionStorage.getItem('cookies_data'));
students = cookies_data.data.register_r.data;
const displayData = () => {
var primary = '';
students.forEach((student) =>{
if(student.UczenNazwisko+' '+student.UczenImie2+' '+student.UczenImie+' '+student.UczenSymbol != primary){
primary = student.UczenNazwisko+' '+student.UczenImie2+' '+student.UczenImie+' '+student.UczenSymbol;
document.querySelector("#content").innerHTML += `<p>
<label>
<input class="with-gap" name="group1" value='`+student.UczenPelnaNazwa+`' type="radio" checked />
<span>`+student.UczenPelnaNazwa+`</span>
</label>
</p>`
}
})
document.querySelector("#content").innerHTML += `<button id="button" class="waves-light waves-effect btn red darken-1">LOGIN</button>`
const button_ = document.querySelector("#button")
button_.addEventListener('click', logIn)
}
const logIn = () => {
var ele = document.getElementsByName('group1');
for(i = 0; i < ele.length; i++) {
if(ele[i].checked){
studentName = ele[i].value;
students.forEach((student) => {
if(student.UczenPelnaNazwa == studentName){
cookies_data.data.register_r.data = [student]
sessionStorage.setItem('cookies_data', JSON.stringify(cookies_data));
window.location.href = '/content/'
}
})
}
}
}
window.addEventListener('load', displayData)

View file

@ -38,7 +38,7 @@ const login = () => {
sessionStorage.setItem('csrfcookie', csrfcookie());
sessionStorage.setItem('email', document.querySelector('#id_loginName').value);
sessionStorage.setItem('symbol', document.querySelector('#id_Symbol').value);
window.location.href = "/content/";
window.location.href = "/account-manager/";
}
else{
document.querySelector('#error').innerHTML = 'Nieprawidłowy login, hasło lub symbol';

View file

@ -0,0 +1,42 @@
{% load static %}
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{% static 'frontend/css/style.css' %}">
<link rel="shortcut icon" href="{% static 'frontend/images/27146352.png' %}">
<link href="https://fonts.googleapis.com/css2?family=Lora:wght@500&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="{% static 'frontend/css/materialize.min.css' %}" media="screen,projection"/>
<script src="{% static 'frontend/js/materializecss/materialize.min.js' %}"></script>
<title>Wulkanowy | Aplikacja ucznia i rodzica</title>
</head>
<body>
<div data-v-cd2b8d62 data-v-09be56d6 id="container">
<div id="row">
<h1 data-v-cd2b8d62="" class="logo">
<img data-v-cd2b8d62 src="{% static 'frontend/images/wulkanowy-full-flat.4ff8222a.svg' %}" alt="Wulkanowy">
</h1>
<div class="card white darken-1">
<div id="content" class="card-content">
</div>
</div>
</div>
<script type="text/javascript" src="{% static 'frontend/js/dist/out-account_manager.js' %}" defer></script>
<script>
var elem = document.querySelector('.tabs');
var options = {}
var instance = M.Tabs.init(elem, options);
</script>
</body>
</html>

View file

@ -7,5 +7,11 @@ def default_view(request, *args, **kwargs):
def content_view(request, *args, **kwargs):
if request.session.has_key('is_logged'):
return render(request, 'frontend/content.html')
else:
return redirect('../')
def account_manager_view(request, *args, **kwargs):
if request.session.has_key('is_logged'):
return render(request, 'frontend/account-manager.html')
else:
return redirect('../')

View file

@ -12,6 +12,7 @@ module.exports = {
notes : "./static/frontend/js/notes.js",
start : "./static/frontend/js/start.js",
timetable : "./static/frontend/js/timetable.js",
account_manager : "./static/frontend/js/account-manager.js",
},
output: {
filename: "out-[name].js",

View file

@ -16,13 +16,14 @@ Including another URLconf
from django.urls import path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from frontend.views import default_view, content_view
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
urlpatterns = [
#views
path('', default_view, name='home'),
path('content/', content_view, name='content'),
path('account-manager/', account_manager_view, name='account_manager'),
#api
path('api/login', login, name='login'),
path('api/grades', grades, name='grades'),