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_email(parliamentarians: list[onegov.pas.models.PASParliamentarian]) dict[str, onegov.pas.models.PASParliamentarian][source]

Pick one parliamentarian per unique email, prioritizing commission presidents.

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

Keep the parliamentarian and its user account in sync.

  • Creates a new user account if an email address is set (if not already existing).

  • Disable user accounts if an email has been deleted.

  • Change usernames if an email has changed.

  • Make sure used user accounts have the right role.

  • Make sure used user accounts are activated.

  • Make sure the password is changed if activated or disabled.

Optional users_cache parameter allows to pre-fetch the users to avoid N+1 queries.

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

Sync user accounts for all parliamentarians.

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

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