Skip to content
Snippets Groups Projects
Commit c00a1c2e authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

add personal calendars to homepage

parent 955855d7
No related branches found
No related tags found
2 merge requests!787Release,!749Add personal calendars, move from requests-cache to Django cache
Pipeline #12332 passed
from functools import cached_property
import json
import requests
from dateutil.relativedelta import relativedelta
......@@ -851,8 +852,6 @@ class MainPersonPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
if self.ical_calendar_url:
context["calendar_data"] = self.get_ical_data()
print(context["calendar_data"])
return context
### OTHERS
......@@ -871,12 +870,31 @@ class MainPersonPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
timeout=3600, # 1 hour
)
return icalevents.parse_events(
parsed_events = icalevents.parse_events(
ical_response,
start=date.today() - timedelta(days=30),
end=date.today() + timedelta(days=60),
)
calendar_format_events = []
for event in parsed_events:
parsed_event = {
"allDay": event.all_day,
"start": event.start.isoformat(),
"end": event.end.isoformat(),
}
if event.summary is not None:
parsed_event["title"] = event.summary
if event.url is not None:
parsed_event["url"] = event.url
calendar_format_events.append(parsed_event)
return json.dumps(calendar_format_events)
class Meta:
verbose_name = "Detail osoby"
# ordering = ("title",)
......
This diff is collapsed.
This diff is collapsed.
......@@ -7,7 +7,7 @@
{% with before_title=page.before_name after_title=page.after_name subtitle=page.position image_url=main_img.url %}
{% include 'main/includes/layout/person_photo_page_header.html' %}
{% endwith %}
<div class="">
<div>
<section class="grid-container person-grid-container">
<div class="grid-content leading-6">
<article class="mb-4 xl:mb-24 xl:mr-2">
......@@ -109,6 +109,19 @@
</section>
{% endif %}
{% if page.ical_calendar_url %}
<section class="grid-container no-max mr-0 mb-4 xl:mb-20">
<div class="grid-content-with-right-side">
<h2 class="head-4xl text-left">
Kalendář
</h2>
<div class="xl:max-w-[1145px] __js-root">
<ui-person-calendar events='{{ calendar_data|safe }}'></ui-person-calendar>
</div>
</div>
</section>
{% endif %}
{% if article_page_list %}
<section class="mb-4 xl:mb-20">
<div class="grid-container justify-start">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment