Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
ef7481ed
Commit
ef7481ed
authored
6 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Provide UserInformation
parent
1cbf31c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!86
Merge school-apps
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
schoolapps/dashboard/views.py
+4
-1
4 additions, 1 deletion
schoolapps/dashboard/views.py
schoolapps/templates/partials/header.html
+0
-6
0 additions, 6 deletions
schoolapps/templates/partials/header.html
schoolapps/userinformation.py
+54
-0
54 additions, 0 deletions
schoolapps/userinformation.py
with
58 additions
and
7 deletions
schoolapps/dashboard/views.py
+
4
−
1
View file @
ef7481ed
...
...
@@ -4,7 +4,7 @@ from django.urls import reverse
from
.models
import
Activity
,
register_notification
# from .apps import DashboardConfig
from
mailer
import
send_mail_with_template
from
userinformation
import
UserInformation
# Create your views here.
...
...
@@ -15,6 +15,9 @@ def index(request):
# act = Activity(title="Dashboard aufgerufen", description="Sie haben das Dashboard aufgerufen.",
# app=DashboardConfig.verbose_name, user=request.user)
# act.save()
print
(
request
.
user
)
# UserInformation.user_classes(request.user)
print
(
UserInformation
.
user_courses
(
request
.
user
))
# Load activities
activities
=
Activity
.
objects
.
filter
(
user
=
request
.
user
).
order_by
(
'
-created_at
'
)[:
5
]
...
...
This diff is collapsed.
Click to expand it.
schoolapps/templates/partials/header.html
+
0
−
6
View file @
ef7481ed
...
...
@@ -128,12 +128,6 @@
<i
class=
"material-icons"
>
exit_to_app
</i>
Abmelden
</a>
</li>
<li>
{{ user.groups.all }}
{% for group in user.groups.all %}
{{ group }}
{% endfor %}
</li>
{% endif %}
</ul>
</header>
This diff is collapsed.
Click to expand it.
schoolapps/userinformation.py
0 → 100644
+
54
−
0
View file @
ef7481ed
import
re
class
UserInformation
:
OTHER
=
0
TEACHER
=
1
STUDENT
=
2
@staticmethod
def
regexr
(
regex
,
groups
):
reg
=
re
.
compile
(
regex
)
return
reg
.
findall
(
"
\n
"
.
join
(
groups
))
@staticmethod
def
user_groups
(
user
):
raw_groups
=
user
.
groups
.
all
()
groups
=
[
group
.
name
for
group
in
raw_groups
]
print
(
groups
)
return
groups
@staticmethod
def
user_type
(
user
):
groups
=
UserInformation
.
user_groups
(
user
)
if
"
teachers
"
in
groups
:
return
UserInformation
.
TEACHER
elif
"
students
"
in
groups
:
return
UserInformation
.
STUDENT
else
:
return
UserInformation
.
OTHER
@staticmethod
def
user_classes
(
user
):
groups
=
UserInformation
.
user_groups
(
user
)
classes
=
UserInformation
.
regexr
(
r
"
class_(\w{1,3})
"
,
groups
)
return
classes
@staticmethod
def
user_courses
(
user
):
groups
=
UserInformation
.
user_groups
(
user
)
classes
=
UserInformation
.
regexr
(
r
"
course_(.{1,10})
"
,
groups
)
return
classes
@staticmethod
def
user_subjects
(
user
):
groups
=
UserInformation
.
user_groups
(
user
)
classes
=
UserInformation
.
regexr
(
r
"
subject_(\w{1,3})
"
,
groups
)
return
classes
@staticmethod
def
has_wifi
(
user
):
groups
=
UserInformation
.
user_groups
(
user
)
if
"
teachers
"
in
groups
or
"
students-wifi
"
in
groups
:
return
True
return
False
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment