Skip to content
Snippets Groups Projects
Commit 1e6bf2ba authored by jan.bednarik's avatar jan.bednarik
Browse files

elections2021: Program points default order

parent b1a77150
Branches
No related tags found
2 merge requests!265release,!264Volby
Pipeline #3738 passed
......@@ -47,6 +47,7 @@ from ...models import Elections2021ProgramPointPage
OLD_TITLE = "old_title"
TITLE = "title"
ORDER = "order"
FIELDNAMES = (
"x1",
......@@ -91,6 +92,7 @@ FIELDNAMES = (
MINISTRY_HEALTH,
MINISTRY_AGRICULTURE,
MINISTRY_ENVIRONMENT,
ORDER,
)
......@@ -153,6 +155,7 @@ class Command(BaseCommand):
page.weight_ministry_health = int(row[MINISTRY_HEALTH])
page.weight_ministry_agriculture = int(row[MINISTRY_AGRICULTURE])
page.weight_ministry_environment = int(row[MINISTRY_ENVIRONMENT])
page.default_order = int(row[ORDER])
revision = page.save_revision()
if was_live and not had_unpublished_changes:
......
# Generated by Django 3.2.2 on 2021-05-18 09:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("elections2021", "0027_auto_20210518_0147"),
]
operations = [
migrations.AddField(
model_name="elections2021programpointpage",
name="default_order",
field=models.IntegerField(default=0, verbose_name="výchozí řazení"),
),
]
......@@ -1158,7 +1158,11 @@ class Elections2021ProgramPage(
@route(r"^$")
def plan_all(self, request):
points = Elections2021ProgramPointPage.objects.live().specific()
points = (
Elections2021ProgramPointPage.objects.live()
.specific()
.order_by("-default_order")
)
points = Paginator(points, PROGRAM_POINTS_PER_PAGE).get_page(
request.GET.get("page")
)
......@@ -1466,6 +1470,8 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page):
blank=True,
)
default_order = models.IntegerField("výchozí řazení", default=0)
# target weights
weight_childless = models.IntegerField("váha bezdětní", default=0)
weight_parents = models.IntegerField("váha rodiče", default=0)
......@@ -1581,6 +1587,7 @@ class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page):
]
weights_panels = [
FieldPanel("default_order"),
MultiFieldPanel(
[
FieldPanel("weight_childless"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment