pas.utils ========= .. py:module:: pas.utils Attributes ---------- .. autoapisummary:: pas.utils.CLEX_URL Functions --------- .. autoapisummary:: pas.utils._is_kantonsrat_role pas.utils.is_active_kantonsrat_member pas.utils.get_active_kantonsrat_parliamentarians pas.utils.fetch_clex_kantonsrat_members pas.utils.format_swiss_number pas.utils.is_kantonsrat_president pas.utils.is_president_for_attendance pas.utils.get_parliamentarians_with_settlements pas.utils.get_parties_with_settlements pas.utils.is_parliamentarian pas.utils.is_parliamentarian_role pas.utils.get_commissions_with_memberships Module Contents --------------- .. py:function:: _is_kantonsrat_role(role: onegov.pas.models.parliamentarian_role.PASParliamentarianRole | onegov.parliament.models.parliamentarian_role.ParliamentarianRole) -> bool A Kantonsrat role has meta.org_type == 'Kantonsrat' (set by the KUB importer). .. py:function:: is_active_kantonsrat_member(parliamentarian: onegov.pas.models.parliamentarian.PASParliamentarian | onegov.parliament.models.parliamentarian.Parliamentarian, reference_date: datetime.date | None = None) -> bool .. py:function:: get_active_kantonsrat_parliamentarians(app: onegov.core.Framework, reference_date: datetime.date | None = None) -> list[onegov.pas.models.parliamentarian.PASParliamentarian] .. py:data:: CLEX_URL :value: 'https://zg-compwork.clex.ch/frontend/people' .. py:function:: fetch_clex_kantonsrat_members(reference_date: datetime.date | None = None) -> set[tuple[str, str]] Fetch active Kantonsrat members from the CLEX frontend. Returns set of (last_name, first_name) tuples for members without an exit date or with an exit date >= reference_date. .. py:function:: format_swiss_number(value: decimal.Decimal | int) -> str .. py:function:: is_kantonsrat_president(parliamentarian: onegov.pas.models.parliamentarian.PASParliamentarian, on_date: datetime.date) -> bool The Kantonsratspräsidium is a role on the parliamentarian and not a commission membership. .. py:function:: is_president_for_attendance(parliamentarian: onegov.pas.models.parliamentarian.PASParliamentarian, attendance: onegov.pas.models.attendence.Attendence) -> bool Whether the president rate applies. A plenary session has no commission, there the Kantonsratspräsidium decides. .. py:function:: get_parliamentarians_with_settlements(session: sqlalchemy.orm.Session, start_date: datetime.date, end_date: datetime.date, settlement_run_id: uuid.UUID | None = None) -> list[onegov.pas.models.parliamentarian.PASParliamentarian] Get all parliamentarians who were active and had settlements (attendances or presidential allowances) during the specified period. .. py:function:: get_parties_with_settlements(session: sqlalchemy.orm.Session, start_date: datetime.date, end_date: datetime.date) -> list[onegov.pas.models.party.Party] Get all parties that had active members with attendances during the specified period. This function ensures accurate party filtering by checking that parliamentarians were active members of their party at the time of each attendance, properly handling cases where parliamentarians switch parties or have changing membership dates. .. py:function:: is_parliamentarian(user: onegov.user.User | None) -> bool Check if a user has parliamentarian role. .. py:function:: is_parliamentarian_role(role: str | None) -> bool Check if a role is a parliamentarian role. .. py:function:: get_commissions_with_memberships(session: sqlalchemy.orm.Session, start_date: datetime.date, end_date: datetime.date) -> list[onegov.pas.models.commission.PASCommission] Get all commissions that had active memberships during the specified period. This function ensures accurate commission filtering by checking that commissions had active members during the period, properly handling cases where memberships have changing dates.