Skip to content

Commit b84abca

Browse files
authored
Event: Now exports fields highlight and syndicate
Event exports (excel, csv, json, xml) now contain the fields `highlight` and `syndicate` TYPE: Feature LINK: ogc-3238
1 parent 04fe0d1 commit b84abca

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/onegov/org/forms/event.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ def headers(self) -> dict[str, str]:
568568
'event_registration_url': self.request.translate(
569569
_('Event Registration URL')),
570570
'tags': self.request.translate(_('Tags')),
571+
'syndicate': self.request.translate(_('Syndicate')),
572+
'highlight': self.request.translate(_('Highlight')),
571573
'start': self.request.translate(_('From')),
572574
'end': self.request.translate(_('To')),
573575
'created': self.request.translate(_('Created')),
@@ -576,11 +578,11 @@ def headers(self) -> dict[str, str]:
576578
def custom_tags(self) -> list[str] | None:
577579
return self.request.app.custom_event_tags
578580

579-
def run_export(self) -> list[dict[str, str]]:
581+
def run_export(self) -> list[dict[str, str | bool]]:
580582
occurrences = OccurrenceCollection(self.request.session)
581583
headers = self.headers
582584

583-
def get(occurrence: Occurrence, attribute: str) -> str:
585+
def get(occurrence: Occurrence, attribute: str) -> str | bool:
584586
if attribute in ('start', 'end'):
585587
attribute = f'localized_{attribute}'
586588
result = (
@@ -592,6 +594,8 @@ def get(occurrence: Occurrence, attribute: str) -> str:
592594
result, occurrence.timezone or 'Europe/Zurich')
593595
if isinstance(result, datetime):
594596
result = result.strftime('%d.%m.%Y %H:%M')
597+
if isinstance(result, bool):
598+
return result
595599
if attribute == 'tags':
596600
result = ', '.join(
597601
self.request.translate(_(tag))

tests/onegov/org/test_views_event.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ def clear_submit_accept_single_event(
733733
transaction.commit()
734734

735735
# Submit and publish an event
736+
client.login_admin()
736737
page = client.get('/events').click('Veranstaltung erfassen')
737738
event_date = date.today() + timedelta(days=1)
738739
page.form['email'] = 'sinfonieorchester@govikon.org'
@@ -744,11 +745,14 @@ def clear_submit_accept_single_event(
744745
page.form['organizer_email'] = 'sinfonieorchester@govikon.org'
745746
page.form['organizer_phone'] = '+41 41 123 45 67'
746747
page.form['tags'] = custom_tags if custom_tags else ['Music', 'Tradition']
748+
page.form['syndicate'] = False # requires admin
749+
page.form['highlight'] = True # requires admin
747750
page.form['start_date'] = event_date.isoformat()
748751
page.form['start_time'] = '18:00'
749752
page.form['end_time'] = '22:00'
750753
page.form['repeat'] = 'without'
751754
page.form.submit().follow().form.submit().follow()
755+
client.logout()
752756

753757
client.login_editor()
754758

@@ -913,6 +917,21 @@ def verify_event_fields(event_fields: dict[str, str | None]) -> None:
913917
'+41 41 123 45 67')
914918

915919
assert event_fields['Schlagworte'] == 'Musik, Brauchtum'
920+
921+
if 'Extern_publizieren' in event_fields:
922+
assert event_fields['Extern_publizieren'] in (
923+
False,
924+
'False',
925+
'false',
926+
)
927+
else:
928+
assert event_fields['Extern publizieren'] in (
929+
False,
930+
'False',
931+
'false',
932+
)
933+
934+
assert event_fields['Highlight'] in (True, 'True', 'true')
916935
assert event_fields['Erstellt'] == '23.03.2026 09:00'
917936
assert event_fields['Von'] == '24.03.2026 18:00'
918937
assert event_fields['Bis'] == '24.03.2026 22:00'

0 commit comments

Comments
 (0)