Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
83f53e08
Commit
83f53e08
authored
2 years ago
by
Ondrej Rehounek
Browse files
Options
Downloads
Patches
Plain Diff
main: models and blocks skeletons
parent
9a2a6fd6
Branches
Branches containing commit
No related tags found
2 merge requests
!607
Pirati.cz
,
!575
Feature/pirati cz
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main/blocks.py
+73
-14
73 additions, 14 deletions
main/blocks.py
main/migrations/0002_mainarticlepage_remove_mainhomepage_footer_and_more.py
+6543
-0
6543 additions, 0 deletions
...02_mainarticlepage_remove_mainhomepage_footer_and_more.py
main/models.py
+251
-10
251 additions, 10 deletions
main/models.py
with
6867 additions
and
24 deletions
main/blocks.py
+
73
−
14
View file @
83f53e08
from
wagtail.core.blocks
import
CharBlock
,
PageChooserBlock
,
StructBlock
,
URLBlock
from
wagtail.core.blocks
import
(
CharBlock
,
ListBlock
,
PageChooserBlock
,
StructBlock
,
TextBlock
,
URLBlock
,
)
from
wagtail.images.blocks
import
ImageChooserBlock
class
CTAMixin
:
button_link
=
URLBlock
(
label
=
"
Odkaz tlačítka
"
)
button_text
=
CharBlock
(
label
=
"
Text tlačítka
"
)
class
BoxBlock
(
CTAMixin
,
StructBlock
):
image
=
ImageChooserBlock
(
label
=
"
Logo/obrázek
"
)
title
=
CharBlock
(
label
=
"
Nadpis
"
)
class
BoxesBlock
(
StructBlock
):
title
=
CharBlock
(
label
=
"
Nadpis
"
)
list
=
ListBlock
(
BoxBlock
,
label
=
"
Boxíky
"
)
class
HomePageCarouseSlideBlock
(
CTAMixin
,
StructBlock
):
line_1
=
CharBlock
()
line_2
=
CharBlock
()
class
HomePageCarouselBlock
(
StructBlock
):
slides
=
ListBlock
(
HomePageCarouseSlideBlock
)
class
PeopleGroupBlock
(
StructBlock
):
title
=
CharBlock
()
person_list
=
ListBlock
(
PageChooserBlock
(
page_type
=
"
main.MainPersonPage
"
))
# HomePageCarouselBlock
# RecentWork/TweetsBlock
# NewsBlock
# PeopleOverviewBlock
# RegionOverviewBlock
# LinkBoxBlock (mozna hardcoded do homepage?)
# WorkTimelineBlock
# ArticleLinkBlock
# ProgramBlock
class
ProgramBlock
(
StructBlock
):
icon
=
ImageChooserBlock
()
title
=
CharBlock
()
text
=
TextBlock
()
class
ProgramGroupBlock
(
StructBlock
):
title
=
CharBlock
()
person_list
=
ListBlock
(
ProgramBlock
())
class
TweetsBlock
(
StructBlock
):
title
=
CharBlock
()
# NewsBlock - zatím asi hardcoded
# PeopleOverviewBlock - zatím asi hardcoded
# RegionOverviewBlock - zatím asi hardcoded
class
PersonContactBlock
(
StructBlock
):
...
...
@@ -24,12 +71,24 @@ class PersonContactBlock(StructBlock):
label
=
"
Osoba s volitelnou pozicí
"
class
PersonContactBoxBlock
(
StructBlock
):
class
PersonContactBoxBlock
(
CTAMixin
,
StructBlock
):
title
=
CharBlock
(
label
=
"
Titulek
"
)
subtitle
=
CharBlock
(
label
=
"
Podtitulek
"
)
button_link
=
URLBlock
()
button_text
=
CharBlock
(
label
=
"
Text tlačítka
"
)
# Footer
class
LinkBlock
(
StructBlock
):
text
=
CharBlock
()
link
=
URLBlock
()
class
OtherLinksBlock
(
StructBlock
):
title
=
CharBlock
()
list
=
ListBlock
(
LinkBlock
)
class
SocialLinkBlock
(
LinkBlock
):
icon
=
CharBlock
()
# TODO CSS class name or somthing better?
# TwitterCarouselBlock
# ContactBlock
This diff is collapsed.
Click to expand it.
main/migrations/0002_mainarticlepage_remove_mainhomepage_footer_and_more.py
0 → 100644
+
6543
−
0
View file @
83f53e08
This diff is collapsed.
Click to expand it.
main/models.py
+
251
−
10
View file @
83f53e08
from
django.core.paginator
import
Paginator
from
django.db
import
models
from
django.shortcuts
import
render
from
modelcluster.contrib.taggit
import
ClusterTaggableManager
from
modelcluster.fields
import
ParentalKey
from
taggit.models
import
TaggedItemBase
from
wagtail.admin.edit_handlers
import
FieldPanel
,
ObjectList
,
TabbedInterface
from
wagtail.contrib.routable_page.models
import
RoutablePageMixin
,
route
from
wagtail.core.blocks
import
PageChooserBlock
from
wagtail.core.fields
import
RichTextField
,
StreamField
from
wagtail.core.models
import
Page
from
wagtailmetadata.models
import
MetadataPageMixin
from
shared.const
import
RICH_TEXT_DEFAULT_FEATURES
from
shared.models
import
(
ArticleMixin
,
ExtendedMetadataHomePageMixin
,
ExtendedMetadataPageMixin
,
MenuMixin
,
SubpageMixin
,
)
from
shared.utils
import
make_promote_panels
from
tuning
import
admin_help
from
.
import
blocks
...
...
@@ -24,11 +32,54 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
"
Matomo ID pro sledování návštěvnosti
"
,
blank
=
True
,
null
=
True
)
# header
- fb, twitter, insta, youtube, dary, nalodeni
footer
=
StreamField
(
[(
"
item
"
,
blocks
.
PersonContactBlock
())],
verbose_name
=
"
Kontaktní boxy
"
,
# header
contact_newcomers
=
models
.
URLField
(
"
URL pro zájemce o členství
"
,
blank
=
True
,
null
=
True
,
default
=
"
https://nalodeni.pirati.cz
"
,
)
donation_page
=
models
.
URLField
(
"
URL pro příjem darů (tlačítko Dary)
"
,
blank
=
True
,
null
=
True
,
default
=
"
https://dary.pirati.cz
"
,
)
# content
content
=
StreamField
(
[
(
"
carousel
"
,
blocks
.
HomePageCarouselBlock
()),
(
"
boxes
"
,
blocks
.
BoxesBlock
()),
],
verbose_name
=
"
Hlavní obsah
"
,
blank
=
True
,
)
# footer
footer_social_links
=
StreamField
(
[
(
"
social_links
"
,
blocks
.
SocialLinkBlock
()),
],
verbose_name
=
"
Odkazy na sociální sítě v zápatí webu
"
,
blank
=
True
,
)
footer_other_links
=
StreamField
(
[
(
"
other_links
"
,
blocks
.
OtherLinksBlock
()),
],
verbose_name
=
"
Bloky dalších odkazů v zápatí webu
"
,
blank
=
True
,
)
footer_person_list
=
StreamField
(
[(
"
person
"
,
blocks
.
PersonContactBlock
())],
verbose_name
=
"
Osoby v zápatí webu
"
,
blank
=
True
,
max_num
=
6
,
)
content_panels
=
Page
.
content_panels
+
[]
...
...
@@ -48,12 +99,12 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
### RELATIONS
subpage_types
=
[
#
MainWork
Timeline
Page
#
MainArticlePage
#
MainProgramPage
#
MainPeoplePage
#
MainPersonPage
"
main.MainContactPage
"
"
main.
MainWorkPage
"
,
"
main.
MainArticle
s
Page
"
,
"
main.
MainProgramPage
"
,
"
main.
MainPeoplePage
"
,
"
main.
MainPersonPage
"
,
"
main.MainContactPage
"
,
]
### OTHERS
...
...
@@ -70,7 +121,197 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
return
self
class
MainWorkPage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
perex
=
models
.
TextField
()
timeline
=
StreamField
(
[(
"
article_list
"
,
PageChooserBlock
(
page_type
=
"
main.MainArticlePage
"
))],
verbose_name
=
"
Timeline
"
,
blank
=
True
,
)
### RELATIONS
parent_page_types
=
[
"
main.MainHomePage
"
]
subpage_types
=
[]
### OTHERS
class
Meta
:
verbose_name
=
"
Piráti pracují
"
class
MainArticleTag
(
TaggedItemBase
):
content_object
=
ParentalKey
(
"
main.MainArticlePage
"
,
on_delete
=
models
.
CASCADE
)
class
MainArticlePage
(
ArticleMixin
,
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
author_page
=
models
.
ForeignKey
(
"
main.MainPersonPage
"
,
on_delete
=
models
.
SET_NULL
,
null
=
True
,
blank
=
True
)
tags
=
ClusterTaggableManager
(
through
=
MainArticleTag
,
blank
=
True
)
### PANELS
content_panels
=
ArticleMixin
.
content_panels
+
[
FieldPanel
(
"
author_page
"
),
FieldPanel
(
"
tags
"
),
]
promote_panels
=
make_promote_panels
(
admin_help
.
build
(
admin_help
.
NO_SEO_TITLE
,
admin_help
.
NO_DESCRIPTION_USE_PEREX
),
search_image
=
False
,
)
### RELATIONS
parent_page_types
=
[
"
main.MainArticlesPage
"
]
subpage_types
=
[]
### OTHERS
class
Meta
:
verbose_name
=
"
Aktualita
"
# def get_context(self, request): chceme/nechceme?
# context = super().get_context(request)
# context["related_articles"] = (
# self.get_siblings(inclusive=False)
# .live()
# .specific()
# .order_by("-mainarticlepage__date")[:3]
# )
# return context
class
MainArticlesPage
(
RoutablePageMixin
,
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
def
get_context
(
self
,
request
):
context
=
super
().
get_context
(
request
)
context
[
"
articles
"
]
=
Paginator
(
self
.
get_children
().
live
().
specific
().
order_by
(
"
-mainarticlepage__date
"
),
12
,
# nevím, návrh nemáme
).
get_page
(
request
.
GET
.
get
(
"
page
"
))
return
context
@route
(
r
"
^tagy/$
"
,
name
=
"
tags
"
)
def
tags
(
self
,
request
):
return
render
(
request
,
"
main/main_tags_page.html
"
,
context
=
self
.
get_tags_page_context
(
request
=
request
),
)
### RELATIONS
parent_page_types
=
[
"
main.MainHomePage
"
]
subpage_types
=
[
"
main.MainArticlePage
"
]
### OTHERS
class
Meta
:
verbose_name
=
"
Aktuality
"
class
MainProgramPage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
perex
=
models
.
TextField
()
program
=
StreamField
(
[(
"
program_group
"
,
blocks
.
ProgramGroupBlock
())],
verbose_name
=
"
Program
"
,
blank
=
True
,
)
### PANELS
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
"
perex
"
),
FieldPanel
(
"
program
"
)]
promote_panels
=
make_promote_panels
()
settings_panels
=
[]
### RELATIONS
parent_page_types
=
[
"
main.MainHomePage
"
]
subpage_types
=
[]
### OTHERS
class
Meta
:
verbose_name
=
"
Program
"
class
MainPeoplePage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
perex
=
models
.
TextField
()
people
=
StreamField
(
[(
"
people_group
"
,
blocks
.
PeopleGroupBlock
())],
verbose_name
=
"
Lidé
"
,
blank
=
True
,
)
### PANELS
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
"
perex
"
),
FieldPanel
(
"
people
"
)]
promote_panels
=
make_promote_panels
()
settings_panels
=
[]
### RELATIONS
parent_page_types
=
[
"
main.MainHomePage
"
]
subpage_types
=
[
"
main.MainPersonPage
"
]
### OTHERS
class
Meta
:
verbose_name
=
"
Lidé
"
class
MainPersonPage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
perex
=
models
.
TextField
()
text
=
RichTextField
()
settings_panels
=
[]
### RELATIONS
parent_page_types
=
[
"
main.MainPeoplePage
"
]
subpage_types
=
[]
### OTHERS
class
Meta
:
verbose_name
=
"
Detail osoby
"
# ordering = ("title",)
def
get_background_photo
(
self
):
"""
Vrací background_photo pro pozadí na stránce, pokud není nastaveno,
vezme falbback z homepage
"""
return
(
self
.
background_photo
if
self
.
background_photo
else
self
.
root_page
.
fallback_image
)
class
MainContactPage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
contact_people
=
StreamField
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment