-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PAS: Add rate sets, settlement runs and changes.
TYPE: Feature LINK: OGC-1503
- Loading branch information
Showing
65 changed files
with
3,191 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from onegov.core.collection import GenericCollection | ||
from onegov.pas.models import Change | ||
from sqlalchemy import desc | ||
|
||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from sqlalchemy.orm import Query | ||
|
||
|
||
class ChangeCollection(GenericCollection[Change]): | ||
|
||
@property | ||
def model_class(self) -> type[Change]: | ||
return Change | ||
|
||
def query(self) -> 'Query[Change]': | ||
return super().query().order_by(desc(Change.last_change)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
from onegov.core.collection import GenericCollection | ||
from onegov.pas.models import CommissionMembership | ||
|
||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from sqlalchemy.orm import Query | ||
|
||
|
||
class CommissionMembershipCollection(GenericCollection[CommissionMembership]): | ||
|
||
@property | ||
def model_class(self) -> type[CommissionMembership]: | ||
return CommissionMembership | ||
|
||
def query(self) -> 'Query[CommissionMembership]': | ||
return super().query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
from onegov.core.collection import GenericCollection | ||
from onegov.pas.models import ParliamentarianRole | ||
|
||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from sqlalchemy.orm import Query | ||
|
||
|
||
class ParliamentarianRoleCollection(GenericCollection[ParliamentarianRole]): | ||
|
||
@property | ||
def model_class(self) -> type[ParliamentarianRole]: | ||
return ParliamentarianRole | ||
|
||
def query(self) -> 'Query[ParliamentarianRole]': | ||
return super().query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from datetime import date | ||
from onegov.core.collection import GenericCollection | ||
from onegov.pas.models import RateSet | ||
|
||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from sqlalchemy.orm import Query | ||
from sqlalchemy.orm import Session | ||
from typing_extensions import Self | ||
|
||
|
||
class RateSetCollection(GenericCollection[RateSet]): | ||
|
||
def __init__( | ||
self, | ||
session: 'Session', | ||
active: bool | None = None | ||
): | ||
super().__init__(session) | ||
self.active = active | ||
|
||
@property | ||
def model_class(self) -> type[RateSet]: | ||
return RateSet | ||
|
||
def query(self) -> 'Query[RateSet]': | ||
query = super().query() | ||
|
||
if self.active is not None: | ||
year = date.today().year | ||
if self.active: | ||
query = query.filter(RateSet.year == year) | ||
else: | ||
query = query.filter(RateSet.year != year) | ||
|
||
return query.order_by(RateSet.year.desc()) | ||
|
||
def for_filter( | ||
self, | ||
active: bool | None = None | ||
) -> 'Self': | ||
return self.__class__(self.session, active) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from onegov.core.collection import GenericCollection | ||
from onegov.pas.models import SettlementRun | ||
|
||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from sqlalchemy.orm import Query | ||
from sqlalchemy.orm import Session | ||
from typing_extensions import Self | ||
|
||
|
||
class SettlementRunCollection(GenericCollection[SettlementRun]): | ||
|
||
def __init__( | ||
self, | ||
session: 'Session', | ||
active: bool | None = None | ||
): | ||
super().__init__(session) | ||
self.active = active | ||
|
||
@property | ||
def model_class(self) -> type[SettlementRun]: | ||
return SettlementRun | ||
|
||
def query(self) -> 'Query[SettlementRun]': | ||
query = super().query() | ||
|
||
if self.active is not None: | ||
query = query.filter(SettlementRun.active.is_(self.active)) | ||
|
||
return query.order_by(SettlementRun.start.desc()) | ||
|
||
def for_filter( | ||
self, | ||
active: bool | None = None | ||
) -> 'Self': | ||
return self.__class__(self.session, active) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.