From 0f4189ad9260445627932b2837e541e09cc36638 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 4 Nov 2024 12:27:03 +0100
Subject: [PATCH] fix ordering

---
 district/blocks.py                            |  4 ++--
 .../0303_alter_districtcenterpage_content.py  | 20 ++++++++++++++++
 .../templatetags/district_people_filters.py   |  2 +-
 ...topusperson_options_octopusperson_order.py | 23 +++++++++++++++++++
 .../0013_alter_octopusperson_order.py         | 18 +++++++++++++++
 shared/models/main.py                         |  4 ++++
 shared/people_import.py                       |  7 +++---
 7 files changed, 72 insertions(+), 6 deletions(-)
 create mode 100644 district/migrations/0303_alter_districtcenterpage_content.py
 create mode 100644 shared/migrations/0012_alter_octopusperson_options_octopusperson_order.py
 create mode 100644 shared/migrations/0013_alter_octopusperson_order.py

diff --git a/district/blocks.py b/district/blocks.py
index 1f977dee..254119c8 100644
--- a/district/blocks.py
+++ b/district/blocks.py
@@ -152,7 +152,7 @@ class OctopusMixin(blocks.StructBlock):
             DistrictOctopusPersonPage.objects.filter(
                 originating_group=value["group_shortcut"]
             )
-            .order_by("title")
+            .order_by("person__order", "title")
             .all()
         )
 
@@ -216,7 +216,7 @@ class OctopusTeamBlock(OctopusMixin):
 
         context["person_list"] = (
             DistrictOctopusPersonPage.objects.filter(filter)
-            .order_by("title")
+            .order_by("person__order", "title")
             .all()
         )
 
