diff --git a/project/chapters/migrations/0006_chapter_social_media.py b/project/chapters/migrations/0006_chapter_social_media.py new file mode 100644 index 0000000..22f4c8f --- /dev/null +++ b/project/chapters/migrations/0006_chapter_social_media.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.6 on 2021-11-16 04:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('chapters', '0005_chapter_members'), + ] + + operations = [ + migrations.AddField( + model_name='chapter', + name='social_media', + field=models.URLField(blank=True, max_length=500), + ), + ] diff --git a/project/chapters/migrations/0007_auto_20211116_1009.py b/project/chapters/migrations/0007_auto_20211116_1009.py new file mode 100644 index 0000000..d87d009 --- /dev/null +++ b/project/chapters/migrations/0007_auto_20211116_1009.py @@ -0,0 +1,24 @@ +# Generated by Django 3.2.6 on 2021-11-16 04:39 + +from django.db import migrations +import wagtail.core.blocks +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('chapters', '0006_chapter_social_media'), + ] + + operations = [ + migrations.RemoveField( + model_name='chapter', + name='social_media', + ), + migrations.AddField( + model_name='chapter', + name='links', + field=wagtail.core.fields.StreamField([('social_media_link', wagtail.core.blocks.URLBlock(form_classname='social media link', required=False)), ('website_link', wagtail.core.blocks.URLBlock(form_classname='website link', required=False))], blank=True), + ), + ] diff --git a/project/chapters/models.py b/project/chapters/models.py index 7db3757..9c45853 100644 --- a/project/chapters/models.py +++ b/project/chapters/models.py @@ -5,7 +5,7 @@ from wagtail.admin.edit_handlers import FieldPanel from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Page -from wagtail.core.blocks import RichTextBlock, TextBlock +from wagtail.core.blocks import URLBlock from wagtail.admin.edit_handlers import StreamFieldPanel from accounts.models import User @@ -59,8 +59,20 @@ class ChaptersIndexPage(GroupsIndexPage): class Group(Page): introduction = RichTextField() + links = StreamField( + [ + ( + "social_media_link", + URLBlock(required=False, form_classname="social media link"), + ), + ("website_link", URLBlock(required=False, form_classname="website link")), + ], + blank=True, + ) + content_panels = Page.content_panels + [ FieldPanel("introduction", classname="full"), + FieldPanel("links", classname="full"), ] members = models.ManyToManyField(User, blank=True) diff --git a/project/chapters/templates/chapters/chapter.html b/project/chapters/templates/chapters/chapter.html index e435eed..f48443f 100644 --- a/project/chapters/templates/chapters/chapter.html +++ b/project/chapters/templates/chapters/chapter.html @@ -9,6 +9,22 @@

{{ page.title }}

{{ page.introduction | richtext }} + + + + {% if user.is_authenticated %}
{% csrf_token %}