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

add calendars to district pages

parent 5fef36bb
No related branches found
No related tags found
2 merge requests!787Release,!749Add personal calendars, move from requests-cache to Django cache
Pipeline #12336 passed
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<!-- Styles --> <!-- Styles -->
<link rel="stylesheet" href="https://styleguide.pirati.cz/2.10.x/css/styles.css"> <link rel="stylesheet" href="https://styleguide.pirati.cz/2.12.x/css/styles.css">
<link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet"> <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet">
<link rel="stylesheet" href="{% static "shared/css/helpers.css" %}"> <link rel="stylesheet" href="{% static "shared/css/helpers.css" %}">
......
...@@ -21,9 +21,15 @@ ...@@ -21,9 +21,15 @@
{% block content %} {% block content %}
<div class="flex flex-col lg:flex-row lg:space-x-8 xl:space-x-16"> <div class="flex flex-col lg:flex-row lg:space-x-8 xl:space-x-16">
<section class="lg:w-3/5 xl:w-2/3"> <section class="lg:w-3/5 xl:w-2/3">
<div class="content-block w-full"> <div class="content-block w-full mb-16">
{{ page.text|richtext }} {{ page.text|richtext }}
</div> </div>
{% if page.ical_calendar_url %}
<section>
<h2 class="head-alt-md mb-3"><i class="ico--calendar mr-4"></i>Kalendář</h2>
<ui-person-calendar events='{{ calendar_data|safe }}'></ui-person-calendar>
</section>
{% endif %}
</section> </section>
<section class="lg:w-2/5 xl:w-1/3 pt-8 lg:pt-0 order-first lg:order-last candidate-detail__sidebar"> <section class="lg:w-2/5 xl:w-1/3 pt-8 lg:pt-0 order-first lg:order-last candidate-detail__sidebar">
......
...@@ -4,7 +4,6 @@ from functools import cached_property ...@@ -4,7 +4,6 @@ from functools import cached_property
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.core.cache import cache
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.db import models from django.db import models
...@@ -12,7 +11,6 @@ from django.forms import ValidationError ...@@ -12,7 +11,6 @@ from django.forms import ValidationError
from django.http import HttpResponseRedirect, JsonResponse from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import render from django.shortcuts import render
from django.utils import timezone from django.utils import timezone
from icalevnt import icalevents
from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey from modelcluster.fields import ParentalKey
from taggit.models import TaggedItemBase from taggit.models import TaggedItemBase
...@@ -822,6 +820,15 @@ class MainPersonPage( ...@@ -822,6 +820,15 @@ class MainPersonPage(
def get_context(self, request) -> dict: def get_context(self, request) -> dict:
context = super().get_context(request) context = super().get_context(request)
if len(self.instagram_access.raw_data) != 0:
context["instagram_post_list"] = (
InstagramPost.objects.filter(
author_username=self.instagram_access.raw_data[0]["value"][
"username"
]
).order_by("-timestamp")
)[:20]
context["article_page_list"] = MainArticlePage.objects.filter( context["article_page_list"] = MainArticlePage.objects.filter(
author_page=self.id author_page=self.id
) )
......
...@@ -2,8 +2,11 @@ import json ...@@ -2,8 +2,11 @@ import json
import logging import logging
import requests import requests
from datetime import date, timedelta
from django.core.cache import cache
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
from icalevnt import icalevents
from wagtail.admin.panels import FieldPanel, MultiFieldPanel, PublishingPanel from wagtail.admin.panels import FieldPanel, MultiFieldPanel, PublishingPanel
from wagtail.fields import StreamField from wagtail.fields import StreamField
from wagtail.models import Page from wagtail.models import Page
...@@ -212,15 +215,6 @@ class PersonCalendarMixin(models.Model): ...@@ -212,15 +215,6 @@ class PersonCalendarMixin(models.Model):
def get_context(self, request) -> dict: def get_context(self, request) -> dict:
context = super().get_context(request) context = super().get_context(request)
if len(self.instagram_access.raw_data) != 0:
context["instagram_post_list"] = (
InstagramPost.objects.filter(
author_username=self.instagram_access.raw_data[0]["value"][
"username"
]
).order_by("-timestamp")
)[:20]
if self.ical_calendar_url: if self.ical_calendar_url:
context["calendar_data"] = self.get_ical_data() context["calendar_data"] = self.get_ical_data()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment