Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
c205dec3
Commit
c205dec3
authored
3 years ago
by
OndraRehounek
Browse files
Options
Downloads
Patches
Plain Diff
calendar: clear event description by bleach
parent
b6b5ffe0
No related branches found
No related tags found
2 merge requests
!480
Release
,
!479
calendar: clear event description by bleach
Pipeline
#7777
passed
3 years ago
Stage: build
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
calendar_utils/parser.py
+16
-1
16 additions, 1 deletion
calendar_utils/parser.py
with
16 additions
and
1 deletion
calendar_utils/parser.py
+
16
−
1
View file @
c205dec3
...
@@ -2,6 +2,7 @@ import re
...
@@ -2,6 +2,7 @@ import re
from
operator
import
attrgetter
from
operator
import
attrgetter
import
arrow
import
arrow
import
bleach
from
django.conf
import
settings
from
django.conf
import
settings
from
ics
import
Calendar
from
ics
import
Calendar
...
@@ -32,6 +33,13 @@ def split_events(events):
...
@@ -32,6 +33,13 @@ def split_events(events):
return
past
,
future
return
past
,
future
def
set_event_description
(
event
):
"""
Clears even description from unwanted tags.
"""
description
:
str
=
event
.
get
(
"
description
"
,
""
)
or
""
event
[
"
description
"
]
=
bleach
.
clean
(
description
,
tags
=
[
"
a
"
,
"
br
"
],
strip
=
True
)
return
event
def
set_event_duration
(
event
):
def
set_event_duration
(
event
):
"""
Sets duration for event.
"""
"""
Sets duration for event.
"""
if
event
[
"
all_day
"
]:
if
event
[
"
all_day
"
]:
...
@@ -50,10 +58,17 @@ def set_event_duration(event):
...
@@ -50,10 +58,17 @@ def set_event_duration(event):
return
event
return
event
def
process_event
(
event
):
"""
Processes single event for use in Majak
"""
event
=
set_event_duration
(
event
)
event
=
set_event_description
(
event
)
return
event
def
process_ical
(
source
):
def
process_ical
(
source
):
"""
Parses iCalendar source and returns events as list of dicts. Returns
"""
Parses iCalendar source and returns events as list of dicts. Returns
tuple of past and future events.
tuple of past and future events.
"""
"""
events
=
parse_ical
(
source
)
events
=
parse_ical
(
source
)
events
=
list
(
map
(
set_event_duration
,
events
))
events
=
list
(
map
(
process_event
,
events
))
return
split_events
(
events
)
return
split_events
(
events
)
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