Source code for fsi.layouts.course_attendee

from functools import cached_property

from onegov.core.elements import Link, LinkGroup, Confirm, Intercooler
from onegov.fsi.collections.attendee import CourseAttendeeCollection
from onegov.fsi.collections.subscription import SubscriptionsCollection
from onegov.fsi.layout import DefaultLayout
from onegov.fsi import _


from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from onegov.fsi.models import CourseAttendee


[docs] class CourseAttendeeCollectionLayout(DefaultLayout): @cached_property
[docs] def title(self) -> str: if self.request.view_name == 'add-external': return _('Add External Attendee') return _('Manage Course Attendees')
@cached_property @cached_property
[docs] def breadcrumbs(self) -> list[Link]: links = super().breadcrumbs assert isinstance(links, list) links.append( Link(_('Manage Course Attendees'), self.request.link(self.model)) ) if self.request.view_name == 'add-external': links.append(Link(_('Add External Attendee'))) return links
@cached_property
[docs] def collection(self) -> CourseAttendeeCollection: return CourseAttendeeCollection( self.request.session, auth_attendee=self.request.attendee )
@cached_property
[docs] def collection_externals(self) -> CourseAttendeeCollection: return CourseAttendeeCollection( self.request.session, auth_attendee=self.request.attendee, external_only=True )
@cached_property
[docs] def collection_editors(self) -> CourseAttendeeCollection: return CourseAttendeeCollection( self.request.session, auth_attendee=self.request.attendee, editors_only=True )
@cached_property
[docs] def collection_admins(self) -> CourseAttendeeCollection: return CourseAttendeeCollection( self.request.session, auth_attendee=self.request.attendee, admins_only=True )
@cached_property
[docs] def menu(self) -> list[tuple[str, str, bool]]: if not self.request.is_admin: # Hide menu for editor since filtered by permissions return [] return [ (_('All'), self.request.link(self.collection), self.model.unfiltered), (_('Editors'), self.request.link(self.collection_editors), self.model.editors_only), (_('Admins'), self.request.link(self.collection_admins), self.model.admins_only), (_('External'), self.request.link(self.collection_externals), self.model.external_only), ]
[docs] class CourseAttendeeLayout(DefaultLayout):
[docs] model: 'CourseAttendee'
@cached_property
[docs] def title(self) -> str: if self.request.view_name == 'edit': return _('Edit Profile') return _('Profile Details')
@cached_property
[docs] def collection(self) -> CourseAttendeeCollection: return CourseAttendeeCollection( self.request.session, auth_attendee=self.request.attendee)
@cached_property
[docs] def breadcrumbs(self) -> list[Link]: links = super().breadcrumbs assert isinstance(links, list) if self.request.is_manager: links.append( Link( _('Manage Course Attendees'), self.request.link(self.collection) ) ) links.append( Link(_('Personal Profile'), self.request.link(self.model))) if self.request.view_name == 'edit': links.append( Link(_('Edit'), self.request.link(self.model, name='edit')) ) return links
@cached_property @property
[docs] def for_himself(self) -> bool: if self.request.attendee is None: return False return self.model.id == self.request.attendee.id