Skip to content

Commit

Permalink
FSI: UI Update to Foundation 6
Browse files Browse the repository at this point in the history
TYPE: Feature
LINK: OGC-1748
  • Loading branch information
BreathingFlesh authored Aug 19, 2024
1 parent e5c3c3f commit 245af37
Show file tree
Hide file tree
Showing 36 changed files with 365 additions and 436 deletions.
12 changes: 6 additions & 6 deletions src/onegov/fsi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from onegov.fsi.models.course_attendee import CourseAttendee
from onegov.fsi.request import FsiRequest
from onegov.fsi.theme import FsiTheme
from onegov.org import OrgApp
from onegov.org.app import get_common_asset as default_common_asset
from onegov.org.app import get_i18n_localedirs as get_org_i18n_localedirs
from onegov.town6 import TownApp
from onegov.town6.app import get_common_asset as default_common_asset
from onegov.town6.app import get_i18n_localedirs as get_town6_i18n_localedirs


from typing import Any, TYPE_CHECKING
Expand All @@ -16,7 +16,7 @@
from onegov.user import User


class FsiApp(OrgApp):
class FsiApp(TownApp):

request_class = FsiRequest

Expand Down Expand Up @@ -56,7 +56,7 @@ def get_template_directory() -> str:
return 'templates'


@OrgApp.static_directory()
@TownApp.static_directory()
def get_static_directory() -> str:
return 'static'

Expand All @@ -75,7 +75,7 @@ def get_create_new_organisation_factory(
@FsiApp.setting(section='i18n', name='localedirs')
def get_i18n_localedirs() -> list[str]:
mine = utils.module_path('onegov.fsi', 'locale')
return [mine] + get_org_i18n_localedirs()
return [mine] + get_town6_i18n_localedirs()


@FsiApp.webasset_path()
Expand Down
35 changes: 24 additions & 11 deletions src/onegov/fsi/custom.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from onegov.core.elements import Link
from onegov.core.utils import Bunch
from onegov.form.collection import SurveyCollection
from onegov.fsi import FsiApp
from onegov.fsi.collections.attendee import CourseAttendeeCollection
Expand All @@ -18,6 +19,7 @@
if TYPE_CHECKING:
from collections.abc import Iterator
from onegov.fsi.request import FsiRequest
from onegov.town6.layout import NavigationEntry


def get_base_tools(request: 'FsiRequest') -> 'Iterator[Link | LinkGroup]':
Expand Down Expand Up @@ -165,21 +167,32 @@ def get_template_variables(request: 'FsiRequest') -> dict[str, Any]:
}


def get_top_navigation(request: 'FsiRequest') -> 'Iterator[Link]':
def get_top_navigation(request: 'FsiRequest') -> 'Iterator[NavigationEntry]':

# inject an activites link in front of all top navigation links
yield Link(
text=_("Courses"),
url=request.class_link(CourseCollection)
yield ( # type:ignore[misc]
Bunch(id=-3, access='public', published=True),
Link(
text=_("Courses"),
url=request.class_link(CourseCollection)
),
()
)
if request.is_manager:
yield Link(
text=_("Audit"),
url=request.class_link(AuditCollection)
yield ( # type:ignore[misc]
Bunch(id=-2, access='public', published=True),
Link(
text=_("Audit"),
url=request.class_link(AuditCollection)
),
()
)
yield Link(
text=_("Attendee Check"),
url=request.class_link(PastCourseEventCollection)
yield ( # type:ignore[misc]
Bunch(id=-1, access='public', published=True),
Link(
text=_("Attendee Check"),
url=request.class_link(PastCourseEventCollection)
),
()
)

layout = DefaultLayout(request.app.org, request)
Expand Down
9 changes: 4 additions & 5 deletions src/onegov/fsi/forms/course_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ class CourseEventForm(Form):
)

def ensure_start_before_end(self) -> bool:
assert self.start.data is not None
assert self.end.data is not None
if self.start.data >= self.end.data:
self.start.errors = [_("Please use a start prior to the end")]
return False
if (self.start.data is not None and self.end.data is not None):
if self.start.data >= self.end.data:
self.start.errors = [_("Please use a start prior to the end")]
return False
return True

def ensure_no_duplicates(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/onegov/fsi/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
)
from onegov.fsi.models.course_notification_template import (
NOTIFICATION_TYPE_TRANSLATIONS, NOTIFICATION_TYPES)
from onegov.org.layout import DefaultLayout as BaseLayout
from onegov.town6.layout import DefaultLayout as BaseLayout
from onegov.fsi import _


Expand Down
2 changes: 1 addition & 1 deletion src/onegov/fsi/layouts/course_attendee.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def editbar_links(self) -> list[Link | LinkGroup]:
_('Add External Attendee'),
url=self.request.class_link(
CourseAttendeeCollection, name='add-external'),
attrs={'class': 'users'}
attrs={'class': 'add-external'}
),
]

