Skip to content
Snippets Groups Projects
Commit 0b614855 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Show information about user

parent 7b4c4996
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -3,10 +3,31 @@
<main>
<p class="flow-text">Willkommen bei SchoolApps!</p>
<div class="row">
<div class="col s12">
<h5>Dein Status</h5>
</div>
<div class="col"><i class="material-icons left green-text">check_circle</i>{{ user_type_formatted }}</div>
{% if user_type == 1 or user_type == 2 %}
<div class="col"><i class="material-icons left green-text">check_circle</i>Deine
Klassen: {{ classes|join:", " }}</div>
<div class="col"><i class="material-icons left green-text">check_circle</i>Deine
Kurse: {{ courses|join:", " }}</div>
{% endif %}
{% if user_type == 1 %}
<div class="col"><i class="material-icons left green-text">check_circle</i>Deine
Fächer: {{ subjects|join:", " }}</div>
{% endif %}
{% if user_type == 1 or has_wifi == True %}
<div class="col"><i class="material-icons left green-text">check_circle</i>WLAN</div>
{% else %}
<div class="col"><i class="material-icons left red-text">close</i>Kein WLAN</div>
{% endif %}
</div>
<div class="row">
<div class="col s12 m6">
<h4>Letzte Aktivitäten</h4>
<h5>Letzte Aktivitäten</h5>
{% if activities %}
<ul class="collection">
......@@ -29,7 +50,7 @@
</div>
<div class="col s12 m6">
<h4>Letzte Benachrichtigungen</h4>
<h5>Letzte Benachrichtigungen</h5>
{% if notifications %}
<ul class="collection">
......
......@@ -6,6 +6,7 @@ from .models import Activity, register_notification
from mailer import send_mail_with_template
from userinformation import UserInformation
# Create your views here.
@login_required
......@@ -25,9 +26,16 @@ def index(request):
# Load notifications
notifications = request.user.notifications.all().filter(user=request.user).order_by('-created_at')
# user_type = UserInformation.user_type(request.user)
context = {
'activities': activities,
'notifications': notifications,
'user_type': UserInformation.user_type(request.user),
'user_type_formatted': UserInformation.user_type_formatted(request.user),
'classes': UserInformation.user_classes(request.user),
'courses': UserInformation.user_courses(request.user),
'subjects': UserInformation.user_subjects(request.user),
'has_wifi': UserInformation.user_has_wifi(request.user)
}
return render(request, 'dashboard/index.html', context)
......
......@@ -28,6 +28,16 @@ class UserInformation:
else:
return UserInformation.OTHER
@staticmethod
def _user_type_formatted(user_type):
return "Lehrer" if user_type == UserInformation.TEACHER else (
"Schüler" if user_type == UserInformation.STUDENT else "Sonstiges Mitglied")
@staticmethod
def user_type_formatted(user):
user_type = UserInformation.user_type(user)
return UserInformation._user_type_formatted(user_type)
@staticmethod
def user_classes(user):
groups = UserInformation.user_groups(user)
......@@ -47,7 +57,7 @@ class UserInformation:
return classes
@staticmethod
def has_wifi(user):
def user_has_wifi(user):
groups = UserInformation.user_groups(user)
if "teachers" in groups or "students-wifi" in groups:
return True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment