Skip to content

Commit 2e576bc

Browse files
authored
Merge pull request #25 from python-la-paz/develop
Pass from develop to production
2 parents bd84ea1 + 8cf87d9 commit 2e576bc

File tree

10 files changed

+454
-85
lines changed

10 files changed

+454
-85
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Generated by Django 5.0.9 on 2024-10-02 01:43
2+
3+
import wagtail_color_panel.fields
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('home', '0041_homepage_externalraws'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='homepage',
16+
name='background_section',
17+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FFFFFF', max_length=250),
18+
),
19+
migrations.AlterField(
20+
model_name='homepage',
21+
name='color_gradient_1',
22+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FF4D79', max_length=250),
23+
),
24+
migrations.AlterField(
25+
model_name='homepage',
26+
name='color_gradient_2',
27+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FF809F', max_length=250),
28+
),
29+
migrations.AlterField(
30+
model_name='homepage',
31+
name='color_primary',
32+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#ff4a67', max_length=250),
33+
),
34+
migrations.AlterField(
35+
model_name='homepage',
36+
name='color_text_hero',
37+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FFFFFF', max_length=250),
38+
),
39+
migrations.AlterField(
40+
model_name='homepage',
41+
name='color_text_section',
42+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FFFFFF', max_length=250),
43+
),
44+
migrations.AlterField(
45+
model_name='homepage',
46+
name='navbar_background',
47+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#000000', max_length=250),
48+
),
49+
migrations.AlterField(
50+
model_name='homepage',
51+
name='navbar_links_color',
52+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FFFFFF', max_length=250),
53+
),
54+
migrations.AlterField(
55+
model_name='segmentpage',
56+
name='background_section',
57+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#FFFFFF', max_length=250),
58+
),
59+
migrations.AlterField(
60+
model_name='segmentpage',
61+
name='color_text_section',
62+
field=wagtail_color_panel.fields.ColorField(blank=True, default='#000000', max_length=250),
63+
),
64+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 5.0.9 on 2024-09-08 22:45
2+
3+
import wagtail.fields
4+
from django.db import migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('home', '0041_homepage_externalraws'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='homepage',
16+
name='fonts',
17+
field=wagtail.fields.StreamField([('fonts', 3)], blank=True, block_lookup={0: ('wagtail.blocks.CharBlock', (), {'max_length': 250, 'required': True}), 1: ('wagtail.blocks.URLBlock', (), {'required': True}), 2: ('wagtail.blocks.CharBlock', (), {'default': '#000000', 'max_length': 250, 'required': True}), 3: ('wagtail.blocks.StructBlock', [[('name', 0), ('section', 0), ('url', 1), ('font_size', 0), ('font_wight', 0), ('font_family', 0), ('font_color', 2)]], {})}),
18+
),
19+
]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Generated by Django 5.0.9 on 2024-09-11 02:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('home', '0042_homepage_fonts'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='homepage',
15+
name='fonts',
16+
),
17+
migrations.AddField(
18+
model_name='homepage',
19+
name='primaryFontFamily',
20+
field=models.CharField(default='sans-serif', max_length=250),
21+
),
22+
migrations.AddField(
23+
model_name='homepage',
24+
name='primaryFontURL',
25+
field=models.URLField(blank=True, max_length=250),
26+
),
27+
migrations.AddField(
28+
model_name='homepage',
29+
name='secondaryFontFamily',
30+
field=models.CharField(default='sans-serif', max_length=250),
31+
),
32+
migrations.AddField(
33+
model_name='homepage',
34+
name='secondaryFontURL',
35+
field=models.URLField(blank=True, max_length=250),
36+
),
37+
]

home/models.py

Lines changed: 81 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.db import models
2-
from wagtail.fields import RichTextField, StreamField
3-
from wagtail.models import Page
4-
from wagtail.admin.panels import FieldPanel
52
from wagtail import blocks
3+
from wagtail.admin.panels import FieldPanel
4+
from wagtail.fields import RichTextField, StreamField
65
from wagtail.images.blocks import ImageChooserBlock
6+
from wagtail.models import Page
7+
from wagtail_color_panel.edit_handlers import NativeColorPanel
8+
from wagtail_color_panel.fields import ColorField
79

810

