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
9c95d715
Commit
9c95d715
authored
3 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Create a showcase feed for birthdays of persons
parent
ed3c53af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!975
Resolve "Add possibility to create Ical feeds for all apps"
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/feeds.py
+42
-1
42 additions, 1 deletion
aleksis/core/feeds.py
with
42 additions
and
1 deletion
aleksis/core/feeds.py
+
42
−
1
View file @
9c95d715
...
@@ -2,10 +2,14 @@ from typing import Any
...
@@ -2,10 +2,14 @@ from typing import Any
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.handlers.wsgi
import
WSGIRequest
from
django.core.handlers.wsgi
import
WSGIRequest
from
django.utils.formats
import
date_format
from
django.utils.functional
import
classproperty
from
django.utils.functional
import
classproperty
from
django.utils.translation
import
gettext_lazy
as
_
from
django_ical.utils
import
build_rrule_from_text
from
django_ical.views
import
ICalFeed
from
django_ical.views
import
ICalFeed
from
aleksis.core.util.core_helpers
import
get_site_preferences
from
aleksis.core
import
models
from
aleksis.core.util.core_helpers
import
get_site_preferences
,
queryset_rules_filter
class
PersonalICalFeedBase
(
ICalFeed
):
class
PersonalICalFeedBase
(
ICalFeed
):
...
@@ -36,3 +40,40 @@ class PersonalICalFeedBase(ICalFeed):
...
@@ -36,3 +40,40 @@ class PersonalICalFeedBase(ICalFeed):
@classproperty
@classproperty
def
subclass_choices
(
cls
):
def
subclass_choices
(
cls
):
return
[(
subclass
.
__name__
,
f
"
{
subclass
.
title
}
–
{
subclass
.
description
}
"
)
for
subclass
in
cls
.
subclasses_list
]
return
[(
subclass
.
__name__
,
f
"
{
subclass
.
title
}
–
{
subclass
.
description
}
"
)
for
subclass
in
cls
.
subclasses_list
]
class
BirthdayFeed
(
PersonalICalFeedBase
):
"""
Birthday calendar feed
"""
title
=
_
(
"
Birthday Calendar
"
)
description
=
_
(
"
A Calendar of Birthdays
"
)
file_name
=
"
birthdays.ics
"
def
items
(
self
):
from
aleksis.core.models
import
Person
return
queryset_rules_filter
(
obj
=
self
.
person
.
user
,
perm
=
"
core.view_personal_details_rule
"
,
queryset
=
Person
.
objects
.
filter
(
date_of_birth__isnull
=
False
),
)
def
item_title
(
self
,
item
:
"
models.Person
"
):
return
_
(
"
%(first_name)s %(last_name)s
'
s birthday
"
)
%
{
"
first_name
"
:
item
.
first_name
,
"
last_name
"
:
item
.
last_name
,
}
def
item_description
(
self
,
item
:
"
models.Person
"
):
return
_
(
"
%(first_name)s %(last_name)s was born on %(birthday)s
"
)
%
{
"
first_name
"
:
item
.
first_name
,
"
last_name
"
:
item
.
last_name
,
"
birthday
"
:
date_format
(
item
.
date_of_birth
),
}
def
item_start_datetime
(
self
,
item
):
return
item
.
date_of_birth
def
item_rrule
(
self
,
item
):
return
build_rrule_from_text
(
"
FREQ=YEARLY
"
)
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