Skip to content

Commit

Permalink
ical VIII
Browse files Browse the repository at this point in the history
(cherry picked from commit 862542f)
  • Loading branch information
Belissimo-T committed Aug 2, 2024
1 parent 4e5e98c commit 2f26117
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions endpoints/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def plan_ical(token: str) -> Response:
import html

def generate_html_list(elements: list[str]) -> str:
return "<ul>" + "".join(f"<li>{html.escape(element)}</li>" for element in elements) + "</ul>"
if not elements:
return ""
else:
return "<ul>" + "".join(f"<li>{html.escape(element)}</li>" for element in elements) + "</ul>"

if plan_type != "forms":
calendar = icalendar.Calendar()
Expand Down Expand Up @@ -244,11 +247,10 @@ def generate_html_list(elements: list[str]) -> str:

event = icalendar.Event()
event.add("summary", summary)
if info_paragraphs:
event.add("description", (
generate_html_list(info_paragraphs)
+ f"<br><small>{datetime.datetime.now().isoformat()}</small>"
))
event.add("description", (
generate_html_list(info_paragraphs)
+ f"<br><small>{datetime.datetime.now().isoformat()}</small>"
))
event.add("dtstart", begin)
event.add("dtend", end)
event.add("dtstamp", datetime.datetime.now())
Expand Down

0 comments on commit 2f26117

Please sign in to comment.