-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Frost Ming <[email protected]>
- Loading branch information
Showing
11 changed files
with
205 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
INSTALLED_APPS = [ | ||
"base", | ||
"home", | ||
"supporter", | ||
"search", | ||
"bakery", | ||
"wagtailbakery", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from wagtail.blocks import ( | ||
CharBlock, | ||
ListBlock, | ||
RichTextBlock, | ||
StreamBlock, | ||
StructBlock, | ||
URLBlock, | ||
) | ||
from wagtail.images.blocks import ImageChooserBlock | ||
|
||
|
||
class SupporterBlock(StructBlock): | ||
name = CharBlock(required=True) | ||
description = CharBlock(required=False) | ||
logo = ImageChooserBlock(required=False) | ||
url = URLBlock(required=False) | ||
|
||
|
||
class SupporterListBlock(StructBlock): | ||
heading = CharBlock(required=True) | ||
supporters = ListBlock(SupporterBlock()) | ||
|
||
class Meta: | ||
template = "supporter/blocks/supporter-list.html" | ||
|
||
|
||
class SupporterStreamBlock(StreamBlock): | ||
paragraph = RichTextBlock(required=False) | ||
supporters = ListBlock(SupporterListBlock()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 5.1.1 on 2024-10-08 09:55 | ||
|
||
import django.db.models.deletion | ||
import wagtail.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('wagtailcore', '0094_alter_page_locale'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SupporterPage', | ||
fields=[ | ||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), | ||
('body', wagtail.fields.StreamField([('paragraph', 0), ('supporters', 8)], block_lookup={0: ('wagtail.blocks.RichTextBlock', (), {'required': False}), 1: ('wagtail.blocks.CharBlock', (), {'required': True}), 2: ('wagtail.blocks.CharBlock', (), {'required': False}), 3: ('wagtail.images.blocks.ImageChooserBlock', (), {'required': False}), 4: ('wagtail.blocks.URLBlock', (), {'required': False}), 5: ('wagtail.blocks.StructBlock', [[('name', 1), ('description', 2), ('logo', 3), ('url', 4)]], {}), 6: ('wagtail.blocks.ListBlock', (5,), {}), 7: ('wagtail.blocks.StructBlock', [[('heading', 1), ('supporters', 6)]], {}), 8: ('wagtail.blocks.ListBlock', (7,), {})}, help_text='Add supporters to the page.')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('wagtailcore.page',), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from wagtail.admin.panels import FieldPanel | ||
from wagtail.fields import StreamField | ||
from wagtail.models import Page | ||
|
||
from supporter.blocks import SupporterStreamBlock | ||
|
||
# Create your models here. | ||
|
||
|
||
class SupporterPage(Page): | ||
parent_page_types = ["home.HomePage"] | ||
|
||
body = StreamField( | ||
SupporterStreamBlock(), | ||
use_json_field=True, | ||
help_text="Add supporters to the page.", | ||
) | ||
|
||
content_panels = Page.content_panels + [ | ||
FieldPanel("body"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
|
||
.supporter-list { | ||
background-color: #f8f8f8; | ||
border: 2px solid #4B8BBE; | ||
border-radius: 10px; | ||
padding: 20px; | ||
margin-top: 20px; | ||
} | ||
|
||
.supporter-list h2 { | ||
color: #4B8BBE; | ||
font-size: 24px; | ||
margin-bottom: 20px; | ||
text-align: center; | ||
} | ||
|
||
.supporter-list ul { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
} | ||
|
||
.supporter-list .supporter { | ||
background-color: white; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
margin: 10px; | ||
padding: 15px; | ||
width: 240px; | ||
text-align: center; | ||
transition: transform 0.2s, box-shadow 0.2s; | ||
} | ||
|
||
.supporter-list .supporter:hover { | ||
transform: translateY(-5px); | ||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.supporter-list .supporter img { | ||
max-width: 100%; | ||
height: auto; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.supporter-list .supporter-info p { | ||
margin: 5px 0; | ||
} | ||
|
||
.supporter-list .supporter-info p:first-child { | ||
font-weight: bold; | ||
color: #4B8BBE; | ||
} | ||
|
||
.block-supporters ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% load wagtailcore_tags wagtailimages_tags %} | ||
|
||
<div class="supporter-list"> | ||
<h2>{{ self.heading }}</h2> | ||
<ul> | ||
{% for supporter in self.supporters %} | ||
<li class="supporter"> | ||
<a href="{{ supporter.url }}" target="_blank"> | ||
{% if supporter.logo %} | ||
{% image supporter.logo width-240 %} | ||
{% endif %} | ||
<div class="supporter-info"> | ||
<p>{{ supporter.name }}</p> | ||
</div> | ||
</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% extends "base.html" %} | ||
{% load static %} | ||
{% load wagtailcore_tags %} | ||
|
||
{% block extra_css %} | ||
<link rel="stylesheet" href="{% static 'css/supporter.css' %}"> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<main> | ||
<h1 class="title">{{ page.title }}</h1> | ||
<div class="card"> | ||
<div class="card-body"> | ||
{{ page.body }} | ||
</div> | ||
</div> | ||
</main> | ||
{% endblock %} |