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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
ac584475
Commit
ac584475
authored
Sep 5, 2022
by
OndraPetrzilka
Committed by
jan.bednarik
Sep 6, 2022
Browse files
Options
Downloads
Patches
Plain Diff
added field thumb image on district article page
parent
6f6cfd61
No related branches found
No related tags found
2 merge requests
!617
Release
,
!615
Feature/district page image
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
district/migrations/0100_districtarticlepage_thumb_image.py
+20
-0
20 additions, 0 deletions
district/migrations/0100_districtarticlepage_thumb_image.py
district/models.py
+20
-0
20 additions, 0 deletions
district/models.py
with
40 additions
and
0 deletions
district/migrations/0100_districtarticlepage_thumb_image.py
0 → 100644
+
20
−
0
View file @
ac584475
# Generated by Django 4.0.7 on 2022-09-05 12:16
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
wagtailimages
'
,
'
0024_index_image_file_hash
'
),
(
'
district
'
,
'
0099_alter_districtelectionprogrampage_guarantor
'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'
districtarticlepage
'
,
name
=
'
thumb_image
'
,
field
=
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
related_name
=
'
thumb_image
'
,
to
=
'
wagtailimages.image
'
,
verbose_name
=
'
náhledový obrázek
'
),
),
]
This diff is collapsed.
Click to expand it.
district/models.py
+
20
−
0
View file @
ac584475
...
...
@@ -351,6 +351,14 @@ class DistrictArticlePage(
)
is_black
=
models
.
BooleanField
(
"
Má tmavé pozadí?
"
,
default
=
False
)
tags
=
ClusterTaggableManager
(
through
=
DistrictArticleTag
,
blank
=
True
)
thumb_image
=
models
.
ForeignKey
(
"
wagtailimages.Image
"
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
,
verbose_name
=
"
náhledový obrázek
"
,
related_name
=
"
thumb_image
"
)
### PANELS
...
...
@@ -358,6 +366,7 @@ class DistrictArticlePage(
FieldPanel
(
"
author_page
"
),
FieldPanel
(
"
is_black
"
),
FieldPanel
(
"
tags
"
),
FieldPanel
(
"
thumb_image
"
)
]
promote_panels
=
make_promote_panels
(
...
...
@@ -375,6 +384,17 @@ class DistrictArticlePage(
class
Meta
:
verbose_name
=
"
Aktualita
"
def
clean
(
self
):
cleaned_data
=
super
().
clean
()
if
not
self
.
image
and
not
self
.
thumb_image
:
raise
ValidationError
(
"
Musí být nahraný buď obrázek nebo náhledový obrázek
"
)
elif
not
self
.
thumb_image
and
self
.
image
:
self
.
thumb_image
=
self
.
image
return
cleaned_data
else
:
return
cleaned_data
def
get_context
(
self
,
request
):
context
=
super
().
get_context
(
request
)
context
[
"
related_articles
"
]
=
(
...
...
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