Skip to content
Snippets Groups Projects
Commit d1cce6c2 authored by Alexa Valentová's avatar Alexa Valentová
Browse files

fix career pages, handle errors

parent 702ba51e
No related branches found
No related tags found
2 merge requests!1223Release,!1222fix career pages, handle errors
Pipeline #20635 passed
......@@ -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
)
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
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")
)
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -6,14 +6,16 @@
<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 %}
{% 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 %}
......@@ -23,7 +25,8 @@
{% else %}
<div class="mb-4 text-grey-250">Žádné aktuální nabídky.</div>
{% endif %}
{% endwith %}
</template>
{% endfor %}
{% if not show_closed %}
<a class="underline" href="?show_closed=true">Zobrazit uzavřené</a>
......
......@@ -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)
......@@ -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"""
......
......@@ -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 %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment