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
cd5e8d35
Commit
cd5e8d35
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
- Merge dev into feature/dashboard
- Do some refactoring
parent
6920cb01
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/helper.py
+0
-137
0 additions, 137 deletions
biscuit/apps/chronos/helper.py
biscuit/apps/chronos/views.py
+8
-12
8 additions, 12 deletions
biscuit/apps/chronos/views.py
with
8 additions
and
149 deletions
biscuit/apps/chronos/helper.py
deleted
100644 → 0
+
0
−
137
View file @
6920cb01
import
datetime
from
django.utils
import
timezone
from
schoolapps.settings
import
LONG_WEEK_DAYS
from
untisconnect.api
import
TYPE_TEACHER
,
get_teacher_by_shortcode
,
TYPE_CLASS
,
get_class_by_name
,
get_all_teachers
,
\
get_all_classes
,
get_all_rooms
,
get_all_subjects
from
userinformation
import
UserInformation
def
get_name_for_next_week_day_from_today
()
->
str
:
"""
Return the next week day as you would say it from today:
"
today
"
,
"
tomorrow
"
or
"
<weekday>
"
:return: Formatted date
"""
# Next weekday
next_weekday
:
timezone
.
datetime
=
get_next_weekday_with_time
(
timezone
.
now
(),
timezone
.
now
().
time
())
if
next_weekday
.
date
()
==
timezone
.
now
().
date
():
# Today
date_formatted
=
"
heute
"
elif
next_weekday
.
date
()
==
timezone
.
now
().
date
()
+
timezone
.
timedelta
(
days
=
1
):
# Tomorrow
date_formatted
=
"
morgen
"
else
:
# Other weekday
date_formatted
=
LONG_WEEK_DAYS
[
next_weekday
.
isoweekday
()
-
1
][
0
]
return
date_formatted
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
)
elif
_type
==
UserInformation
.
STUDENT
:
# Student
_type
=
TYPE_CLASS
_name
=
UserInformation
.
user_classes
(
user
)[
0
]
el
=
get_class_by_name
(
_name
)
else
:
return
None
,
None
return
_type
,
el
def
get_all_context
():
teachers
=
get_all_teachers
()
classes
=
get_all_classes
()
rooms
=
get_all_rooms
()
subjects
=
get_all_subjects
()
context
=
{
'
teachers
'
:
teachers
,
'
classes
'
:
classes
,
'
rooms
'
:
rooms
,
'
subjects
'
:
subjects
}
return
context
def
get_calendar_weeks
(
year
=
timezone
.
datetime
.
now
().
year
):
weeks
=
[]
# Get first day of year > first calendar week
first_day_of_year
=
timezone
.
datetime
(
year
=
year
,
month
=
1
,
day
=
1
)
if
first_day_of_year
.
isoweekday
()
!=
1
:
days_to_next_monday
=
1
-
first_day_of_year
.
isoweekday
()
first_day_of_year
+=
datetime
.
timedelta
(
days
=
days_to_next_monday
)
# Go for all weeks in year and create week dict
first_day_of_week
=
first_day_of_year
for
i
in
range
(
52
):
calendar_week
=
i
+
1
last_day_of_week
=
first_day_of_week
+
datetime
.
timedelta
(
days
=
4
)
weeks
.
append
({
"
calendar_week
"
:
calendar_week
,
"
first_day
"
:
first_day_of_week
,
"
last_day
"
:
last_day_of_week
})
first_day_of_week
+=
datetime
.
timedelta
(
weeks
=
1
)
return
weeks
def
find_out_what_is_today
(
year
=
None
,
month
=
None
,
day
=
None
):
date
=
timezone
.
datetime
.
now
()
time
=
datetime
.
datetime
.
now
().
time
()
if
year
is
not
None
and
day
is
not
None
and
month
is
not
None
:
date
=
timezone
.
datetime
(
year
=
year
,
month
=
month
,
day
=
day
)
if
date
!=
timezone
.
datetime
.
now
():
time
=
datetime
.
time
(
0
)
return
date
,
time
def
current_calendar_week
():
return
timezone
.
datetime
.
now
().
isocalendar
()[
1
]
def
current_year
():
return
timezone
.
datetime
.
now
().
year
def
get_calendar_week
(
calendar_week
,
year
=
timezone
.
datetime
.
now
().
year
):
weeks
=
get_calendar_weeks
(
year
=
year
)
for
week
in
weeks
:
if
week
[
"
calendar_week
"
]
==
calendar_week
:
return
week
return
None
def
get_next_weekday
(
date
):
"""
Get the next weekday by a datetime object
"""
if
date
.
isoweekday
()
in
{
6
,
7
}:
if
date
.
isoweekday
()
==
6
:
plus
=
2
else
:
plus
=
1
date
+=
datetime
.
timedelta
(
days
=
plus
)
return
date
def
get_next_weekday_with_time
(
date
,
time
)
->
datetime
.
datetime
:
"""
Get the next weekday by a datetime object
"""
if
time
>
datetime
.
time
(
15
,
35
):
date
+=
datetime
.
timedelta
(
days
=
1
)
if
date
.
isoweekday
()
in
{
6
,
7
}:
if
date
.
isoweekday
()
==
6
:
plus
=
2
else
:
plus
=
1
date
+=
datetime
.
timedelta
(
days
=
plus
)
return
date
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
8
−
12
View file @
cd5e8d35
...
...
@@ -8,22 +8,20 @@ from django.shortcuts import render, redirect, get_object_or_404
from
django.utils
import
timezone
from
debug.models
import
register_traceback
,
register_return_0
from
schoolapps.settings
import
BASE_DIR
from
schoolapps.settings
import
SHORT_WEEK_DAYS
,
LONG_WEEK_DAYS
from
timetable.filters
import
HintFilter
from
timetable.forms
import
HintForm
from
timetable.helper
import
get_type_and_object_of_user
,
get_all_context
,
get_calendar_week
,
get_calendar_weeks
,
\
get_next_weekday
,
current_calendar_week
,
current_year
,
find_out_what_is_today
,
get_next_weekday_with_time
from
untisconnect.datetimeutils
import
get_calendar_week
,
get_calendar_weeks
,
get_next_weekday
,
find_out_what_is_today
,
\
get_next_weekday_with_time
from
untisconnect.utils
import
get_type_and_object_of_user
,
overview_dict
from
timetable.hints
import
get_all_hints_by_time_period
,
get_all_hints_by_class_and_time_period
,
\
get_all_hints_for_teachers_by_time_period
,
get_all_hints_not_for_teachers_by_time_period
from
timetable.pdf
import
generate_class_tex
,
generate_pdf
from
untisconnect.plan
import
get_plan
,
parse_lesson_times
from
untisconnect.sub
import
get_substitutions_by_date
,
generate_sub_table
,
get_header_information
from
untisconnect.api
import
*
from
untisconnect.events
import
get_all_events_by_date
from
schoolapps.settings
import
BASE_DIR
from
untisconnect.plan
import
get_plan
,
parse_lesson_times
from
untisconnect.sub
import
get_substitutions_by_date
,
generate_sub_table
,
get_header_information
from
.models
import
Hint
...
...
@@ -40,7 +38,7 @@ def all(request):
:param request: Django request
:return: rendered template
"""
context
=
get_all_contex
t
()
context
=
overview_dic
t
()
return
render
(
request
,
'
timetable/all.html
'
,
context
)
...
...
@@ -53,7 +51,7 @@ def quicklaunch(request):
:param request: Django request
:return: rendered template
"""
context
=
get_all_contex
t
()
context
=
overview_dic
t
()
return
render
(
request
,
'
timetable/quicklaunch.html
'
,
context
)
...
...
@@ -211,8 +209,6 @@ def my_plan(request, year=None, month=None, day=None):
return
render
(
request
,
'
timetable/myplan.html
'
,
context
)
#################
# SUBSTITUTIONS #
#################
...
...
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