|
3 | 3 | # file, You can obtain one at https://mozilla.org/MPL/2.0/. |
4 | 4 |
|
5 | 5 | from django.conf import settings |
6 | | -from django.template.defaultfilters import slugify as django_slugify |
7 | 6 |
|
8 | 7 | from wagtail import blocks |
9 | | -from wagtail.images.blocks import ImageChooserBlock |
10 | 8 | from wagtail.snippets.blocks import SnippetChooserBlock |
11 | 9 |
|
12 | 10 |
|
13 | | -class LeadershipHeadshotBlock(blocks.StructBlock): |
14 | | - """Block for a leadership bio headshot image and (optional) photos link.""" |
15 | | - |
16 | | - image = ImageChooserBlock( |
17 | | - help_text="A headshot image of the person.", |
18 | | - ) |
19 | | - |
20 | | - image_alt_text = blocks.CharBlock( |
21 | | - char_max_length=255, |
22 | | - help_text="Alt text for the headshot image.", |
23 | | - ) |
24 | | - |
25 | | - photos_link = blocks.URLBlock( |
26 | | - required=False, |
27 | | - char_max_length=255, |
28 | | - help_text="External link to a .zip file of photos of the person.", |
29 | | - ) |
30 | | - |
31 | | - class Meta: |
32 | | - icon = "image" |
33 | | - label = "Headshot image" |
34 | | - |
35 | | - |
36 | 11 | class LeadershipExternalLinkBlock(blocks.StructBlock): |
37 | 12 | """Block for a leadership bio external link, such as a website or social media account.""" |
38 | 13 |
|
@@ -63,105 +38,6 @@ class Meta: |
63 | 38 | label = "External Link" |
64 | 39 |
|
65 | 40 |
|
66 | | -class LeadershipBioID(blocks.StructValue): |
67 | | - """ID Value class for LeadershipBioBlock. Used for page anchor links.""" |
68 | | - |
69 | | - @property |
70 | | - def id(self): |
71 | | - name = self.get("name") |
72 | | - return django_slugify(name) |
73 | | - |
74 | | - |
75 | | -class LeadershipBioBlock(blocks.StructBlock): |
76 | | - """Block for a leadership bio.""" |
77 | | - |
78 | | - name = blocks.CharBlock( |
79 | | - char_max_length=255, |
80 | | - placeholder="Enter the person's full name.", |
81 | | - ) |
82 | | - |
83 | | - headshot = LeadershipHeadshotBlock() |
84 | | - |
85 | | - job_title = blocks.CharBlock( |
86 | | - required=False, |
87 | | - char_max_length=255, |
88 | | - ) |
89 | | - |
90 | | - biography = blocks.RichTextBlock( |
91 | | - required=False, |
92 | | - help_text="A biography limited to a few short paragraphs. Links and formatting are supported.", |
93 | | - features=settings.WAGTAIL_RICHTEXT_FEATURES_FULL, |
94 | | - ) |
95 | | - |
96 | | - external_links = blocks.ListBlock( |
97 | | - LeadershipExternalLinkBlock(), |
98 | | - min_num=0, |
99 | | - max_num=5, |
100 | | - ) |
101 | | - |
102 | | - class Meta: |
103 | | - value_class = LeadershipBioID |
104 | | - template = "mozorg/cms/about/blocks/leadership_block.html" |
105 | | - icon = "user" |
106 | | - label = "Leadership Profile" |
107 | | - |
108 | | - |
109 | | -class LeadershipGroupBlock(blocks.StructBlock): |
110 | | - """Block for a leadership group.""" |
111 | | - |
112 | | - title = blocks.CharBlock( |
113 | | - char_max_length=255, |
114 | | - help_text="Leadership group title, e.g. 'Executive Steering Committee' or 'Senior Leadership'.", |
115 | | - required=False, |
116 | | - ) |
117 | | - |
118 | | - description = blocks.CharBlock( |
119 | | - char_max_length=1000, |
120 | | - help_text="A couple of sentences describes what the group is and some helpful context.", |
121 | | - required=False, |
122 | | - ) |
123 | | - |
124 | | - leaders = blocks.ListBlock( |
125 | | - LeadershipBioBlock(), |
126 | | - min_num=1, |
127 | | - ) |
128 | | - |
129 | | - class Meta: |
130 | | - icon = "group" |
131 | | - |
132 | | - |
133 | | -class LeadershipSectionID(blocks.StructValue): |
134 | | - """ID Value class for LeadershipSectionBlock. Used for page anchor links.""" |
135 | | - |
136 | | - @property |
137 | | - def id(self): |
138 | | - name = self.get("title") |
139 | | - return django_slugify(name) |
140 | | - |
141 | | - |
142 | | -class LeadershipSectionBlock(blocks.StructBlock): |
143 | | - """Block for a leadership section containing a title and one or more leadership groups.""" |
144 | | - |
145 | | - title = blocks.CharBlock( |
146 | | - max_length=255, blank=True, null=True, help_text="Title for the section of the page e.g. 'Mozilla Corporation' or 'Mozilla Foundation." |
147 | | - ) |
148 | | - |
149 | | - description = blocks.CharBlock( |
150 | | - char_max_length=1000, |
151 | | - help_text="Description for the leadership section.", |
152 | | - required=False, |
153 | | - ) |
154 | | - |
155 | | - leadership_group = blocks.ListBlock( |
156 | | - LeadershipGroupBlock(), |
157 | | - min_num=1, |
158 | | - ) |
159 | | - |
160 | | - class Meta: |
161 | | - value_class = LeadershipSectionID |
162 | | - icon = "group" |
163 | | - |
164 | | - |
165 | 41 | class LeadershipProfileChooserBlock(blocks.StructBlock): |
166 | 42 | """Block for placing a LeadershipProfileSnippet with an optional per-placement job title.""" |
167 | 43 |
|
|
0 commit comments