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
fb0d5bbd
Commit
fb0d5bbd
authored
4 years ago
by
jarmil
Browse files
Options
Downloads
Patches
Plain Diff
REF: univerzalni SubpageMixin
parent
33063ba0
No related branches found
No related tags found
2 merge requests
!173
Release
,
!134
Weby pro MS
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
district/models.py
+8
-11
8 additions, 11 deletions
district/models.py
shared/models.py
+15
-3
15 additions, 3 deletions
shared/models.py
with
23 additions
and
14 deletions
district/models.py
+
8
−
11
View file @
fb0d5bbd
...
...
@@ -7,19 +7,16 @@ from wagtail.core.fields import StreamField
from
wagtail.core.models
import
Page
from
wagtailmetadata.models
import
MetadataPageMixin
from
shared.models
import
Article
,
PersonPage
from
shared.models
import
Article
,
SharedSubpageMixin
class
SubpageMixin
:
"""
Must be used in class definition before MetadataPageMixin!
"""
"""
Must be used in class definition before MetadataPageMixin!
Obsolete, misto nej pouzivat SharedSubpageMixin
TODO je pouze v migracich, po odstraneni z nich lze smazat
"""
@property
def
root_page
(
self
):
if
not
hasattr
(
self
,
"
_root_page
"
):
self
.
_root_page
=
(
self
.
get_ancestors
().
type
(
DistrictHomePage
).
specific
().
get
()
)
return
self
.
_root_page
pass
class
DistrictHomePage
(
MetadataPageMixin
,
Page
):
...
...
@@ -133,7 +130,7 @@ class DistrictHomePage(MetadataPageMixin, Page):
return
self
class
DistrictArticles
(
SubpageMixin
,
MetadataPageMixin
,
Page
):
class
DistrictArticles
(
Shared
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
max_items
=
models
.
IntegerField
(
...
...
@@ -162,7 +159,7 @@ class DistrictArticles(SubpageMixin, MetadataPageMixin, Page):
return
context
class
DistrictContact
(
SubpageMixin
,
MetadataPageMixin
,
Page
):
class
DistrictContact
(
Shared
SubpageMixin
,
MetadataPageMixin
,
Page
):
class
ContactItemBlock
(
blocks
.
StructBlock
):
name
=
blocks
.
CharBlock
(
label
=
"
Role
"
)
person
=
blocks
.
PageChooserBlock
(
...
...
This diff is collapsed.
Click to expand it.
shared/models.py
+
15
−
3
View file @
fb0d5bbd
...
...
@@ -9,11 +9,23 @@ from wagtail.images.edit_handlers import ImageChooserPanel
from
wagtailmetadata.models
import
MetadataPageMixin
class
SharedSubpageMixin
:
"""
Must be used in class definition before MetadataPageMixin!
"""
@property
def
root_page
(
self
):
if
not
hasattr
(
self
,
"
_root_page
"
):
# Vypada to hackove ale lze takto pouzit: dle dokumentace get_ancestors vraci stranky v poradi
# od rootu, tedy domovska stranka je druha v poradi
self
.
_root_page
=
self
.
get_ancestors
().
specific
()[
1
]
return
self
.
_root_page
class
ArticleTag
(
TaggedItemBase
):
content_object
=
ParentalKey
(
"
shared.Article
"
,
on_delete
=
models
.
CASCADE
)
class
Article
(
MetadataPageMixin
,
Page
):
class
Article
(
SharedSubpageMixin
,
MetadataPageMixin
,
Page
):
"""
Univerzalni clanek pro vsechny weby
"""
### FIELDS
...
...
@@ -47,7 +59,7 @@ class Article(MetadataPageMixin, Page):
verbose_name
=
"
Článek
"
class
PersonPage
(
MetadataPageMixin
,
Page
):
class
PersonPage
(
SharedSubpageMixin
,
MetadataPageMixin
,
Page
):
"""
Stranka Pirata.
Snaha je zadavat tady minimum informaci o osobe a zbytek vytahovat via API z jinych zdroju,
neb nechceme dalsi databazi lidi.
...
...
@@ -114,7 +126,7 @@ class PersonPage(MetadataPageMixin, Page):
return
context
class
PeoplePage
(
MetadataPageMixin
,
Page
):
class
PeoplePage
(
SharedSubpageMixin
,
MetadataPageMixin
,
Page
):
"""
Stranka se zobrazenim lidi v dane organizaci
TOOD: subpagemixin
"""
...
...
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