diff --git a/district/migrations/0303_alter_districtcenterpage_content.py b/district/migrations/0303_alter_districtcenterpage_content.py
new file mode 100644
index 00000000..7026e14e
--- /dev/null
+++ b/district/migrations/0303_alter_districtcenterpage_content.py
@@ -0,0 +1,20 @@
+# Generated by Django 5.0.7 on 2024-11-04 11:09
+
+import shared.blocks.children.chart
+import wagtail.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('district', '0302_auto_20241103_1453'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='districtcenterpage',
+            name='content',
+            field=wagtail.fields.StreamField([('text', 0), ('advanced_text', 4), ('two_columns_text', 7), ('headline', 12), ('headline_with_picture', 15), ('picture_list', 19), ('flip_cards', 30), ('table', 31), ('popout_table', 32), ('gallery', 35), ('figure', 38), ('card', 61), ('two_columns', 70), ('three_columns', 72), ('youtube', 73), ('map_point', 51), ('map_collection', 58), ('button', 65), ('button_group', 67), ('popout_point', 76), ('chart', 98), ('related', 101), ('related_links', 101), ('badge_list', 106), ('badge', 104), ('contact', 111)], blank=True, block_lookup={0: ('wagtail.blocks.RichTextBlock', (), {'features': ['h2', 'h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], 'group': '1. Text', 'label': 'Textový editor', 'template': 'styleguide2/includes/atoms/text/prose_richtext.html'}), 1: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('left', 'vlevo'), ('center', 'uprostřed'), ('right', 'vpravo')], 'label': 'zarovnání'}), 2: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('black_on_white', 'černá na bílé'), ('black_on_yellow', 'černá na žluté'), ('white_on_black', 'bílá na černé'), ('white_on_blue', 'bílá na modré'), ('white_on_cyan', 'bílá na tyrkysové'), ('white_on_violet', 'bílá na fialové')], 'label': 'barva'}), 3: ('wagtail.blocks.RichTextBlock', (), {'features': ['h2', 'h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], 'group': '1. Text', 'label': 'Textový editor'}), 4: ('wagtail.blocks.StructBlock', [[('align', 1), ('color', 2), ('text', 3)]], {}), 5: ('wagtail.blocks.RichTextBlock', (), {'features': ['h2', 'h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], 'label': 'levý sloupec'}), 6: ('wagtail.blocks.RichTextBlock', (), {'features': ['h2', 'h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], 'label': 'pravý sloupec'}), 7: ('wagtail.blocks.StructBlock', [[('left_text', 5), ('right_text', 6)]], {}), 8: ('wagtail.blocks.CharBlock', (), {'label': 'Nadpis', 'max_length': 300, 'required': True}), 9: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('h1', 'H1'), ('h2', 'H2'), ('h3', 'H3'), ('h4', 'H4'), ('h5', 'H5'), ('h6', 'H6')], 'help_text': 'Čím nižší číslo, tím vyšší úroveň.', 'label': 'Úroveň nadpisu'}), 10: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('head-alt-xl', 'Velký, Bebas Neue - 6XL'), ('head-alt-lg', 'Střední, Bebas Neue - 4XL'), ('head-alt-md', 'Základní velikost - Roboto - MD'), ('head-alt-sm', 'Malý - Roboto - SM'), ('head-alt-xs', 'Extra malý - Roboto - XS')], 'help_text': 'Náhled si prohlédněte na https://styleguide2.pirati.cz/pattern/patterns/atoms/text/headings.html.', 'label': 'Velikost'}), 11: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('auto', 'Automaticky'), ('center', 'Na střed')], 'label': 'Zarovnání'}), 12: ('wagtail.blocks.StructBlock', [[('headline', 8), ('tag', 9), ('style', 10), ('align', 11)]], {}), 13: ('wagtail.blocks.CharBlock', (), {'label': 'nadpis'}), 14: ('wagtail.images.blocks.ImageChooserBlock', (), {'help_text': 'rozměr na výšku 75px nebo více (obrázek bude zmenšen na výšku 75px)', 'label': 'obrázek'}), 15: ('wagtail.blocks.StructBlock', [[('color', 2), ('title', 13), ('picture', 14)]], {}), 16: ('wagtail.blocks.RichTextBlock', (), {'features': ['h2', 'h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], 'label': 'Odstavec'}), 17: ('wagtail.blocks.ListBlock', (16,), {'label': 'Odstavce'}), 18: ('wagtail.images.blocks.ImageChooserBlock', (), {'help_text': 'Rozměr 30x30px nebo více (obrázek bude zmenšen na 30x30px)', 'label': 'Obrázek'}), 19: ('wagtail.blocks.StructBlock', [[('color', 2), ('items', 17), ('picture', 18)]], {}), 20: ('wagtail.blocks.CharBlock', (), {'default': 'FEC900', 'help_text': "Kód barvy lze vytvořit např. <a href='https://mdn.github.io/css-examples/tools/color-picker/' target='_blank'>zde</a>.", 'label': 'Barva pozadí'}), 21: ('wagtail.images.blocks.ImageChooserBlock', (), {'help_text': 'Nahrazuje pozadí. Nelze vybrat obě najednou.', 'label': 'Obrázek', 'required': False}), 22: ('wagtail.images.blocks.ImageChooserBlock', (), {'help_text': 'Nahrazuje obrázek. Nelze vybrat obě najednou.', 'label': 'Pozadí', 'required': False}), 23: ('wagtail.blocks.TextBlock', (), {'help_text': 'Řádkování je manuální.', 'label': 'Nadpis'}), 24: ('wagtail.blocks.CharBlock', (), {'default': '000000', 'help_text': "Kód barvy lze vytvořit např. <a href='https://mdn.github.io/css-examples/tools/color-picker/' target='_blank'>zde</a>.", 'label': 'Barva textu'}), 25: ('wagtail.blocks.RichTextBlock', (), {'label': 'Obsah'}), 26: ('wagtail.blocks.CharBlock', (), {'help_text': 'Pokud není vyplněn, tlačítko se neukáže.', 'label': 'Nadpis tlačítka', 'required': False}), 27: ('wagtail.blocks.CharBlock', (), {'label': 'Odkaz tlačítka', 'required': False}), 28: ('wagtail.blocks.StructBlock', [[('bg_color', 20), ('image', 21), ('background', 22), ('title', 23), ('title_color', 24), ('content', 25), ('button_text', 26), ('button_url', 27)]], {'label': 'Karta'}), 29: ('wagtail.blocks.ListBlock', (28,), {'label': 'Karty'}), 30: ('wagtail.blocks.StructBlock', [[('cards', 29)]], {}), 31: ('wagtail.contrib.table_block.blocks.TableBlock', (), {'group': '3. Ostatní', 'label': 'Tabulka', 'template': 'styleguide2/includes/atoms/table/table.html'}), 32: ('wagtail.contrib.table_block.blocks.TableBlock', (), {'group': '3. Ostatní', 'label': 'Rozbalovací tabulka', 'template': 'styleguide2/includes/atoms/table/popout_table.html'}), 33: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'obrázek', 'required': True}), 34: ('wagtail.blocks.ListBlock', (33,), {'group': '3. Ostatní', 'icon': 'image', 'label': 'Galerie'}), 35: ('wagtail.blocks.StructBlock', [[('gallery_items', 34)]], {'label': 'Galerie'}), 36: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'Obrázek', 'required': True}), 37: ('wagtail.blocks.TextBlock', (), {'label': 'Popisek', 'required': False}), 38: ('wagtail.blocks.StructBlock', [[('img', 36), ('caption', 37)]], {}), 39: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'Obrázek', 'required': False}), 40: ('wagtail.blocks.TextBlock', (), {'label': 'Titulek', 'required': False}), 41: ('wagtail.images.blocks.ImageChooserBlock', (), {'help_text': 'Není třeba vyplňovat, náhled bude dohledán automaticky.', 'label': 'Náhled videa (automatické pole)', 'required': False}), 42: ('wagtail.blocks.URLBlock', (), {'help_text': 'Odkaz na YouTube video bude automaticky zkonvertován na ID videa a NEBUDE uložen.', 'label': 'Odkaz na video', 'required': False}), 43: ('wagtail.blocks.CharBlock', (), {'help_text': 'Není třeba vyplňovat, bude automaticky načteno z odkazu.', 'label': 'ID videa (automatické pole)', 'required': False}), 44: ('wagtail.blocks.StructBlock', [[('poster_image', 41), ('video_url', 42), ('video_id', 43)]], {}), 45: ('wagtail.blocks.DecimalBlock', (), {'help_text': 'Např. 50.04075', 'label': 'Zeměpisná šířka'}), 46: ('wagtail.blocks.DecimalBlock', (), {'help_text': 'Např. 15.77659', 'label': 'Zeměpisná délka'}), 47: ('wagtail.blocks.CharBlock', (), {'default': '000000', 'help_text': 'Zadejte barvu pomocí HEX notace (bez # na začátku).', 'label': 'Barva špendlíku (HEX)'}), 48: ('wagtail.blocks.IntegerBlock', (), {'default': 15, 'label': 'Výchozí zoom', 'max_value': 18, 'min_value': 1}), 49: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('osm-mapnik', 'OSM Mapnik'), ('stadia-osm-bright', 'Stadia OSM Bright'), ('stadia-outdoors', 'Stadia Outdoors'), ('mapbox-streets', 'Mapbox Streets'), ('mapbox-outdoors', 'Mapbox Outdoors'), ('mapbox-light', 'Mapbox Light'), ('mapbox-dark', 'Mapbox Dark'), ('mapbox-satellite', 'Mapbox Satellite'), ('mapbox-pirate', 'Mapbox Pirate Theme')], 'label': 'Styl'}), 50: ('wagtail.blocks.IntegerBlock', (), {'label': 'Výška v px', 'max_value': 1000, 'min_value': 100}), 51: ('wagtail.blocks.StructBlock', [[('lat', 45), ('lon', 46), ('hex_color', 47), ('zoom', 48), ('style', 49), ('height', 50)]], {'label': 'Špendlík na mapě'}), 52: ('wagtail.blocks.CharBlock', (), {'label': 'Titulek', 'required': True}), 53: ('wagtail.blocks.TextBlock', (), {'help_text': "Vložte surový GeoJSON objekt typu 'Feature'. Vyrobit jej můžete např. pomocí online služby geojson.io. Pokud u objektu poskytnete properties 'title' a 'description', zobrazí se jak na mapě, tak i v detailu.", 'label': 'Geodata', 'required': True}), 54: ('wagtail.blocks.URLBlock', (), {'label': 'Odkaz', 'required': False}), 55: ('wagtail.blocks.CharBlock', (), {'default': '000000', 'help_text': 'Zadejte barvu pomocí HEX notace (bez # na začátku).', 'label': 'Barva (HEX)'}), 56: ('wagtail.blocks.StructBlock', [[('title', 52), ('description', 37), ('geojson', 53), ('image', 39), ('link', 54), ('hex_color', 55)]], {'required': True}), 57: ('wagtail.blocks.ListBlock', (56,), {'label': 'Součásti'}), 58: ('wagtail.blocks.StructBlock', [[('features', 57), ('zoom', 48), ('style', 49), ('height', 50)]], {'label': 'Mapová kolekce'}), 59: ('wagtail.blocks.StreamBlock', [[('text', 3), ('table', 31), ('figure', 38), ('youtube', 44), ('map_point', 51), ('map_collection', 58)]], {'label': 'Obsah', 'required': False}), 60: ('wagtail.blocks.PageChooserBlock', (), {'label': 'Stránka', 'required': False}), 61: ('wagtail.blocks.StructBlock', [[('img', 39), ('headline', 40), ('content', 59), ('page', 60), ('link', 54)]], {}), 62: ('wagtail.blocks.CharBlock', (), {'label': 'Titulek', 'max_length': 128, 'required': True}), 63: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('black', 'Černá'), ('white', 'Bílá'), ('pirati-yellow', 'Žlutá'), ('grey-125', 'Světle šedá'), ('blue-300', 'Modrá'), ('cyan-200', 'Tyrkysová'), ('green-400', 'Zelená'), ('violet-400', 'Vínová'), ('red-600', 'Červená')], 'label': 'Barva'}), 64: ('wagtail.blocks.BooleanBlock', (), {'default': True, 'help_text': 'Pokud je zapnuto, tlačítko při najetí kurzorem ukáže žlutou šipku.', 'label': 'Animovat na hover', 'required': False}), 65: ('wagtail.blocks.StructBlock', [[('title', 62), ('color', 63), ('hoveractive', 64), ('page', 60), ('link', 54), ('align', 11)]], {}), 66: ('wagtail.blocks.ListBlock', (65,), {'label': 'Tlačítka'}), 67: ('wagtail.blocks.StructBlock', [[('buttons', 66)]], {}), 68: ('wagtail.blocks.StreamBlock', [[('text', 3), ('table', 31), ('card', 61), ('figure', 38), ('youtube', 44), ('map_point', 51), ('map_collection', 58), ('button', 65), ('button_group', 67)]], {'label': 'Obsah levého sloupce', 'required': True}), 69: ('wagtail.blocks.StreamBlock', [[('text', 3), ('table', 31), ('card', 61), ('figure', 38), ('youtube', 44), ('map_point', 51), ('map_collection', 58), ('button', 65), ('button_group', 67)]], {'label': 'Obsah pravého sloupce', 'required': True}), 70: ('wagtail.blocks.StructBlock', [[('left_column_content', 68), ('right_column_content', 69)]], {}), 71: ('wagtail.blocks.StreamBlock', [[('text', 3), ('table', 31), ('card', 61), ('figure', 38), ('youtube', 44), ('map_point', 51), ('map_collection', 58), ('button', 65), ('button_group', 67)]], {'label': 'Obsah prostředního sloupce', 'required': True}), 72: ('wagtail.blocks.StructBlock', [[('left_column_content', 68), ('middle_column_content', 71), ('right_column_content', 69)]], {}), 73: ('wagtail.blocks.StructBlock', [[('poster_image', 41), ('video_url', 42), ('video_id', 43)]], {'label': 'YouTube video'}), 74: ('wagtail.blocks.CharBlock', (), {'label': 'Název', 'required': True}), 75: ('wagtail.blocks.StreamBlock', [[('text', 0), ('headline', 12), ('table', 31)]], {'label': 'Obsah'}), 76: ('wagtail.blocks.StructBlock', [[('name', 74), ('content', 75)]], {}), 77: ('wagtail.blocks.CharBlock', (), {'label': 'Název', 'max_length': 120}), 78: ('wagtail.blocks.ChoiceBlock', [], {'choices': [('bar', 'Graf se sloupci'), ('horizontalBar', 'Graf s vodorovnými sloupci'), ('pie', 'Koláčový graf'), ('doughnut', 'Donutový graf'), ('polarArea', 'Graf polární oblasti'), ('radar', 'Radarový graf'), ('line', 'Graf s liniemi')], 'label': 'Typ'}), 79: ('wagtail.blocks.BooleanBlock', (), {'help_text': 'Mění vzhled pouze u linových grafů.', 'label': 'Schovat body', 'required': False}), 80: ('wagtail.blocks.CharBlock', (), {'label': 'Skupina', 'max_length': 40}), 81: ('wagtail.blocks.ListBlock', (80,), {'blank': True, 'collapsed': True, 'default': [], 'label': 'Místně definované skupiny', 'required': False}), 82: ('wagtail.blocks.CharBlock', (), {'label': 'Označení zdroje dat', 'max_length': 120}), 83: ('wagtail.blocks.IntegerBlock', (), {}), 84: ('wagtail.blocks.ListBlock', (83,), {'default': [0], 'label': 'Data'}), 85: ('wagtail.blocks.StructBlock', [[('label', 82), ('data', 84)]], {}), 86: ('wagtail.blocks.ListBlock', (85,), {'blank': True, 'collapsed': True, 'default': [], 'label': 'Místní zdroje dat', 'required': False}), 87: ('wagtail.blocks.MultipleChoiceBlock', [], {'choices': shared.blocks.children.chart.get_redmine_projects, 'label': 'Projekty'}), 88: ('wagtail.blocks.BooleanBlock', (), {'label': 'Jen otevřené', 'required': False}), 89: ('wagtail.blocks.BooleanBlock', (), {'label': 'Jen uzavřené', 'required': False}), 90: ('wagtail.blocks.DateBlock', (), {'label': 'Min. datum vytvoření', 'required': True}), 91: ('wagtail.blocks.DateBlock', (), {'label': 'Max. datum vytvoření', 'required': True}), 92: ('wagtail.blocks.CharBlock', (), {'help_text': 'Např. <=2023-01-01. Více informací na pi2.cz/redmine-api', 'label': 'Filtr pro datum aktualizace', 'max_length': 128, 'required': False}), 93: ('wagtail.blocks.CharBlock', (), {'label': 'Označení úkolů uvnitř grafu', 'max_length': 128, 'required': True}), 94: ('wagtail.blocks.BooleanBlock', (), {'label': 'Rozdělit podle projektu', 'required': False}), 95: ('wagtail.blocks.BooleanBlock', (), {'label': 'Pouze růst nahoru', 'required': False}), 96: ('wagtail.blocks.StructBlock', [[('projects', 87), ('is_open', 88), ('is_closed', 89), ('created_on_min_date', 90), ('created_on_max_date', 91), ('updated_on', 92), ('issue_label', 93), ('split_per_project', 94), ('only_grow', 95)]], {'label': 'Redmine úkoly'}), 97: ('wagtail.blocks.ListBlock', (96,), {'blank': True, 'default': [], 'help_text': 'Úkoly, podle doby vytvoření. Pokud definuješ více zdrojů, datumy v nich musí být stejné.', 'label': 'Zdroje dat z Redmine (úkoly)', 'required': False}), 98: ('wagtail.blocks.StructBlock', [[('title', 77), ('chart_type', 78), ('hide_points', 79), ('local_labels', 81), ('local_datasets', 86), ('redmine_issue_datasets', 97)]], {}), 99: ('wagtail.blocks.PageChooserBlock', ('district.DistrictArticlePage',), {'label': 'Aktualita', 'required': True}), 100: ('wagtail.blocks.ListBlock', (99,), {'label': 'Seznam aktualit', 'required': True}), 101: ('wagtail.blocks.StructBlock', [[('articles', 100)]], {}), 102: ('wagtail.blocks.PageChooserBlock', (), {'label': 'Osoba', 'page_type': ['district.DistrictPersonPage', 'district.DistrictOctopusPersonPage', 'district.DistrictManualOctopusPersonPage'], 'required': True}), 103: ('wagtail.blocks.CharBlock', (), {'help_text': 'Vlastní popisek na vizitce. Pokud není uvedeno, použije se výchozí profese osoby.', 'label': 'Popisek', 'required': False}), 104: ('wagtail.blocks.StructBlock', [[('person', 102), ('caption', 103)]], {}), 105: ('wagtail.blocks.ListBlock', (104,), {'label': 'Vizitky'}), 106: ('wagtail.blocks.StructBlock', [[('people', 105)]], {}), 107: ('wagtail.blocks.CharBlock', (), {'label': 'Název pozice', 'required': False}), 108: ('wagtail.blocks.PageChooserBlock', (), {'label': 'Osoba', 'page_type': ['district.DistrictPersonPage', 'district.DistrictOctopusPersonPage', 'district.DistrictManualOctopusPersonPage']}), 109: ('wagtail.blocks.StructBlock', [[('position', 107), ('person', 108)]], {}), 110: ('wagtail.blocks.ListBlock', (109,), {}), 111: ('wagtail.blocks.StructBlock', [[('title', 52), ('contact_list', 110)]], {})}, verbose_name='Obsah'),
+        ),
+    ]
diff --git a/district/templatetags/district_people_filters.py b/district/templatetags/district_people_filters.py
index 833bc9ee..ce7ccbcf 100644
--- a/district/templatetags/district_people_filters.py
+++ b/district/templatetags/district_people_filters.py
@@ -21,4 +21,4 @@ def get_block_octopus_person_list(block):
         )
     )
 
