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
5bd792bc
Commit
5bd792bc
authored
2 years ago
by
OndraRehounek
Browse files
Options
Downloads
Patches
Plain Diff
main: region field added
parent
31b017f0
No related branches found
No related tags found
2 merge requests
!607
Pirati.cz
,
!575
Feature/pirati cz
Pipeline
#9339
passed
2 years ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main/migrations/0007_mainarticlepage_region_and_more.py
+51
-0
51 additions, 0 deletions
main/migrations/0007_mainarticlepage_region_and_more.py
main/models.py
+55
-24
55 additions, 24 deletions
main/models.py
with
106 additions
and
24 deletions
main/migrations/0007_mainarticlepage_region_and_more.py
0 → 100644
+
51
−
0
View file @
5bd792bc
# Generated by Django 4.0.7 on 2022-08-23 10:07
import
django.db.models.deletion
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
"
main
"
,
"
0006_mainpersonpage_after_name_mainpersonpage_before_name_and_more
"
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
"
mainarticlepage
"
,
name
=
"
region
"
,
field
=
models
.
IntegerField
(
blank
=
True
,
choices
=
[
(
"
PHA
"
,
"
Hlavní město Praha
"
),
(
"
JHC
"
,
"
Jihočeský kraj
"
),
(
"
JHM
"
,
"
Jihomoravský kraj
"
),
(
"
KVK
"
,
"
Karlovarský kraj
"
),
(
"
VYS
"
,
"
Kraj Vysočina
"
),
(
"
KHK
"
,
"
Královéhradecký kraj
"
),
(
"
LBK
"
,
"
Liberecký kraj
"
),
(
"
MSK
"
,
"
Moravskoslezský kraj
"
),
(
"
OLK
"
,
"
Olomoucký kraj
"
),
(
"
PAK
"
,
"
Pardubický kraj
"
),
(
"
PLK
"
,
"
Plzeňský kraj
"
),
(
"
STC
"
,
"
Středočeský kraj
"
),
(
"
ULK
"
,
"
Ústecký kraj
"
),
(
"
ZLK
"
,
"
Zlínský kraj
"
),
],
help_text
=
"
Kraj, ke kterému se článek vztahuje
"
,
null
=
True
,
verbose_name
=
"
Kraj
"
,
),
),
migrations
.
AlterField
(
model_name
=
"
mainarticlepage
"
,
name
=
"
author_page
"
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
"
main.mainpersonpage
"
,
verbose_name
=
"
Stránka autora (osoby)
"
,
),
),
]
This diff is collapsed.
Click to expand it.
main/models.py
+
55
−
24
View file @
5bd792bc
...
...
@@ -15,6 +15,7 @@ from wagtail.core.fields import RichTextField, StreamField
from
wagtail.core.models
import
Page
from
wagtailmetadata.models
import
MetadataPageMixin
from
elections2021.constants
import
REGION_CHOICES
# pozor, import ze sousedního modulu
from
shared.const
import
RICH_TEXT_DEFAULT_FEATURES
from
shared.forms
import
SubscribeForm
from
shared.models
import
(
...
...
@@ -26,9 +27,9 @@ from shared.models import (
)
from
shared.utils
import
make_promote_panels
,
subscribe_to_newsletter
from
tuning
import
admin_help
from
twitter_utils.models
import
Tweet
from
.
import
blocks
from
twitter_utils.models
import
Tweet
class
MainHomePage
(
MenuMixin
,
ExtendedMetadataHomePageMixin
,
MetadataPageMixin
,
Page
):
...
...
@@ -172,7 +173,14 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
class
MainWorkPage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
perex
=
models
.
TextField
()
timeline
=
StreamField
(
[(
"
article_list
"
,
PageChooserBlock
(
page_type
=
"
main.MainArticlePage
"
,
label
=
"
Vybrat aktualitu
"
))],
[
(
"
article_list
"
,
PageChooserBlock
(
page_type
=
"
main.MainArticlePage
"
,
label
=
"
Vybrat aktualitu
"
),
)
],
verbose_name
=
"
Timeline
"
,
blank
=
True
,
)
...
...
@@ -183,10 +191,7 @@ class MainWorkPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, P
subpage_types
=
[]
### PANELS
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
'
perex
'
),
FieldPanel
(
'
timeline
'
)
]
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
"
perex
"
),
FieldPanel
(
"
timeline
"
)]
### OTHERS
...
...
@@ -205,7 +210,18 @@ class MainArticlePage(
### FIELDS
author_page
=
models
.
ForeignKey
(
"
main.MainPersonPage
"
,
on_delete
=
models
.
SET_NULL
,
null
=
True
,
blank
=
True
"
main.MainPersonPage
"
,
on_delete
=
models
.
SET_NULL
,
null
=
True
,
blank
=
True
,
verbose_name
=
"
Stránka autora (osoby)
"
,
)
region
=
models
.
IntegerField
(
choices
=
REGION_CHOICES
,
null
=
True
,
blank
=
True
,
verbose_name
=
"
Kraj
"
,
help_text
=
"
Kraj, ke kterému se článek vztahuje
"
,
)
tags
=
ClusterTaggableManager
(
through
=
MainArticleTag
,
blank
=
True
)
...
...
@@ -335,13 +351,24 @@ class MainPeoplePage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
class
MainPersonPage
(
ExtendedMetadataPageMixin
,
SubpageMixin
,
MetadataPageMixin
,
Page
):
### FIELDS
before_name
=
models
.
CharField
(
"
Tituly před jménem
"
,
max_length
=
16
,
blank
=
True
,
null
=
True
)
after_name
=
models
.
CharField
(
"
Tituly za jménem
"
,
max_length
=
16
,
blank
=
True
,
null
=
True
)
position
=
models
.
CharField
(
"
Pozice/povolání
"
,
max_length
=
128
,
blank
=
True
,
null
=
True
)
before_name
=
models
.
CharField
(
"
Tituly před jménem
"
,
max_length
=
16
,
blank
=
True
,
null
=
True
)
after_name
=
models
.
CharField
(
"
Tituly za jménem
"
,
max_length
=
16
,
blank
=
True
,
null
=
True
)
position
=
models
.
CharField
(
"
Pozice/povolání
"
,
max_length
=
128
,
blank
=
True
,
null
=
True
)
perex
=
models
.
TextField
()
text
=
RichTextField
()
twitter_username
=
models
.
CharField
(
"
Uživatelské jméno twitter pro získání příspěvků
"
,
blank
=
True
,
null
=
True
,
max_length
=
32
)
twitter_username
=
models
.
CharField
(
"
Uživatelské jméno twitter pro získání příspěvků
"
,
blank
=
True
,
null
=
True
,
max_length
=
32
,
)
email
=
models
.
CharField
(
"
E-mail
"
,
max_length
=
128
,
blank
=
True
,
null
=
True
)
phone
=
models
.
CharField
(
"
Telefonní kontakt
"
,
max_length
=
16
,
blank
=
True
,
null
=
True
)
...
...
@@ -359,23 +386,27 @@ class MainPersonPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
### PANELS
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
'
before_name
'
),
FieldPanel
(
'
after_name
'
),
FieldPanel
(
'
position
'
),
FieldPanel
(
'
perex
'
),
FieldPanel
(
'
twitter_username
'
),
FieldPanel
(
'
text
'
),
FieldPanel
(
'
email
'
),
FieldPanel
(
'
phone
'
),
FieldPanel
(
'
facebook
'
),
FieldPanel
(
'
twitter
'
),
FieldPanel
(
'
instagram
'
),
FieldPanel
(
"
before_name
"
),
FieldPanel
(
"
after_name
"
),
FieldPanel
(
"
position
"
),
FieldPanel
(
"
perex
"
),
FieldPanel
(
"
twitter_username
"
),
FieldPanel
(
"
text
"
),
FieldPanel
(
"
email
"
),
FieldPanel
(
"
phone
"
),
FieldPanel
(
"
facebook
"
),
FieldPanel
(
"
twitter
"
),
FieldPanel
(
"
instagram
"
),
]
def
get_context
(
self
,
request
):
context
=
super
(
MainPersonPage
,
self
).
get_context
(
request
)
context
[
'
article_page_list
'
]
=
MainArticlePage
.
objects
.
filter
(
author_page
=
self
.
id
)
context
[
'
tweet_list
'
]
=
Tweet
.
objects
.
filter
(
author_username
=
self
.
twitter_username
)
context
[
"
article_page_list
"
]
=
MainArticlePage
.
objects
.
filter
(
author_page
=
self
.
id
)
context
[
"
tweet_list
"
]
=
Tweet
.
objects
.
filter
(
author_username
=
self
.
twitter_username
)
return
context
### OTHERS
...
...
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