class ZMIConfigurationRibbonGroup(FormGroupChecker): """ZMI configuration ribbon fields""" fields = Fields(IZMIConfiguration).select('include_ribbon', 'fixed_ribbon') fields['fixed_ribbon'].widget_factory = SingleCheckBoxFieldWidget weight = 40
class DocumentContainerSynchronizerEditForm(InnerEditForm): """Document container synchronizer edit form""" legend = _("Synchronizer configuration") fields = Fields(IDocumentSynchronizer) weight = 10
def extends(*args, **kwargs): """Extend fields, buttons and handlers""" frame = sys._getframe(1) # pylint: disable=protected-access f_locals = frame.f_locals if not kwargs.get('ignore_fields', False): f_locals['fields'] = Fields() for arg in args: f_locals['fields'] += getattr(arg, 'fields', Fields()) if not kwargs.get('ignore_buttons', False): f_locals['buttons'] = Buttons() for arg in args: f_locals['buttons'] += getattr(arg, 'buttons', Buttons()) if not kwargs.get('ignore_handlers', False): f_locals['handlers'] = Handlers() for arg in args: f_locals['handlers'] += getattr(arg, 'handlers', Handlers())
class JobHistoryView(AdminModalDisplayForm): """Job run history display form""" @property def title(self): """Title getter""" return get_parent(self.context, ITask).name legend = _("Task run history") modal_class = 'modal-max' label_css_class = 'col-sm-3 col-md-2' input_css_class = 'col-sm-9 col-md-10' fields = Fields(ITaskHistory).omit('__parent__', '__name__') def update_widgets(self, prefix=None): super().update_widgets(prefix) duration = self.widgets.get('duration') if duration is not None: duration.value = get_duration( timedelta(seconds=self.context.duration)) report = self.widgets.get('report') if report is not None: report.rows = 15 report.add_class('monospace')
class DocumentSearchForm(SearchForm): """Document search form""" title = _("Documents search form") fields = Fields(IDocumentSearchFields) label_css_class = 'col-sm-3' input_css_class = 'col-sm-9' object_data = {'ams-warn-on-change': False} def update_widgets(self, prefix=None): super().update_widgets(prefix) oid = self.widgets.get('oid') if oid is not None: oid.input_css_class = 'col-sm-3' version = self.widgets.get('version') if version is not None: version.input_css_class = 'col-sm-3' placeholder = self.request.localizer.translate( _("No selected principal")) creator = self.widgets.get('creator') if creator is not None: creator.placeholder = placeholder owner = self.widgets.get('owner') if owner is not None: owner.placeholder = placeholder updater = self.widgets.get('updater') if updater is not None: updater.placeholder = placeholder status_updater = self.widgets.get('status_updater') if status_updater is not None: status_updater.placeholder = placeholder
class TaskRunEditForm(TaskBaseFormMixin, AdminModalEditForm): """Task run edit form""" legend = _("Task execution") modal_class = 'modal-xl' has_border = True fields = Fields(Interface) buttons = Buttons(ITaskRunButtons).select('debug', 'run', 'close') def update_actions(self): super().update_actions() debug = self.actions.get('debug') if debug is not None: debug.add_class('btn-info mr-auto') @handler(ITaskRunButtons['debug']) def handle_debug(self, action): """Debug button handler""" report = StringIO() self.context.run(report) self.finished_state.update({ 'action': action, 'changes': report.getvalue() }) @handler(ITaskRunButtons['run']) def handle_apply(self, action): """Task run button handler""" self.context.launch() self.finished_state.update({'action': action, 'changes': self.context})
class ZMIConfigurationHeaderGroup(FormGroupChecker): """ZMI configuration header fields""" fields = Fields(IZMIConfiguration).select('include_header', 'fixed_header', 'logo') fields['fixed_header'].widget_factory = SingleCheckBoxFieldWidget weight = 10
class ZMIConfigurationSearchGroup(FormGroupChecker): """ZMI configuration search fields""" fields = Fields(IZMIConfiguration).select('include_site_search', 'site_search_placeholder', 'site_search_handler') weight = 20
class ServerTimezonePropertiesEditForm(AdminModalEditForm): """Server timezone properties edit form""" title = _("Server timezone") legend = _("Properties") fields = Fields(IServerTimezone) _edit_permission = MANAGE_SYSTEM_PERMISSION
class ZMIConfigurationMiscGroup(Group): """ZMI configuration misc fields""" legend = _("Custom extensions") fields = Fields(IZMIConfiguration).select('custom_stylesheet', 'base_body_css_class', 'custom_script') weight = 50
class UserSkinPropertiesInheritGroup(FormGroupChecker): """User skin properties inherit group""" def __new__(cls, context, request, parent_form): if not IUserSkinnable(context).can_inherit_skin: return None return FormGroupChecker.__new__(cls) fields = Fields(IUserSkinnable).select('override_skin') checker_fieldname = 'override_skin' checker_mode = 'disable'
class SearchForm(AdminAddForm): """Base search form""" title = _("Search form") legend = _("Search criteria") fields = Fields(ISearchInfo) buttons = Buttons(ISearchButtons) ajax_form_handler = 'search-results.html' ajax_form_target = '#search-results'
class RESTTaskFormJWTInfo(FormGroupChecker): """REST task form JWT info""" fields = Fields(IRESTCallerTaskInfo).select('use_jwt_authority', 'jwt_authority_url', 'jwt_token_service', 'jwt_token_attribute', 'jwt_use_proxy') fields['jwt_use_proxy'].widget_factory = SingleCheckBoxFieldWidget weight = 30
class AlchemyEngineAddForm(AlchemyEngineBaseAddFormMixin, AdminModalAddForm): # pylint: disable=abstract-method """SQLAlchemy engine add form""" legend = _("New engine properties") fields = Fields(IAlchemyEngineUtility) content_factory = IAlchemyEngineUtility def add(self, obj): oid = IUniqueID(obj).oid self.context[oid] = obj
class TaskScheduleEditForm(TaskBaseFormMixin, AdminModalEditForm): """Task schedule edit form""" legend = _("Task schedule properties") fields = Fields(Interface) def apply_changes(self, data): changes = super().apply_changes(data) if changes: self.context.reset() return changes
class ZMIConfigurationNavigationGroup(FormGroupChecker): """ZMI configuration navigation fields""" fields = Fields(IZMIConfiguration).select('include_menus', 'include_minify_button', 'fixed_navigation', 'accordion_menus') fields['include_minify_button'].widget_factory = SingleCheckBoxFieldWidget fields['fixed_navigation'].widget_factory = SingleCheckBoxFieldWidget fields['accordion_menus'].widget_factory = SingleCheckBoxFieldWidget weight = 30
class BaseTaskEditForm(TaskBaseFormMixin, AdminModalEditForm): """Base task edit form""" legend = _("Task properties") fields = Fields(ITaskInfo).select('name', 'schedule_mode') def apply_changes(self, data): changes = super().apply_changes(data) if changes: self.context.reset() return changes
class AlchemyEngineCloneForm(AlchemyEngineBaseAddFormMixin, AdminModalAddForm): """SQLAlchemy engine clone form""" legend = _("Clone SQL connection") fields = Fields(IAlchemyEngineUtility).select('name') def create(self, data): return copy(self.context) def add(self, obj): oid = IUniqueID(obj).oid self.context.__parent__[oid] = obj
class JWTProxyConfigurationGroup(FormGroupChecker): """JWT proxy configuration edit group""" fields = Fields(IJWTSecurityConfiguration).select( 'proxy_mode', 'authority', 'get_token_service', 'proxy_access_token_name', 'proxy_refresh_token_name', 'get_claims_service', 'refresh_token_service', 'verify_token_service', 'verify_ssl') fields['verify_ssl'].widget_factory = SingleCheckBoxFieldWidget weight = 20 def get_content(self): return IJWTSecurityConfiguration(self.context)
class TaskCloneForm(TaskBaseFormMixin, AdminModalAddForm): """Task clone form""" legend = _("Clone task") fields = Fields(ITask).select('name') def create(self, data): return copy(self.context) def add(self, obj): intids = get_utility(IIntIds) self.context.__parent__[hex(intids.register(obj))[2:]] = obj
class UserSkinPropertiesInnerEditForm(InnerEditForm): """User skin properties inner edit form""" @property def legend(self): if IUserSkinnable(self.context).can_inherit_skin: return None return _("Skin properties") border_class = '' fields = Fields(IUserSkinnable).select('skin', 'container_class', 'custom_stylesheet', 'editor_stylesheet', 'custom_script')
class RESTTaskFormAuthInfo(FormGroupChecker): """REST task form auth info""" legend = _("Authentication") fields = Fields(IRESTCallerTaskInfo).select('authenticate', 'username', 'password') weight = 10 def update_widgets(self, prefix=None): super().update_widgets(prefix) password = self.widgets.get('password') if password is not None: password.autocomplete = 'new-password'
class RESTTaskFormProxyInfo(FormGroupChecker): """REST task form proxy info""" legend = _("Proxy settings") fields = Fields(IRESTCallerTaskInfo).select('use_proxy', 'proxy_server', 'proxy_port', 'proxy_username', 'proxy_password') weight = 20 def update_widgets(self, prefix=None): super().update_widgets(prefix) password = self.widgets.get('proxy_password') if password is not None: password.autocomplete = 'new-password'
class ZMIConfigurationForm(AdminEditForm): """ZMI configuration form""" title = _("ZMI configuration") legend = _("Interface configuration") fields = Fields(IZMIConfiguration).select('site_name', 'home_name', 'application_name', 'application_package', 'inner_package_name', 'inner_package', 'environment', 'myams_bundle', 'favicon') def get_content(self): return IZMIConfiguration(self.context)
class BaseTaskAddFormInfo(InnerAddForm): """Base task add form general information tab""" title = _("Task reports") fields = Fields(ITaskInfo).select('keep_empty_reports', 'history_duration', 'history_length') weight = 100 def update_widgets(self, prefix=None): """Widgets update""" super().update_widgets(prefix) widget = self.widgets.get('history_duration') if widget is not None: widget.prefix = TaskHistoryHelpMessage(self.context, self.request, self, None)
class BaseTaskAddForm(AdminModalAddForm): # pylint: disable=abstract-method """Base task add form""" @property def title(self): """Title getter""" translate = self.request.localizer.translate return '<small>{}</small><br />{}'.format( get_object_label(self.context, self.request, self), translate(_("New task: {}")).format(translate(self.content_label))) legend = _("New task properties") content_label = '--' fields = Fields(ITaskInfo).select('name', 'schedule_mode') def add(self, obj): intids = get_utility(IIntIds) self.context[hex(intids.register(obj))[2:]] = obj
class JWTSecurityConfigurationEditForm(AdminEditForm): """JWT security configuration edit form""" title = _("Security manager") legend = _("JWT configuration") fields = Fields(IJWTSecurityConfiguration).select('access_token_name', 'refresh_token_name') def get_content(self): return IJWTSecurityConfiguration(self.context) def apply_changes(self, data): configuration = self.get_content() old_region = configuration.selected_cache changes = super(JWTSecurityConfigurationEditForm, self).apply_changes(data) if changes and (old_region is not None): clear_cache(JWT_PROXY_CACHE_NAME, old_region, JWT_PROXY_TOKENS_NAMESPACE) return changes
class JWTConfigurationGroup(FormGroupChecker): """JWT configuration edit group""" fields = Fields(IJWTSecurityConfiguration).select('local_mode', 'algorithm', 'secret', 'private_key', 'public_key', 'access_expiration', 'refresh_expiration') weight = 10 def update_widgets(self, prefix=None): super(JWTConfigurationGroup, self).update_widgets(prefix) widget = self.widgets.get('private_key') if widget is not None: widget.prefix = JWTConfigurationKeyAlert(self.context, self.request, self, None) widget.rows = 15 widget.add_class('monospace') widget = self.widgets.get('public_key') if widget is not None: widget.rows = 5 widget.add_class('monospace')
class RESTTaskFormInfo(GroupManager): """REST API caller task add form info""" title = _("HTTP/REST API settings") fields = Fields(IRESTCallerTaskInfo).select('base_url', 'service', 'params', 'verify_ssl', 'connection_timeout', 'ok_status', 'allow_redirects') fields['verify_ssl'].widget_factory = SingleCheckBoxFieldWidget fields['allow_redirects'].widget_factory = SingleCheckBoxFieldWidget def update_widgets(self, prefix=None): """Widgets update""" super().update_widgets(prefix) # pylint: disable=no-member params = self.widgets.get('params') # pylint: disable=no-member if params is not None: params.add_class('height-100') params.widget_css_class = "editor height-200px" params.object_data = {'ams-filename': 'params.json'} alsoProvides(params, IObjectData)
class AlchemyEngineEditForm(AdminModalEditForm): """SQLAlchemy engine properties edit form""" @property def title(self): translate = self.request.localizer.translate manager = query_utility(IAlchemyManager) return '<small>{}</small><br />{}'.format( get_object_label(manager, self.request, self), translate(_("SQL engine: {}")).format(self.context.name)) legend = _("SQL engine properties") fields = Fields(IAlchemyEngineUtility) def update_widgets(self, prefix=None): super().update_widgets(prefix) name = self.widgets.get('name') if name is not None: name.mode = DISPLAY_MODE