Expand Down
2 changes: 1 addition & 1 deletion src/onegov/fsi/layouts/course_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def editbar_links(self) -> list[Link | LinkGroup]:
_("Placeholder"),
self.request.link(
self.reservation_collection,
name='add-placeholder'
name='add-icon'
),
attrs={'class': 'add-placeholder'}
)
Expand Down
20 changes: 18 additions & 2 deletions src/onegov/fsi/locale/de_CH/LC_MESSAGES/onegov.fsi.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE 1.0\n"
"POT-Creation-Date: 2024-05-23 09:47+0200\n"
"POT-Creation-Date: 2024-08-13 09:41+0200\n"
"PO-Revision-Date: 2020-03-05 14:36+0100\n"
"Last-Translator: Denis Krienbühl <[email protected]>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -32,6 +32,9 @@ msgstr "Teilnehmer"
msgid "Event Subscriptions"
msgstr "Kursanmeldungen"

msgid "Surveys"
msgstr "Umfragen"

msgid "Files"
msgstr "Dateien"

Expand Down Expand Up @@ -97,6 +100,12 @@ msgstr "Anzahl Jahre"
msgid "Hidden"
msgstr "Versteckt"

msgid "Evaluation URL"
msgstr "Link zur Umfrage"

msgid "URL to the evaluation form"
msgstr "URL zur Kursumfrage"

msgid "Not a valid integer value"
msgstr "Keine gültige Ganzzahl"

Expand Down Expand Up @@ -158,7 +167,7 @@ msgid "Status"
msgstr "Status"

msgid "Please use a start prior to the end"
msgstr "Bitte benutzen Sie eine Anfangszeit vor der Startzeit"
msgstr "Bitte setzen Sie eine Startzeit vor der Endzeit"

msgid "A duplicate event already exists"
msgstr "Ein Duplikat dieser Durchführung existiert bereits"
Expand Down Expand Up @@ -558,6 +567,9 @@ msgstr "Datum"
msgid "Remaining seats"
msgstr "Verbleibende Plätze"

msgid "Course Evaluation"
msgstr "Kursevaluation"

msgid "Description:"
msgstr "Beschreibung:"

Expand Down Expand Up @@ -811,3 +823,7 @@ msgstr "Anmeldung erfolgreich gelöscht"

msgid "Placeholder successfully deleted"
msgstr "Platzhalter erfolgreich gelöscht"

#~ msgid "The form contains errors. Please check the fields marked in red."
#~ msgstr ""
#~ "Das Formular enthält Fehler. Bitte die rot markierten Felder überprüfen."
4 changes: 2 additions & 2 deletions src/onegov/fsi/request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import cached_property
from onegov.org.request import OrgRequest
from onegov.town6.request import TownRequest


from typing import TYPE_CHECKING
Expand All @@ -8,7 +8,7 @@
from uuid import UUID


class FsiRequest(OrgRequest):
class FsiRequest(TownRequest):

@cached_property
def attendee(self) -> 'CourseAttendee | None':
Expand Down
125 changes: 60 additions & 65 deletions src/onegov/fsi/templates/audits.pt
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,76 @@
${layout.title}
</tal:b>
<tal:b metal:fill-slot="content">
<div class="row">
<div class="columns small-12">
<div class="row">
<div tal:condition="show_form|True" class="columns small-12 medium-8">
<div class="filter-panel">
<div metal:use-macro="layout.macros['form']" />
</div>
<div class="filter-panel">
<p class="label-text" i18n:translate>By last name</p>
<div metal:use-macro="layout.macros['tags']" tal:define="tags letters" />
</div>
<div class="grid-x grid-padding-x wrapper">
<div tal:condition="show_form|True" class="cell small-12 medium-7 cell">
<div class="filter-panel" tal:define="hide_cancel True">
<div metal:use-macro="layout.macros['form']" />
</div>
<div class="filter-panel">
<span class="label-text" i18n:translate>By last name</span>
<div metal:use-macro="layout.macros['tags']" tal:define="tags letters" />
</div>
<div class="columns small-12 medium-4">
</div>
<div class="large-4 medium-4 cell medium-offset-1">
<div class="sidebar-wrapper">
<div class="info-panel hide-for-print">
<tal:b metal:use-macro="layout.macros['color_code_snippet']" />
</div>
</div>
</div>
<div class="row hide-for-print">
<div class="columns small-12 medium-8">
<a class="button ${'' if email_recipients else 'disabled'}" tal:attributes="href python: f'mailto:{email_recipients}?subject={subject}' if email_recipients else ''" ><i class="fa fa-envelope"></i> <tal:b i18n:translate>Reminder mails</tal:b></a>
<p tal:condition="email_recipients" i18n:translate>Opens an empty message in your mail program with the course participants filtered visibly here, who have neither attended the course due nor are registered (next attendance).</p>
<p tal:condition="not email_recipients" i18n:translate>Select one or more organizations. If people in the filtered view have neither attended the due course nor are registered (next attendance), the button can be used to send a reminder email to them.</p>
</div>
</div>
</div>
<div class="grid-x grid-padding-x wrapper hide-for-print">
<div class="small-12 medium-8 cell">
<a class="button ${'' if email_recipients else 'disabled'}" tal:attributes="href python: f'mailto:{email_recipients}?subject={subject}' if email_recipients else ''" ><i class="fa fa-envelope"></i> <tal:b i18n:translate>Reminder mails</tal:b></a>
<p tal:condition="email_recipients" i18n:translate>Opens an empty message in your mail program with the course participants filtered visibly here, who have neither attended the course due nor are registered (next attendance).</p>
<p tal:condition="not email_recipients" i18n:translate>Select one or more organizations. If people in the filtered view have neither attended the due course nor are registered (next attendance), the button can be used to send a reminder email to them.</p>
</div>

