Skip to content
Snippets Groups Projects
Commit 68871102 authored by Tomáš Valenta's avatar Tomáš Valenta Committed by jan.bednarik
Browse files

sync styleguide2 changes

parent 9c5f2e63
Branches
No related tags found
2 merge requests!804Release,!782Improve personal calendar styling, view more info, sync Instagram on save
Pipeline #13674 passed
......@@ -117,8 +117,6 @@ class CalendarMixin(models.Model):
if event["description"] not in ("", None):
parsed_event["description"] = event["description"]
print(event)
calendar_format_events.append(parsed_event)
return json.dumps(calendar_format_events)
......
......@@ -2,6 +2,7 @@ import datetime
import mimetypes
import uuid
from django.conf import settings
from django.db import models
......@@ -74,3 +75,28 @@ class InstagramPost(models.Model):
class Meta:
ordering = ("timestamp",)
class InstagramMixin(models.Model):
def save(self, *args, **kwargs):
"""
Update Instagram posts when saved, assume they are declared
"""
from .services import InstagramDownloadService
try:
service = InstagramDownloadService(
app_id=settings.INSTAGRAM_APP_ID,
app_secret=settings.INSTAGRAM_APP_SECRET,
)
service.perform_update()
except Exception:
logger.error(
"Instagram post update failed", exc_info=True
)
super().save(*args, **kwargs)
class Meta:
abstract = True
......@@ -31,7 +31,7 @@ from wagtailmetadata.models import MetadataPageMixin
from calendar_utils.models import CalendarMixin
from elections2021.constants import REGION_CHOICES # pozor, import ze sousedního modulu
from instagram_utils.models import InstagramPost
from instagram_utils.models import InstagramPost, InstagramMixin
from shared.forms import SubscribeForm
from shared.models import ( # MenuMixin,
ArticleMixin,
......@@ -54,7 +54,12 @@ class ARTICLE_TYPES(models.IntegerChoices):
class MainHomePage(
MenuMixin, RoutablePageMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, Page
MenuMixin,
RoutablePageMixin,
ExtendedMetadataHomePageMixin,
MetadataPageMixin,
InstagramMixin,
Page
):
# header
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment