Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add website and social media links to chapter profile #42

Merged
merged 4 commits into from
Nov 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions project/chapters/migrations/0006_chapter_social_media.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
24 changes: 24 additions & 0 deletions project/chapters/migrations/0007_auto_20211116_1009.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
14 changes: 13 additions & 1 deletion project/chapters/models.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions project/chapters/templates/chapters/chapter.html
Original file line number Diff line number Diff line change
@@ -9,6 +9,22 @@
<h1>{{ page.title }}</h1>

{{ page.introduction | richtext }}

<ul class="nav flex-column">
{% for link in page.links %}
{% if link.block_type == 'website_link' %}
<li class="nav-item">
<a class="nav-link" href="{{ link.value }}">Website link</a>
</li>
{% elif link.block_type == 'social_media_link' %}
<li class="nav-item">
<a class="nav-link" href="{{ link.value }}">Social Media link</a>
</li>
{% endif %}
{% endfor %}
</ul>


{% if user.is_authenticated %}
<form action="." method="post">
{% csrf_token %}