-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into postgres-full-text
- Loading branch information
Showing
43 changed files
with
1,261 additions
and
1,002 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
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,67 @@ | ||
from wtforms import SelectField, BooleanField, DateField | ||
|
||
from privatim.forms.constants import cantons_named | ||
from privatim.forms.core import Form | ||
from wtforms.validators import Optional | ||
from privatim.i18n import _ | ||
|
||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from pyramid.interfaces import IRequest | ||
from wtforms import Field | ||
|
||
|
||
def render_filter_field(field: 'Field') -> str: | ||
if isinstance(field, BooleanField): | ||
return field(class_="form-check-input") | ||
else: | ||
return field(class_="form-control") | ||
|
||
|
||
class FilterForm(Form): | ||
def __init__( | ||
self, | ||
request: 'IRequest', | ||
) -> None: | ||
|
||
self._title = _('Filter') | ||
session = request.dbsession | ||
super().__init__(request.POST, meta={'dbsession': session}) | ||
|
||
def get_type_fields(self) -> list[BooleanField]: | ||
return [self.consultation, self.meeting, self.comment] | ||
|
||
def get_date_fields(self) -> list[tuple[str, DateField]]: | ||
return [('datumVon', self.start_date), ('datumBis', self.end_date)] | ||
|
||
canton: SelectField = SelectField( | ||
_('Kanton'), | ||
choices=[('all', _('all'))] + cantons_named, | ||
validators=[Optional()], | ||
render_kw={'class': 'form-select', 'id': 'kanton'}, | ||
) | ||
|
||
consultation: BooleanField = BooleanField( | ||
_('Consultation'), | ||
render_kw={'class': 'form-check-input', 'id': 'vernehmlassung'}, | ||
) | ||
meeting: BooleanField = BooleanField( | ||
_('Meeting'), render_kw={'class': 'form-check-input', 'id': 'sitzung'} | ||
) | ||
comment: BooleanField = BooleanField( | ||
_('Comment'), | ||
render_kw={'class': 'form-check-input', 'id': 'kommentar'}, | ||
) | ||
|
||
start_date: DateField = DateField( | ||
_('Date from'), | ||
validators=[Optional()], | ||
render_kw={'class': 'form-control', 'id': 'datumVon'}, | ||
) | ||
end_date: DateField = DateField( | ||
_('Date to'), | ||
validators=[Optional()], | ||
render_kw={'class': 'form-control', 'id': 'datumBis'}, | ||
) |
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.