911
class HomePage(Page):
@@ -47,7 +49,9 @@ class HomePage(Page):
4749
on_delete=models.SET_NULL,
4850
related_name="+",
4951
)
50-
hero_image_overlay_opacity = models.DecimalField(default=0.70, decimal_places=2, max_digits=3)
52+
hero_image_overlay_opacity = models.DecimalField(
53+
default=0.70, decimal_places=2, max_digits=3
54+
)
5155
hero_padding_left = models.CharField(max_length=250, default="20px")
5256
hero_padding_right = models.CharField(max_length=250, default="20px")
5357
footer_title = models.CharField(max_length=250, blank=True)
@@ -77,41 +81,54 @@ class HomePage(Page):
7781
blank=True,
7882
use_json_field=True,
7983
)
80-
color_gradient_1 = models.CharField(max_length=250, blank=True, default="#FF4D79")
81-
color_gradient_2 = models.CharField(max_length=250, blank=True, default="#FF809F")
82-
color_primary = models.CharField(max_length=250, blank=True, default="#ff4a67")
83-
color_text_hero = models.CharField(max_length=250, blank=True, default="#FFFFFF")
84+
85+
primaryFontURL = models.URLField(max_length=250, blank=True)
86+
primaryFontFamily = models.CharField(max_length=250, default="sans-serif")
87+
secondaryFontURL = models.URLField(max_length=250, blank=True)
88+
secondaryFontFamily = models.CharField(max_length=250, default="sans-serif")
89+
color_gradient_1 = ColorField(max_length=250, blank=True, default="#FF4D79")
90+
color_gradient_2 = ColorField(max_length=250, blank=True, default="#FF809F")
91+
color_primary = ColorField(max_length=250, blank=True, default="#ff4a67")
92+
color_text_hero = ColorField(max_length=250, blank=True, default="#FFFFFF")
93+
8494
show_time = models.BooleanField(default=True)
85-
background_section = models.CharField(max_length=250, blank=True, default="#FFFFFF")
86-
color_text_section = models.CharField(max_length=250, blank=True, default="white")
87-
navbar_background = models.CharField(max_length=250, default="transparent")
88-
navbar_links_color = models.CharField(max_length=250,default="white")
89-
message_show_time = models.CharField(max_length=250, blank=True, default="Próximamente...")
95+
background_section = ColorField(max_length=250, blank=True, default="#FFFFFF")
96+
color_text_section = ColorField(max_length=250, blank=True, default="#FFFFFF")
97+
navbar_background = ColorField(max_length=250, blank=True, default="#000000")
98+
navbar_links_color = ColorField(max_length=250, blank=True, default="#FFFFFF")
99+
message_show_time = models.CharField(
100+
max_length=250, blank=True, default="Próximamente..."
101+
)
90102
menu_links = StreamField(
91-
[
92-
(
93-
"menu_links",
94-
blocks.StructBlock(
95-
[
96-
("text", blocks.CharBlock(max_length=250, required=True)),
97-
("url",blocks.CharBlock(max_length=250, required=True, default="#")),
98-
]
99-
),
103+
[
104+
(
105+
"menu_links",
106+
blocks.StructBlock(
107+
[
108+
("text", blocks.CharBlock(max_length=250, required=True)),
109+
(
110+
"url",
111+
blocks.CharBlock(
112+
max_length=250, required=True, default="#"
113+
),
114+
),
115+
]
100116
),
101-
],
102-
blank=True,
103-
use_json_field=True,
104-
)
117+
),
118+
],
119+
blank=True,
120+
use_json_field=True,
121+
)
105122
favicon = models.ForeignKey(
106123
"wagtailimages.Image",
107124
null=True,
108125
blank=True,
109126
on_delete=models.SET_NULL,
110127
related_name="+",
111-
help_text="max size 256x256 png format"
128+
help_text="max size 256x256 png format",
112129
)
113130
footer_background = models.CharField(max_length=250, blank=True, default="#161E26")
114-
footer_color_text = models.CharField(max_length=250, blank=True, default="#9e9e9e")
131+
footer_color_text = models.CharField(max_length=250, blank=True, default="#9e9e9e")
115132
externalRaws = StreamField(
116133
[
117134
(
@@ -129,8 +146,8 @@ class HomePage(Page):
129146
content_panels = Page.content_panels + [
130147
FieldPanel("event"),
131148
FieldPanel("favicon"),
132-
FieldPanel("navbar_background"),
133-
FieldPanel("navbar_links_color"),
149+
NativeColorPanel("navbar_background"),
150+
NativeColorPanel("navbar_links_color"),
134151
FieldPanel("position_event"),
135152
FieldPanel("about"),
136153
FieldPanel("location"),
@@ -142,30 +159,40 @@ class HomePage(Page):
142159
FieldPanel("logo_image_big"),
143160
FieldPanel("hero_image"),
144161
FieldPanel("hero_image_overlay_opacity"),
145-
FieldPanel("color_text_hero"),
162+
NativeColorPanel("color_text_hero"),
146163
FieldPanel("hero_padding_left"),
147164
FieldPanel("hero_padding_right"),
148-
FieldPanel("color_gradient_1"),
149-
FieldPanel("color_gradient_2"),
150-
FieldPanel("color_primary"),
165+
FieldPanel("primaryFontURL"),
166+
FieldPanel("primaryFontFamily"),
167+
FieldPanel("secondaryFontURL"),
168+
FieldPanel("secondaryFontFamily"),
169+
NativeColorPanel("color_gradient_1"),
170+
NativeColorPanel("color_gradient_2"),
171+
NativeColorPanel("color_primary"),
151172
FieldPanel("show_time"),
152-
FieldPanel("background_section"),
153-
FieldPanel("color_text_section"),
173+
NativeColorPanel("background_section"),
174+
NativeColorPanel("color_text_section"),
154175
FieldPanel("message_show_time"),
155176
FieldPanel("menu_links"),
156177
FieldPanel("footer_title"),
157178
FieldPanel("footer_site_info"),
158179
FieldPanel("footer_networks"),
159-
FieldPanel("footer_background"),
160-
FieldPanel("footer_color_text"),
180+
NativeColorPanel("color_gradient_1"),
181+
NativeColorPanel("footer_background"),
182+
NativeColorPanel("footer_color_text"),
161183
FieldPanel("externalRaws"),
162184
]
163-
185+
164186
def get_context(self, request):
165187
# Update context to include only published posts, ordered by reverse-chron
166188
context = super().get_context(request)
167189
segments = SegmentPage.objects.child_of(self).live().order_by("order")
168190
context["segments"] = segments # sorted (segments, key=lambda x: x.order)
191+
context["exist_descendants"] = [
192+
descendant
193+
for descendant in self.get_descendants()
194+
if descendant.live and descendant.content_type == self.content_type
195+
]
169196
return context
170197

171198

@@ -188,6 +215,7 @@ class SponsorBlock(blocks.StructBlock):
188215
)
189216
url = blocks.URLBlock(required=False)
190217

218+
191219
class TiersBlock(blocks.StructBlock):
192220
classname = blocks.CharBlock(required=False)
193221
name = blocks.CharBlock()
@@ -200,6 +228,7 @@ class TiersBlock(blocks.StructBlock):
200228
url_text = blocks.CharBlock(required=False, default="Buy now")
201229
bg_color = blocks.CharBlock(required=False, default="#fff")
202230

231+
203232
class ScheduleDetailBlock(blocks.StructBlock):
204233
menu_title = blocks.CharBlock()
205234
menu_subtitle = blocks.CharBlock(default="Workshop")
@@ -210,15 +239,17 @@ class ScheduleDetailBlock(blocks.StructBlock):
210239
location = blocks.CharBlock(required=False)
211240
image = ImageChooserBlock(required=False)
212241

242+
213243
class ScheduleBlock(blocks.StructBlock):
214244
name = blocks.CharBlock()
215245
detail = blocks.CharBlock()
216246
schedule_details = blocks.ListBlock(ScheduleDetailBlock(required=False))
217247

248+
218249
class SegmentPage(Page):
219250
order = models.IntegerField(default=0)
220-
background_section = models.CharField(max_length=250, blank=True, default="#FFFFFF")
221-
color_text_section = models.CharField(max_length=250, blank=True, default="black")
251+
background_section = ColorField(max_length=250, blank=True, default="#FFFFFF")
252+
color_text_section = ColorField(max_length=250, blank=True, default="#000000")
222253
segments = StreamField(
223254
[
224255
# detail segment
@@ -253,7 +284,8 @@ class SegmentPage(Page):
253284
),
254285
),
255286
(
256-
"list_style",blocks.BooleanBlock(required=False, default=False),
287+
"list_style",
288+
blocks.BooleanBlock(required=False, default=False),
257289
),
258290
]
259291
),
@@ -363,7 +395,12 @@ class SegmentPage(Page):
363395

364396
content_panels = Page.content_panels + [
365397
FieldPanel("order"),
366-
FieldPanel("background_section"),
367-
FieldPanel("color_text_section"),
398+
NativeColorPanel("color_text_section"),
368399
FieldPanel("segments"),
400+
NativeColorPanel("background_section"),
369401
]
402+
403+
def get_context(self, request):
404+
context = super().get_context(request)
405+
context["parent"] = self.get_parent().specific
406+
return context

0 commit comments

Comments
 (0)