From 98d751af55292f6f6fc19e3285ad8caf003d34d0 Mon Sep 17 00:00:00 2001 From: SamuelmdLow Date: Tue, 29 Oct 2024 07:17:06 +0000 Subject: [PATCH] Allow different audio formats (why didn't I do that before? laziness). Slugify user inputed ids cause no one reads help text. Alter some help texts lmao. Highlight manually inputted events on events calendar to make admining easier. --- article/blocks.py | 30 +++++++++++++++++-- article/models.py | 4 +-- .../article/stream_blocks/audio.html | 2 +- .../article/stream_blocks/header.html | 3 +- .../article/stream_blocks/pageLink.html | 7 +++-- .../article/stream_blocks/quote.html | 10 ++++--- events/models.py | 9 +++--- events/views.py | 2 +- .../src/js/components/Events/calendar.jsx | 2 +- .../src/styles/components/events/_base.scss | 4 ++- 10 files changed, 52 insertions(+), 21 deletions(-) diff --git a/article/blocks.py b/article/blocks.py index 34b50738b..a2355d666 100644 --- a/article/blocks.py +++ b/article/blocks.py @@ -7,8 +7,20 @@ class AudioBlock(blocks.StructBlock): caption = blocks.CharBlock(required=False) - audio = DocumentChooserBlock(required=True, help_text="Must be mp3 format") - + audio = DocumentChooserBlock(required=True, help_text="File format: .m4a, .mp4, .mp, .wav, or .ogg") + + def get_context(self, value, parent_context=None): + context = super().get_context(value, parent_context) + if value['audio'].url[-4:] == '.wav': + context['self'].format = 'wav' + if value['audio'].url[-4:] == '.mp3': + context['self'].format = 'mpeg' + if value['audio'].url[-4:] == '.ogg': + context['self'].format = 'ogg' + else: + context['self'].format = 'mp4' + return context + class Meta: template = 'article/stream_blocks/audio.html', icon = "media" @@ -16,7 +28,19 @@ class Meta: class PullQuoteBlock(blocks.StructBlock): content = blocks.CharBlock(required=True) source = blocks.CharBlock(required=False) - audio = DocumentChooserBlock(required=False, help_text="optional, must be mp3 format") + audio = DocumentChooserBlock(required=False, help_text="Optional, file format: .m4a, .mp4, .mp, .wav, or .ogg") + + def get_context(self, value, parent_context=None): + context = super().get_context(value, parent_context) + if value['audio'].url[-4:] == '.wav': + context['self'].format = 'wav' + if value['audio'].url[-4:] == '.mp3': + context['self'].format = 'mpeg' + if value['audio'].url[-4:] == '.ogg': + context['self'].format = 'ogg' + else: + context['self'].format = 'mp4' + return context class Meta: template = 'article/stream_blocks/quote.html', diff --git a/article/models.py b/article/models.py index e34de0f4e..4782ebdac 100644 --- a/article/models.py +++ b/article/models.py @@ -480,7 +480,7 @@ class ArticlePage(RoutablePageMixin, SectionablePage, UbysseyMenuMixin): ('dropcap', blocks.TextBlock( label = "Dropcap Block", template = 'article/stream_blocks/dropcap.html', - help_text = "DO NOT USE - Legacy block. Create a block where special dropcap styling with be applied to the first letter and the first letter only.\n\nThe contents of this block will be enclosed in a

...

element, allowing its targetting for styling.\n\nNo RichText allowed." + help_text = "Create a block where special dropcap styling with be applied to the first letter and the first letter only.\n\nThe contents of this block will be enclosed in a

...

element, allowing its targetting for styling.\n\nNo RichText allowed." )), ('video', video_blocks.OneOffVideoBlock( label = "Credited/Captioned One-Off Video", @@ -546,7 +546,7 @@ class ArticlePage(RoutablePageMixin, SectionablePage, UbysseyMenuMixin): blank=True, default='', max_length=255, - help_text="Enter the slug of the tag to be used for linking at the end of the article. For example, the slug of the tag 'blue chip' is 'blue-chip'.", + help_text="IF USED, SHOULD ALSO BE IN TAGS FIELD. Enter the slug of the tag to be used for linking at the end of the article. For example, the slug of the tag 'blue chip' is 'blue-chip'.", ) tag_page_link = models.BooleanField( null=False, diff --git a/article/templates/article/stream_blocks/audio.html b/article/templates/article/stream_blocks/audio.html index 0f68834ae..a7b31ff45 100644 --- a/article/templates/article/stream_blocks/audio.html +++ b/article/templates/article/stream_blocks/audio.html @@ -1,7 +1,7 @@

{{self.caption}}

\ No newline at end of file diff --git a/article/templates/article/stream_blocks/header.html b/article/templates/article/stream_blocks/header.html index d6c490df6..02bd1e8f6 100644 --- a/article/templates/article/stream_blocks/header.html +++ b/article/templates/article/stream_blocks/header.html @@ -1,3 +1,4 @@ +{% load wagtailcore_tags %}
-

{{self.title}}

+

{{self.title}}

\ No newline at end of file diff --git a/article/templates/article/stream_blocks/pageLink.html b/article/templates/article/stream_blocks/pageLink.html index 20533338b..eaeb7e5f1 100644 --- a/article/templates/article/stream_blocks/pageLink.html +++ b/article/templates/article/stream_blocks/pageLink.html @@ -1,15 +1,16 @@ {% load static %} +{% load wagtailcore_tags %}
diff --git a/article/templates/article/stream_blocks/quote.html b/article/templates/article/stream_blocks/quote.html index 868bfbdaa..03d073bf6 100644 --- a/article/templates/article/stream_blocks/quote.html +++ b/article/templates/article/stream_blocks/quote.html @@ -1,6 +1,8 @@ +{% load wagtailcore_tags %} + {% if self.audio %} -