Skip to content
1 change: 1 addition & 0 deletions maintenance-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ schedule:
- caicias
- caicinus
- caicus
- caerus
- carcinus
- date: Monday +7 days at 7:00
nodes:
Expand Down
12 changes: 6 additions & 6 deletions src/onegov/form/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,13 +552,13 @@ def __call__(self, form: Form, field: Field) -> Form | None:
# limit the definition to MultiCheckboxField, RadioField which can
# be used for filter definition
errors = None
for field in parsed_form._fields.values():
if not isinstance(field, (MultiCheckboxField, RadioField)):
error = field.gettext(self.invalid_field_type.format(
label=field.label.text))
errors = form['definition'].errors
for parsed_field in parsed_form._fields.values():
if not isinstance(parsed_field, (MultiCheckboxField, RadioField)):
error = parsed_field.gettext(self.invalid_field_type.format(
label=parsed_field.label.text))
errors = field.errors
if not isinstance(errors, list):
errors = form['definition'].process_errors
errors = field.process_errors
assert isinstance(errors, list)
errors.append(error)

Expand Down
4 changes: 4 additions & 0 deletions src/onegov/org/assets/js/code_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ $(function() {
var readonly = textarea.is('[readonly]');
textarea.css('display', 'none');

// the editor replaces the textarea with its own widget, so make sure
// the field-dependency handling never re-shows the raw textarea
textarea.attr('data-always-hidden', '');

var outside = $('<div class="code-editor-wrapper">');
var inside = $('<div class="code-editor">');
inside.position('absolute');
Expand Down
34 changes: 0 additions & 34 deletions src/onegov/org/forms/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
from onegov.form.fields import TimeField
from onegov.form.fields import UploadField
from onegov.form.fields import UploadFileWithORMSupport
from onegov.form.utils import get_fields_from_class
from onegov.file.attachments import IMAGE_MAX_SIZE
from onegov.form.validators import (
FileSizeLimit,
ImageSizeLimit,
ValidPhoneNumber,
ValidFilterFormDefinition,
MIME_TYPES_EXCEL,
MIME_TYPES_PDF,
)
Expand Down Expand Up @@ -684,35 +682,3 @@ def get(line: DefaultRow, column: str, attribute: str) -> Any:
transaction.abort()

return count, errors


class EventConfigurationForm(Form):
""" Form to configure filters for events view. """

definition = TextAreaField(
label=_('Definition'),
fieldset=_('General'),
validators=[
InputRequired(),
ValidFilterFormDefinition(
require_email_field=False,
require_title_fields=False,
reserved_fields={name for name, _ in
get_fields_from_class(EventForm)}
| {'syndicate', 'highlight'}
)
],
render_kw={'rows': 32, 'data-editor': 'form'})

keyword_fields = TextAreaField(
label=_('Filters'),
fieldset=_('Display'),
render_kw={
'class_': 'formcode-select',
'data-fields-include': 'radio,checkbox'
})

force_remove = BooleanField(
label=_('Remove these filters from all affected events'),
fieldset=_('Confirmation'),
)
68 changes: 53 additions & 15 deletions src/onegov/org/forms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
from onegov.form.fields import TagsField
from onegov.form.fields import TranslatedSelectField
from onegov.form.fields import URLField
from onegov.form.utils import get_fields_from_class
from onegov.form.validators import If
from onegov.form.validators import StrictOptional
from onegov.form.validators import ValidFilterFormDefinition
from onegov.form.validators import ValidHostname
from onegov.gis import CoordinatesField
from onegov.org import _, log
from onegov.org.forms.event import EventForm
from onegov.org.forms.fields import (
HtmlField,
UploadOrSelectExistingMultipleFilesField,
Expand Down Expand Up @@ -2067,21 +2070,6 @@ class EventSettingsForm(Form):
default=False
)

event_locations = TagsField(
label=_('Values of the location filter'),
)

event_filter_type = RadioField(
label=_("Choose the filter type for events (default is 'Tags')"),
choices=(
('tags', _('A predefined set of tags')),
('filters', _('Manually configurable filters')),
('tags_and_filters', _('Both, predefined tags as well as '
'configurable filters')),
),
default='tags'
)

event_header_title = StringField(
label=_('Title of text above event list'),
description=_('General information about the event calendar'),
Expand All @@ -2104,6 +2092,56 @@ class EventSettingsForm(Form):
fieldset=_('Information below the event list')
)

event_locations = TagsField(
label=_('Values of the location filter'),
fieldset=_('Filters'),
)

event_filter_type = RadioField(
label=_("Choose the filter type for events (default is 'Tags')"),
fieldset=_('Filters'),
choices=(
('tags', _('A predefined set of tags')),
('filters', _('Manually configurable filters')),
('tags_and_filters', _('Both, predefined tags as well as '
'configurable filters')),
),
default='tags'
)

event_filter_definition = TextAreaField(
label=_('Definition'),
fieldset=_('Filters'),
depends_on=('event_filter_type', '!tags'),
validators=[
ValidFilterFormDefinition(
require_email_field=False,
require_title_fields=False,
reserved_fields={name for name, _ in
get_fields_from_class(EventForm)}
| {'syndicate', 'highlight'}
)
],
render_kw={'rows': 16, 'data-editor': 'form'}
)

keyword_fields = TextAreaField(
label=_('Filters'),
fieldset=_('Filters'),
depends_on=('event_filter_type', '!tags'),
render_kw={
'class_': 'formcode-select',
'data-fields-include': 'radio,checkbox'
}
)

force_remove = BooleanField(
label=_('Remove these filters from all affected events'),
fieldset=_('Filters'),
)

# FIXME: keep this last; its upload widget emits a split <label> that
# confuses webtest's form parser for any field rendered after it
event_files = UploadOrSelectExistingMultipleFilesField(
label=_('Documents'),
fieldset=_('General event documents')
Expand Down
Loading
Loading