diff --git a/district/management/commands/octopus_people_import.py b/district/management/commands/octopus_people_import.py index 83b7bc701a84ce76222b2e219bf16d8f910c81ff..3229e64e255edd497b154249cd049311d859ca4e 100644 --- a/district/management/commands/octopus_people_import.py +++ b/district/management/commands/octopus_people_import.py @@ -51,4 +51,6 @@ class Command(BaseCommand): ) for person_page in DistrictManualOctopusPersonPage.objects.all(): - import_manual_person.delay(person_page.id, collection_id) + import_manual_person.delay( + person_page.id, person_page.root_page.image_collection_id + ) diff --git a/district/static/district/css/district_custom_admin.css b/district/static/district/css/district_custom_admin.css new file mode 100644 index 0000000000000000000000000000000000000000..129b728be8918e40f11a6916a49407fea4530409 --- /dev/null +++ b/district/static/district/css/district_custom_admin.css @@ -0,0 +1,4 @@ +div:not(:first-child) > .c-sf-add-button[title="Insert a block"][aria-expanded="false"] { + margin-top: 50px!important; + margin-bottom: 50px!important; +} \ No newline at end of file diff --git a/district/wagtail_hooks.py b/district/wagtail_hooks.py index 3f0fe618620acadd6bbcbaa9a367166f2c842a6e..f0ccab362551a16e27f420609d4c09f876928c60 100644 --- a/district/wagtail_hooks.py +++ b/district/wagtail_hooks.py @@ -1,3 +1,5 @@ +from django.templatetags.static import static +from django.utils.html import format_html from wagtail import hooks from district.models import DistrictCenterPage, DistrictHomePage @@ -19,3 +21,11 @@ def handle_copy_calendar(request, origin_page, copied_page): # set new copy of calendar copied_page.calendar_id = calendar.id copied_page.save() + + +@hooks.register("insert_global_admin_css", order=100) +def global_admin_css(): + return format_html( + '<link rel="stylesheet" href="{}">', + static("district/css/district_custom_admin.css") + ) diff --git a/elections/blocks.py b/elections/blocks.py index 4356b829cce697c606bc9f00fc4035800cc84ddc..6c5180459abebfbf626531678147f5757fd22bbb 100644 --- a/elections/blocks.py +++ b/elections/blocks.py @@ -10,9 +10,8 @@ from wagtail.images.blocks import ImageChooserBlock from shared.blocks import CandidateBlock as SharedCandidateBlockMixin from shared.blocks import CandidateListBlock as SharedCandidateListBlockMixin -from shared.blocks import ( - CandidateSecondaryListBlock as SharedCandidateSecondaryListBlockMixin, -) +from shared.blocks import \ + CandidateSecondaryListBlock as SharedCandidateSecondaryListBlockMixin from shared.blocks import SecondaryCandidateBlock as SharedSecondaryCandidateBlockMixin diff --git a/main/blocks.py b/main/blocks.py index 257ba5ba11c46fa859f203c2e4fd6aa06493fc7c..dc9d7f8c8c93a6a20c76205dc170b82e36775cb8 100644 --- a/main/blocks.py +++ b/main/blocks.py @@ -13,9 +13,8 @@ from wagtail.images.blocks import ImageChooserBlock from shared.blocks import CandidateBlock as SharedCandidateBlockMixin from shared.blocks import CandidateListBlock from shared.blocks import CandidateListBlock as SharedCandidateListBlockMixin -from shared.blocks import ( - CandidateSecondaryListBlock as SharedCandidateSecondaryListBlockMixin, -) +from shared.blocks import \ + CandidateSecondaryListBlock as SharedCandidateSecondaryListBlockMixin from shared.blocks import ( CardLinkBlockMixin, CardLinkWithHeadlineBlockMixin, @@ -28,9 +27,8 @@ from shared.blocks import ( ProgramGroupBlockMixin, ) from shared.blocks import ProgramGroupBlockPopout as SharedProgramGroupBlockPopout -from shared.blocks import ( - ProgramGroupWithCandidatesBlock as SharedProgramGroupWithCandidatesBlockMixin, -) +from shared.blocks import \ + ProgramGroupWithCandidatesBlock as SharedProgramGroupWithCandidatesBlockMixin from shared.blocks import SecondaryCandidateBlock as SharedSecondaryCandidateBlockMixin from shared.blocks import StreamBlock, TeamBlockMixin diff --git a/main/models.py b/main/models.py index 08ce117d84c747da5cad30c7ac3973171d95ae39..fd0482ac403a4d23f8ae1bde2cf72f5887f3c841 100644 --- a/main/models.py +++ b/main/models.py @@ -475,7 +475,7 @@ class MainCareersPage( .all() ) - def get_career_pages(self, show_closed: bool = False): + def get_career_pages(self, show_closed: bool = False, category: str|None = None): filter = models.Q() current_date = date.today() @@ -483,6 +483,9 @@ class MainCareersPage( if not show_closed: filter = filter & models.Q(closing_date__gt=current_date) + if category is not None: + filter = filter & models.Q(category=category) + return MainCareerPage.objects.child_of(self).filter(filter).live().all() class Meta: diff --git a/main/templates/main/main_careers_page.html b/main/templates/main/main_careers_page.html index 436ab33c88d1230d22cebe9e70d719a1a66e334e..709030117ef0646b5b48bf034f9c2e3ffa8cb0db 100644 --- a/main/templates/main/main_careers_page.html +++ b/main/templates/main/main_careers_page.html @@ -6,24 +6,27 @@ <div class="__js-root"> <ui-view-provider - :initial="{ {% for category in page.get_career_categories %} '{{ forloop.count0 }}-{{ category }}': {% if forloop.first %}true{% else %}false{% endif %}{% if not forloop.last %},{% endif %}{% endfor %} }" :sync-location="true" + :initial="{ {% for category in page.get_career_categories %} '{{ forloop.counter0 }}-{{ category }}': {% if forloop.first %}true{% else %}false{% endif %}{% if not forloop.last %},{% endif %}{% endfor %} }" :sync-location="true" v-slot="{ isCurrentView, toggleView }" > {% include 'styleguide2/includes/organisms/header/main/careers_header.html' with title=page.title sub_heading=page.subheading description_column_1=page.perex_col_1 description_column_2=page.perex_col_2 %} <main role="main" class="mb-20"> <div class="container--wide"> - {% with page|get_career_pages:show_closed as career_pages %} - {% if career_pages %} - <div class="grid lg:grid-cols-2 grid-cols-1 gap-6 mb-4"> - {% for career in career_pages %} - {% include "styleguide2/includes/molecules/boxes/main/career_box.html" %} - {% endfor %} - </div> - {% else %} - <div class="mb-4 text-grey-250">ŽádnĂ© aktuálnĂ nabĂdky.</div> - {% endif %} - {% endwith %} + {% for category in page.get_career_categories %} + <template v-if="isCurrentView('{{ forloop.counter0 }}-{{ category }}')"> + {% get_career_pages page show_closed category as career_pages %} + {% if career_pages %} + <div class="grid lg:grid-cols-2 grid-cols-1 gap-6 mb-4"> + {% for career in career_pages %} + {% include "styleguide2/includes/molecules/boxes/main/career_box.html" %} + {% endfor %} + </div> + {% else %} + <div class="mb-4 text-grey-250">ŽádnĂ© aktuálnĂ nabĂdky.</div> + {% endif %} + </template> + {% endfor %} {% if not show_closed %} <a class="underline" href="?show_closed=true">Zobrazit uzavĹ™enĂ©</a> diff --git a/main/templatetags/careers.py b/main/templatetags/careers.py index 54ea017d2d2eee5e0a6f087f3a4f532204c7ae6d..403f6bb09da07938450603c690ff79799651f18c 100644 --- a/main/templatetags/careers.py +++ b/main/templatetags/careers.py @@ -3,6 +3,6 @@ from django import template register = template.Library() -@register.filter -def get_career_pages(page, show_closed: bool): - return page.get_career_pages(show_closed) +@register.simple_tag +def get_career_pages(page, show_closed: bool, category: str): + return page.get_career_pages(show_closed, category) diff --git a/shared/people_import.py b/shared/people_import.py index 81877be9ac98666d1cfee2fb43b682bd75cab7ca..e339edb8ba780345f29c65996a4e3720ea1ce824 100644 --- a/shared/people_import.py +++ b/shared/people_import.py @@ -259,7 +259,13 @@ class PeopleGroupImporter(ImporterMixin): self.people_parent_page = self.people_parent_page_model.objects.get( id=self.people_parent_page_id ) - self.collection = Collection.objects.get(id=self.collection_id) + + self.collection = Collection.objects.filter(id=self.collection_id).first() + + if self.collection is None: + # Fallback - Use the first collection in the database, + # we'll have to assume there is one. + self.collection = Collection.objects.first() self.transport = AIOHTTPTransport(url=settings.OCTOPUS_API_URL) self.client = Client( @@ -437,7 +443,12 @@ class PeopleTeamImporter(ImporterMixin): self.people_parent_page = self.people_parent_page_model.objects.get( id=self.people_parent_page_id ) - self.collection = Collection.objects.get(id=self.collection_id) + self.collection = Collection.objects.filter(id=self.collection_id).first() + + if self.collection is None: + # Fallback - Use the first collection in the database, + # we'll have to assume there is one. + self.collection = Collection.objects.first() self.transport = AIOHTTPTransport(url=settings.OCTOPUS_API_URL) self.client = Client( @@ -687,17 +698,24 @@ class PersonImporter(ImporterMixin): self.person_page = self.person_page_model.objects.get( id=self.person_page_id ) - self.collection = Collection.objects.get(id=self.collection_id) + self.collection = Collection.objects.filter(id=self.collection_id).first() + + if self.collection is None: + # Fallback - Use the first collection in the database, + # we'll have to assume there is one. + self.collection = Collection.objects.first() self.transport = AIOHTTPTransport(url=settings.OCTOPUS_API_URL) self.client = Client( transport=self.transport, fetch_schema_from_transport=True ) - except Exception: + except Exception as exception: # No matter what happens, at least remove the lockfile. if os.path.exists(lock_file_name): os.remove(lock_file_name) + logger.error("Person importer crashed on init: %s", str(exception)) + def get_person_id_from_username(self, username): query = gql( f""" diff --git a/shared/templates/styleguide2/includes/organisms/header/main/careers_header.html b/shared/templates/styleguide2/includes/organisms/header/main/careers_header.html index 788906ac1f1ee136629e8beeac03096d4733512b..52454dfae13e2d0f0adad18358e6ad802f341d33 100644 --- a/shared/templates/styleguide2/includes/organisms/header/main/careers_header.html +++ b/shared/templates/styleguide2/includes/organisms/header/main/careers_header.html @@ -22,8 +22,8 @@ {% block switch %} {% for category in page.get_career_categories %} <a - @click="toggleView('{{ forloop.count0 }}-{{ category }}')" class="switch__item" - :class="{'switch__item--active': isCurrentView('{{ category }}')}" + @click="toggleView('{{ forloop.counter0 }}-{{ category }}')" class="switch__item" + :class="{'switch__item--active': isCurrentView('{{ forloop.counter0 }}-{{ category }}')}" >{{ category }}</a> {% endfor %} {% endblock %}