</div>
<br>
<div class="row">
<div class="columns small-12 end">
<div class="row">
<div class="columns small-12">
<tal:b condition="results">
<table class="hover fullwidth">
<thead>
<th class="text-left" i18n:translate="">Name</th>
<th class="text-left" i18n:translate="">Shortcode</th>
<th class="text-left" i18n:translate="">Last Event</th>
<th class="text-center" i18n:translate="">Attended</th>
<th class="text-left" i18n:translate="">Due by (every <span i18n:name="refresh_interval">${layout.format_refresh_interval(model.course.refresh_interval)}</span>)</th>
<th class="text-left" i18n:translate="">Next Subscription</th>
</thead>
<tbody>
<tal:b tal:repeat="result results">
<tr tal:define="date layout.next_event_date(result.start, result.refresh_interval)">
<td>${result.last_name}, ${result.first_name}</td>
<td>${result.source_id}</td>
<td>${layout.format_date(result.start, 'datetime')} <span i18n:translate="" tal:condition="result.start">h</span></td>
<td class="text-center">
<span tal:condition="result.event_completed" class="check-icon"></span>
<span tal:condition="not result.event_completed">-</span>
</td>
<td>
<tal:b tal:condition="date">
<span class="text-red" tal:condition="now > date">${date.year}</span>
<span class="${'text-orange' if date.year == now.year and result.event_completed else 'text-green'}" tal:condition="now < date">${date.year}</span>
</tal:b>
<span class="text-red" tal:condition="not: date">${now.year}</span>
</td>
<td tal:define="next_subscription next_subscriptions.get(result.id, None)">
<tal:b tal:condition="next_subscription">
<a href="${next_subscription[0]}" class="next-subscription">${layout.format_date(next_subscription[1], 'date')}</a>
</tal:b>
</td>
</tr>
</tal:b>
</tbody>
</table>
<div class="pagination-centered">
<div metal:use-macro="layout.macros['pagination']" tal:define="collection model; current_page model;" />
</div>
</tal:b>
</div>
</div>

<div class="grid-x grid-padding-x wrapper">
<div class="small-12 cell">
<tal:b condition="results">
<table class="hover fullwidth">
<thead>
<th class="text-left" i18n:translate="">Name</th>
<th class="text-left" i18n:translate="">Shortcode</th>
<th class="text-left" i18n:translate="">Last Event</th>
<th class="text-center" i18n:translate="">Attended</th>
<th class="text-left" i18n:translate="">Due by (every <span i18n:name="refresh_interval">${layout.format_refresh_interval(model.course.refresh_interval)}</span>)</th>
<th class="text-left" i18n:translate="">Next Subscription</th>
</thead>
<tbody>
<tal:b tal:repeat="result results">
<tr tal:define="date layout.next_event_date(result.start, result.refresh_interval)">
<td>${result.last_name}, ${result.first_name}</td>
<td>${result.source_id}</td>
<td>${layout.format_date(result.start, 'datetime')} <span i18n:translate="" tal:condition="result.start">h</span></td>
<td class="text-center">
<span tal:condition="result.event_completed" class="check-icon"></span>
<span tal:condition="not result.event_completed">-</span>
</td>
<td>
<tal:b tal:condition="date">
<span class="text-red" tal:condition="now > date">${date.year}</span>
<span class="${'text-orange' if date.year == now.year and result.event_completed else 'text-green'}" tal:condition="now < date">${date.year}</span>
</tal:b>
<span class="text-red" tal:condition="not: date">${now.year}</span>
</td>
<td tal:define="next_subscription next_subscriptions.get(result.id, None)">
<tal:b tal:condition="next_subscription">
<a href="${next_subscription[0]}" class="next-subscription">${layout.format_date(next_subscription[1], 'date')}</a>
</tal:b>
</td>
</tr>
</tal:b>
</tbody>
</table>
<div metal:use-macro="layout.macros['pagination']" tal:define="collection model; current_page model; pagination_centered True" />
</tal:b>
</div>
</div>

</tal:b>
</div>
14 changes: 3 additions & 11 deletions src/onegov/fsi/templates/course.pt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@
${model.name}
</tal:b>
<tal:b metal:fill-slot="content">
<div class="row">
<div class="columns small-12">
<div class="row">
<div class="columns small-12">
<tal:b tal:condition="model|nothing">
<metal:b use-macro="layout.macros['course_details']" />
</tal:b>
</div>
</div>
</div>
</div>
<tal:b tal:condition="model|nothing">
<metal:b use-macro="layout.macros['course_details']" />
</tal:b>
</tal:b>
</div>
Loading

0 comments on commit 245af37

Please sign in to comment.