Source code for pay.collections.payment_provider

from onegov.core.collection import GenericCollection
from onegov.pay.models import PaymentProvider


from typing import Any, TYPE_CHECKING
if TYPE_CHECKING:
    from onegov.pay.models import Payment


[docs] class PaymentProviderCollection(GenericCollection[PaymentProvider['Payment']]): """ Manages the payment providers. """ @property
[docs] def model_class(self) -> type[PaymentProvider['Payment']]: return PaymentProvider
[docs] def as_default(self, provider: PaymentProvider[Any]) -> None: for other in self.query(): other.default = False self.session.flush() provider.default = True
[docs] def sync(self) -> None: """ Syncs all payments with the related payment providers. """ for provider in self.query(): provider.sync()