pas.collections.parliamentarian

Attributes

log

Classes

PASParliamentarianCollection

Module Contents

pas.collections.parliamentarian.log[source]
class pas.collections.parliamentarian.PASParliamentarianCollection(app: onegov.core.Framework, **kwargs: Any)[source]

Bases: onegov.parliament.collections.ParliamentarianCollection[onegov.pas.models.PASParliamentarian]

app[source]
for_filter(active: bool | None = None, party: str | None = None) Self[source]
property model_class: type[onegov.pas.models.PASParliamentarian][source]
add(**kwargs: Any) onegov.pas.models.PASParliamentarian[source]
delete(item: onegov.pas.models.PASParliamentarian) None[source]
_is_current_commission_president(item: onegov.pas.models.PASParliamentarian) bool[source]

Check if the parliamentarian is currently a president of any commission.

_representatives_by_zg_username(parliamentarians: list[onegov.pas.models.PASParliamentarian]) dict[str, onegov.pas.models.PASParliamentarian][source]

Pick one parliamentarian per unique zg_username, prioritizing commission presidents.

update_user(item: onegov.pas.models.PASParliamentarian, new_username: str | None, users_cache: dict[str, Any] | None = None) None[source]

Keep the parliamentarian and its user account in sync.

Uses zg_username as the User.username identifier.

  • Creates a new user if zg_username is set.

  • Disables user if zg_username has been removed.

  • Changes usernames if zg_username changed.

  • Ensures correct role and active state.

Optional users_cache pre-fetches users to avoid N+1 queries.

sync_user_accounts() dict[str, Any][source]

Sync user accounts for all parliamentarians.

Groups by zg_username, picks one representative per username to avoid role conflicts. Prioritizes commission presidents.

Returns dict with ‘synced’, ‘skipped’, and ‘created’ (list of new usernames).