-    return DistrictOctopusPersonPage.objects.filter(filter).order_by("title").distinct("title").all()
+    return DistrictOctopusPersonPage.objects.filter(filter).order_by("person__order", "title").distinct().all()
diff --git a/shared/migrations/0012_alter_octopusperson_options_octopusperson_order.py b/shared/migrations/0012_alter_octopusperson_options_octopusperson_order.py
new file mode 100644
index 00000000..8658c1c3
--- /dev/null
+++ b/shared/migrations/0012_alter_octopusperson_options_octopusperson_order.py
@@ -0,0 +1,23 @@
+# Generated by Django 5.0.7 on 2024-11-04 11:09
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('shared', '0011_octopusperson_position'),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name='octopusperson',
+            options={'ordering': ['order']},
+        ),
+        migrations.AddField(
+            model_name='octopusperson',
+            name='order',
+            field=models.IntegerField(default=0, verbose_name='Řadící pozice'),
+            preserve_default=False,
+        ),
+    ]
diff --git a/shared/migrations/0013_alter_octopusperson_order.py b/shared/migrations/0013_alter_octopusperson_order.py
new file mode 100644
index 00000000..656f7e77
--- /dev/null
+++ b/shared/migrations/0013_alter_octopusperson_order.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.7 on 2024-11-04 11:09
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('shared', '0012_alter_octopusperson_options_octopusperson_order'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='octopusperson',
+            name='order',
+            field=models.IntegerField(default=0, verbose_name='Řadící pozice'),
+        ),
+    ]
diff --git a/shared/models/main.py b/shared/models/main.py
index d50abc7d..f2c2a027 100644
--- a/shared/models/main.py
+++ b/shared/models/main.py
@@ -2197,6 +2197,7 @@ class CustomLogoMixin(models.Model):
 
 class OctopusPerson(models.Model):
     octopus_id = models.CharField("ID v chobotnici", max_length=32)
