Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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-App-Chronos
Commits
2e401122
Commit
2e401122
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Show events | Get information about user
parent
bb0fe226
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/chronos/migrations/0010_auto_20190901_1040.py
+17
-0
17 additions, 0 deletions
biscuit/apps/chronos/migrations/0010_auto_20190901_1040.py
biscuit/apps/chronos/views.py
+27
-11
27 additions, 11 deletions
biscuit/apps/chronos/views.py
with
44 additions
and
11 deletions
biscuit/apps/chronos/migrations/0010_auto_20190901_1040.py
0 → 100644
+
17
−
0
View file @
2e401122
# Generated by Django 2.2.1 on 2019-09-01 08:40
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
timetable
'
,
'
0009_hint_classes_formatted
'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'
hintclass
'
,
name
=
'
class_id
'
,
field
=
models
.
IntegerField
(),
),
]
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
27
−
11
View file @
2e401122
...
@@ -203,6 +203,28 @@ def plan(request, plan_type, plan_id, regular="", year=timezone.datetime.now().y
...
@@ -203,6 +203,28 @@ def plan(request, plan_type, plan_id, regular="", year=timezone.datetime.now().y
return
render
(
request
,
'
timetable/plan.html
'
,
context
)
return
render
(
request
,
'
timetable/plan.html
'
,
context
)
def
get_type_and_object_of_user
(
user
):
_type
=
UserInformation
.
user_type
(
user
)
if
_type
==
UserInformation
.
TEACHER
:
# Teacher
_type
=
TYPE_TEACHER
shortcode
=
user
.
username
el
=
get_teacher_by_shortcode
(
shortcode
)
plan_id
=
el
.
id
raw_type
=
"
teacher
"
elif
_type
==
UserInformation
.
STUDENT
:
# Student
_type
=
TYPE_CLASS
_name
=
UserInformation
.
user_classes
(
user
)[
0
]
el
=
get_class_by_name
(
_name
)
plan_id
=
el
.
id
raw_type
=
"
class
"
else
:
return
None
,
None
return
_type
,
el
@login_required
@login_required
@permission_required
(
"
timetable.show_plan
"
)
@permission_required
(
"
timetable.show_plan
"
)
def
my_plan
(
request
,
year
=
None
,
month
=
None
,
day
=
None
):
def
my_plan
(
request
,
year
=
None
,
month
=
None
,
day
=
None
):
...
@@ -223,13 +245,9 @@ def my_plan(request, year=None, month=None, day=None):
...
@@ -223,13 +245,9 @@ def my_plan(request, year=None, month=None, day=None):
monday_of_week
=
get_calendar_week
(
calendar_week
,
date
.
year
)[
"
first_day
"
]
monday_of_week
=
get_calendar_week
(
calendar_week
,
date
.
year
)[
"
first_day
"
]
# Get user type (student, teacher, etc.)
# Get user type (student, teacher, etc.)
_type
=
UserInformation
.
user_type
(
request
.
user
)
_type
,
el
=
get_type_and_object_of_user
(
request
.
user
)
if
_type
==
TYPE_TEACHER
:
if
_type
==
UserInformation
.
TEACHER
:
# Teacher
# Teacher
_type
=
TYPE_TEACHER
shortcode
=
request
.
user
.
username
el
=
get_teacher_by_shortcode
(
shortcode
)
plan_id
=
el
.
id
plan_id
=
el
.
id
raw_type
=
"
teacher
"
raw_type
=
"
teacher
"
...
@@ -237,11 +255,9 @@ def my_plan(request, year=None, month=None, day=None):
...
@@ -237,11 +255,9 @@ def my_plan(request, year=None, month=None, day=None):
hints
=
list
(
get_all_hints_for_teachers_by_time_period
(
date
,
date
))
hints
=
list
(
get_all_hints_for_teachers_by_time_period
(
date
,
date
))
hints_b
=
list
(
get_all_hints_not_for_teachers_by_time_period
(
date
,
date
))
hints_b
=
list
(
get_all_hints_not_for_teachers_by_time_period
(
date
,
date
))
elif
_type
==
UserInformation
.
STUDENT
:
elif
_type
==
TYPE_CLASS
:
# Student
# Student
_type
=
TYPE_CLASS
_name
=
UserInformation
.
user_classes
(
request
.
user
)[
0
]
el
=
get_class_by_name
(
_name
)
plan_id
=
el
.
id
plan_id
=
el
.
id
raw_type
=
"
class
"
raw_type
=
"
class
"
...
@@ -275,7 +291,7 @@ def my_plan(request, year=None, month=None, day=None):
...
@@ -275,7 +291,7 @@ def my_plan(request, year=None, month=None, day=None):
return
render
(
request
,
'
timetable/myplan.html
'
,
context
)
return
render
(
request
,
'
timetable/myplan.html
'
,
context
)
def
get_next_weekday_with_time
(
date
,
time
):
def
get_next_weekday_with_time
(
date
,
time
)
->
datetime
.
datetime
:
"""
Get the next weekday by a datetime object
"""
"""
Get the next weekday by a datetime object
"""
if
time
>
datetime
.
time
(
15
,
35
):
if
time
>
datetime
.
time
(
15
,
35
):
...
...
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