From d4760e95e9334357fc462299436f14813c866659 Mon Sep 17 00:00:00 2001 From: Upasana Dhameliya Date: Mon, 15 Nov 2021 09:35:21 +0530 Subject: [PATCH 1/4] Add website and social media links to chapter profile From d147da61bbb0ff488a3857f02a5adadbe5e76ce1 Mon Sep 17 00:00:00 2001 From: Upasana Dhameliya Date: Tue, 16 Nov 2021 10:23:32 +0530 Subject: [PATCH 2/4] Added Links to chapters StreamField block containing the option to add either social media links or website links was added. Through this feature, the chapters can contain links to webpages corresponding to the theme. --- .../migrations/0006_chapter_social_media.py | 18 ++++++++++++++ .../migrations/0007_auto_20211116_1009.py | 24 +++++++++++++++++++ project/chapters/models.py | 8 ++++++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 project/chapters/migrations/0006_chapter_social_media.py create mode 100644 project/chapters/migrations/0007_auto_20211116_1009.py 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..e19bd15 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,14 @@ 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) From 8eda4ac8d0a45472ab2ccbd2b1648cdf0895d922 Mon Sep 17 00:00:00 2001 From: Upasana Dhameliya Date: Tue, 16 Nov 2021 10:28:46 +0530 Subject: [PATCH 3/4] Reformatted models.py using black --- project/chapters/models.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/project/chapters/models.py b/project/chapters/models.py index e19bd15..9c45853 100644 --- a/project/chapters/models.py +++ b/project/chapters/models.py @@ -59,14 +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) + 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") + FieldPanel("links", classname="full"), ] members = models.ManyToManyField(User, blank=True) From 3c88e6764729c0974671e5d8d7924bdc061f8f26 Mon Sep 17 00:00:00 2001 From: Upasana Dhameliya Date: Tue, 16 Nov 2021 11:49:15 +0530 Subject: [PATCH 4/4] Added links in chapter templates The links were made to render in the individual chapters templates if present, by the use of bootstrap "navs". --- project/chapters/templates/chapters/chapter.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 %}