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
6995c47b
Verified
Commit
6995c47b
authored
1 year ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add more detailed properties to LessonEvent
parent
b9f4bc21
No related branches found
No related tags found
1 merge request
!301
New data model based on calendar events
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/chronos/models.py
+41
-6
41 additions, 6 deletions
aleksis/apps/chronos/models.py
with
41 additions
and
6 deletions
aleksis/apps/chronos/models.py
+
41
−
6
View file @
6995c47b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
from
__future__
import
annotations
from
__future__
import
annotations
import
os
import
os
import
itertools
from
datetime
import
date
,
datetime
,
time
,
timedelta
from
datetime
import
date
,
datetime
,
time
,
timedelta
from
itertools
import
chain
from
itertools
import
chain
from
typing
import
Any
,
Dict
,
Iterable
,
Iterator
,
List
,
Optional
,
Tuple
,
Union
from
typing
import
Any
,
Dict
,
Iterable
,
Iterator
,
List
,
Optional
,
Tuple
,
Union
...
@@ -1367,7 +1368,7 @@ class ChronosGlobalPermissions(GlobalPermissionModel):
...
@@ -1367,7 +1368,7 @@ class ChronosGlobalPermissions(GlobalPermissionModel):
class
LessonEvent
(
CalendarEvent
):
class
LessonEvent
(
CalendarEvent
):
name
=
"
lesson
"
name
=
"
lesson
"
verbose_name
=
_
(
"
Lesson
"
)
verbose_name
=
_
(
"
Lesson
s
"
)
title
=
models
.
CharField
(
verbose_name
=
_
(
"
Name
"
),
max_length
=
255
,
blank
=
True
)
title
=
models
.
CharField
(
verbose_name
=
_
(
"
Name
"
),
max_length
=
255
,
blank
=
True
)
...
@@ -1402,8 +1403,24 @@ class LessonEvent(CalendarEvent):
...
@@ -1402,8 +1403,24 @@ class LessonEvent(CalendarEvent):
null
=
True
,
null
=
True
,
)
)
@property
def
all_members
(
self
:
"
LessonEvent
"
)
->
list
[
Person
]:
return
list
(
itertools
.
chain
(
*
[
list
(
g
.
members
.
all
())
for
g
in
self
.
groups
.
all
()]))
@property
def
group_names
(
self
:
"
LessonEvent
"
)
->
str
:
return
"
,
"
.
join
([
g
.
name
for
g
in
self
.
groups
.
all
()])
@property
def
teacher_names
(
self
:
"
LessonEvent
"
)
->
str
:
return
"
,
"
.
join
([
t
.
full_name
for
t
in
self
.
teachers
.
all
()])
@property
def
room_names
(
self
:
"
LessonEvent
"
)
->
str
:
return
"
,
"
.
join
([
r
.
name
for
r
in
self
.
rooms
.
all
()])
@classmethod
@classmethod
def
value_title
(
cls
,
reference_object
:
"
Calendar
Event
"
)
->
str
:
def
value_title
(
cls
,
reference_object
:
"
Lesson
Event
"
)
->
str
:
"""
Get the title of the event.
"""
"""
Get the title of the event.
"""
if
reference_object
.
title
:
if
reference_object
.
title
:
return
reference_object
.
title
return
reference_object
.
title
...
@@ -1411,17 +1428,17 @@ class LessonEvent(CalendarEvent):
...
@@ -1411,17 +1428,17 @@ class LessonEvent(CalendarEvent):
return
(
return
(
reference_object
.
subject
.
name
reference_object
.
subject
.
name
+
"
·
"
+
"
·
"
+
"
,
"
.
join
([
g
.
name
for
g
in
reference_object
.
group
s
.
all
()])
+
reference_object
.
group
_names
)
)
return
_
(
"
Lesson
"
)
return
_
(
"
Lesson
"
)
@classmethod
@classmethod
def
value_description
(
cls
,
reference_object
:
"
Calendar
Event
"
)
->
str
:
def
value_description
(
cls
,
reference_object
:
"
Lesson
Event
"
)
->
str
:
return
""
return
render_to_string
(
"
chronos/lesson_event_description.txt
"
,
{
"
event
"
:
reference_object
})
@classmethod
@classmethod
def
value_color
(
cls
,
reference_object
:
"
Calendar
Event
"
)
->
str
:
def
value_color
(
cls
,
reference_object
:
"
Lesson
Event
"
)
->
str
:
"""
Get the color of the event.
"""
"""
Get the color of the event.
"""
return
(
return
(
reference_object
.
subject
.
colour_bg
reference_object
.
subject
.
colour_bg
...
@@ -1429,6 +1446,24 @@ class LessonEvent(CalendarEvent):
...
@@ -1429,6 +1446,24 @@ class LessonEvent(CalendarEvent):
else
super
().
value_color
(
reference_object
)
else
super
().
value_color
(
reference_object
)
)
)
@classmethod
def
value_organizer
(
cls
,
reference_object
:
"
LessonEvent
"
)
->
str
:
"""
Get the organizer of the event.
"""
# TODO: Do not use the teachers as organizer, because only one organizer is allowed
return
[
t
.
get_vcal_address
(
role
=
"
CHAIR
"
)
for
t
in
reference_object
.
teachers
.
all
()]
@classmethod
def
value_attendee
(
cls
,
reference_object
:
"
LessonEvent
"
)
->
str
:
"""
Get the attendees of the event.
"""
# FIXME: Permissions
attendees
=
[
t
.
get_vcal_address
(
role
=
"
CHAIR
"
)
for
t
in
reference_object
.
teachers
.
all
()]
+
[
g
.
get_vcal_address
(
role
=
"
REQ-PARTICIPANT
"
)
for
g
in
reference_object
.
all_members
]
return
[
a
for
a
in
attendees
if
a
]
@classmethod
def
value_location
(
cls
,
reference_object
:
"
LessonEvent
"
)
->
str
:
"""
Get the location of the event.
"""
return
"
,
"
.
join
([
r
.
name
for
r
in
reference_object
.
rooms
.
all
()])
@classmethod
@classmethod
def
get_objects
(
cls
,
request
)
->
Iterable
:
def
get_objects
(
cls
,
request
)
->
Iterable
:
"""
Return all objects that should be included in the calendar.
"""
"""
Return all objects that should be included in the calendar.
"""
...
...
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