+    order = models.IntegerField("Řadící pozice", default=0)
 
     username = models.CharField("Username", max_length=128)
 
@@ -2325,5 +2326,8 @@ class OctopusPerson(models.Model):
 
         return f"{username} ({display_name})"
 
+    class Meta:
+        ordering = ["order"]
+
 
 # --- END Django-only models ---
diff --git a/shared/people_import.py b/shared/people_import.py
index 18239f75..22af67da 100644
--- a/shared/people_import.py
+++ b/shared/people_import.py
@@ -39,6 +39,7 @@ class ImporterMixin:
             "email": profile["email"],
             "phone": profile["phone"],
             "position": profile.get("position"),
+            "order": profile.get("order"),
             "facebook_url": profile["facebookUrl"],
             "flickr_url": profile["flickrUrl"],
             "instagram_url": profile["instagramUrl"],
@@ -458,10 +459,7 @@ class PeopleTeamImporter(ImporterMixin):
             for membership in sorted(
                 node["node"]["memberships"],
                 key=lambda membership: int(membership.get("roleOrder", 0)),
-                reverse=True
             ):
-                print(self.team_roles, membership)
-
                 # Can't do this in the query (yet), so just filter here
 
                 if len(self.team_roles) != 0 and membership["roleDisplay"] not in self.team_roles:
@@ -471,6 +469,7 @@ class PeopleTeamImporter(ImporterMixin):
                     {
                         "id": membership["person"]["id"],
                         "role": membership["roleDisplay"],
+                        "order": int(membership.get("roleOrder", 0)),
                     }
                 )
 
@@ -482,6 +481,7 @@ class PeopleTeamImporter(ImporterMixin):
         for person in people_ids:
             id = person["id"]
             position = person["role"]
+            order = person["order"]
 
             prirotizied_profiles = []
 
@@ -501,6 +501,7 @@ class PeopleTeamImporter(ImporterMixin):
                 people_profiles[id] = None
             else:
                 people_profiles[id]["position"] = position
+                people_profiles[id]["order"] = order
 
         return people_profiles
 
-- 
GitLab