class IntegralSchema(colander.Schema): function1 = colander.SchemaNode(colander.String()) function2 = colander.SchemaNode(colander.String(), default='0') min_x = colander.SchemaNode(colander.Float(), default=-5) max_x = colander.SchemaNode(colander.Float(), default=5) min_y = colander.SchemaNode(colander.Float(), default=-5) max_y = colander.SchemaNode(colander.Float(), default=5) draw_grid = colander.SchemaNode(colander.Bool(), widget=FancyCheckboxInput(label='Draw grid'), default=False) draw_labels = colander.SchemaNode(colander.Bool(), widget=FancyCheckboxInput(label='Draw axis labels'), default=True) a = colander.SchemaNode(colander.Float()) b = colander.SchemaNode(colander.Float()) def validator(self, form, values): # todo: find out how to pass a form node to colander.Invalid # currently it seems like I can't force the error on the domains node if values['min_x'] > values['max_x']: e = colander.Invalid(form) e['min_x'] = 'Minimum x-value must be smaller than the maximum x-value' raise e if values['min_y'] > values['max_y']: e = colander.Invalid(form) e['min_y'] = 'Minimum y-value must be smaller than the maximum y-value' raise e
def create_html_view(): from .....flexible_datagrabber import create_datagrabber_html_view import colander import deform from colander import SchemaNode as sn conf = colander.SchemaNode(colander.Mapping()) dirs = colander.SchemaNode(colander.Mapping(),name='Directories') dirs.add(colander.SchemaNode(colander.String(),name='working_dir')) dirs.add(colander.SchemaNode(colander.String(),name='sink_dir')) dirs.add(colander.SchemaNode(colander.String(),name='surf_dir')) dirs.add(colander.SchemaNode(colander.String(),name='crash_dir')) x_opts = colander.SchemaNode(colander.Mapping(),name='Execution Options') x_opts.add(colander.SchemaNode(colander.Bool(),name='run_using_plugin',default=True)) x_opts.add(colander.SchemaNode(deform.Set(), widget=deform.widget.SelectWidget(values=[('PBS','PBS'), ('PBSGraph','PBSGraph'), ('Condor','Condor'), ('CondorDAGMan','CondorDAGMan') ('MultiProc','MultiProc')]), name='plugin')) x_opts.add(sn(colander.String(),name='plugin_args',default='{\'qsub_args\':\'-q many\'}')) x_opts.add(sn(colander.Bool(),name='test_mode')) x_opts.add(sn(colander.Bool(),name='save_script_only')) conf.add(dirs) conf.add(x_opts) return conf
class TriangleSchema(colander.Schema): a = colander.SchemaNode(colander.Float(), validator=colander.Range( min=0, min_err='Side length must be positive'), default=5) b = colander.SchemaNode(colander.Float(), validator=colander.Range( min=0, min_err='Side length must be positive'), default=5) theta = colander.SchemaNode( colander.Float(), validator=colander.Range( min=0, max=180, min_err='Angle must be positive', max_err='Angle must be less than 180 degrees'), default=45) label_a = colander.SchemaNode(colander.String(), missing='') label_b = colander.SchemaNode(colander.String(), missing='') label_c = colander.SchemaNode(colander.String(), missing='') label_angle_A = colander.SchemaNode(colander.String(), missing='') label_angle_B = colander.SchemaNode(colander.String(), missing='') label_angle_C = colander.SchemaNode(colander.String(), missing='') show_angle_A = colander.SchemaNode( colander.Bool(), widget=FancyCheckboxInput(label='Render Angle (A)'), default=True) show_angle_B = colander.SchemaNode( colander.Bool(), widget=FancyCheckboxInput(label='Render Angle (B)'), default=True) show_angle_C = colander.SchemaNode( colander.Bool(), widget=FancyCheckboxInput(label='Render Angle (C)'), default=True)
class ChangeDetails(colander.MappingSchema): """ colander schema (form) to change details of member """ signature_received = colander.SchemaNode( colander.Bool(), title=_(u"Have we received a good signature?")) payment_received = colander.SchemaNode( colander.Bool(), title=_(u"Have we received payment for the shares?"))
class ExportMotionsSchema(colander.Schema): description = _( "Export motions into a meeting. Each motion will be it's own agenda item." ) meeting = colander.SchemaNode( colander.String(), title=_("Export into meeting"), widget=meetings_select_widget, validator=meetings_validator, description=_( "export_meeting_schema_desc", default="You must be moderator in the meeting you wish to export to.", ), ) as_userid = colander.SchemaNode( colander.String(), title=_("Add all proposals as this user"), description=_( "as_userid_schema_description", default="If you want to override the default behaviour to " "add proposals as the person who wrote them. " "Not recommended unless you have a good reason to do so!", ), missing="", widget=deferred_autocompleting_userid_widget, ) clear_ownership = colander.SchemaNode( colander.Bool(), title=_("Clear ownership of proposals?"), description=_( "clear_ownership_description", default="This makes the original author unable to retract their proposals. " "It will still be added in their name.", ), ) view_perm = colander.SchemaNode( colander.Bool(), title=_( "view_perm_schema_title", default="Give included users view permission " "within the meeting", ), description=_( "view_perm_schema_description", default="If you're adding proposals as a specific user, " "the original creators will get the view permission from this setting.", ), default=True, ) states_to_include = colander.SchemaNode( colander.Set(), title=_("Include these states in the export"), default=("endorsed",), widget=motion_states_checkbox_widget, )
class TermsInfo(colander.Schema): """ some legal requirements """ def statute_validator(node, value): """ Validator for statute confirmation. """ if not value: # raise without additional error message as the description # already explains the necessity of the checkbox raise Invalid(node, u'') got_statute = colander.SchemaNode( colander.Bool(true_val=u'yes'), #title=(u''), title=_(u'I acknowledge that the statutes and membership dues ' u'regulations determine periodic contributions ' u'for full members.'), label=_( u'An electronic copy of the statute of the ' u'C3S SCE has been made available to me (see link below).'), description=_(u'You must confirm to have access to the statute.'), widget=deform.widget.CheckboxWidget(), validator=statute_validator, required=True, oid='got_statute', #label=_('Yes, really'), ) def dues_regulations_validator(node, value): """ Validator for dues regulations confirmation. """ if not value: # raise without additional error message as the description # already explains the necessity of the checkbox raise Invalid(node, u'') got_dues_regulations = colander.SchemaNode( colander.Bool(true_val=u'yes'), title=(u''), label=_( u'An electronic copy of the temporary membership dues ' u'regulations of the C3S SCE has been made available to me ' u'(see link below).'), description=_(u'You must confirm to have access to the temporary ' u'membership dues regulations.'), widget=deform.widget.CheckboxWidget(), validator=dues_regulations_validator, required=True, oid='got_dues_regulations', #label=_('Yes'), )
class NotificationSettingsSchema(colander.Schema): mention_notification_setting = colander.SchemaNode( colander.Bool(), title=_("Send mail to mentioned users."), default=True, missing=True, ) poll_notification_setting = colander.SchemaNode( colander.Bool(), title=_("Send mail to voters when a poll starts."), default=False, missing=False, )
class updateUserSchema(colander.Schema): name = colander.SchemaNode(colander.String(), ) login = colander.SchemaNode( colander.String(), validator=login_validator, ) disabled = colander.SchemaNode(colander.Bool(), )
class QRSettingsSchema(colander.Schema): active = colander.SchemaNode( colander.Bool(), title=_("Enable QR code checkin?"), ) log_time = colander.SchemaNode( colander.Bool(), title=_("Log time present for all users?"), default=True, ) assign_pn = colander.SchemaNode( colander.Bool(), title= _("Create and assign a participant number at checkin if the user lacks one?" ), )
class AuthnPluginSettingsSchemaBase(colander.MappingSchema): """ This base schema is intended for use in authentication plugins. It adds a few default settings (e.g., "enabled"), so that plugin authors don't have to maintain a bunch of boilerplate. """ enabled = colander.SchemaNode( colander.Bool(), default=False, description=_('Enable or disable this authentication plugin.'), missing=False, title=_('Enabled'), widget='bool', ) cache_ttl = colander.SchemaNode( colander.Int(), default=0, description=_('Amount of seconds to cache the authentication ' 'call for this plugin. Useful for long calls like ' 'LDAP to improve the responsiveness of the ' 'authentication system (0 means disabled).'), missing=0, title=_('Auth Cache TTL'), validator=colander.Range(min=0, max=None), widget='int', )
class AddIndexSchema(IndexSchema): name = NameSchemaNode(editing=context_is_an_index, insert_before='sd_category') reindex = colander.SchemaNode( colander.Bool(), default=True, )
class PreprocessPortletSchema(colander.Schema): title = colander.SchemaNode( colander.String(), title=_("Title"), ) body = colander.SchemaNode( colander.String(), title=_("Body"), widget=deform.widget.RichTextWidget(), ) button_caption = colander.SchemaNode( colander.String(), title=_("Button caption"), default=_("Add tag(s)"), ) form_title = colander.SchemaNode( colander.String(), title=_("Form title, for the modal window"), ) form_description = colander.SchemaNode( colander.String(), title=_("Form description text, for the modal window"), widget=deform.widget.RichTextWidget(), default="", missing="", ) tags_selectable = OptionItems(widget=deform.widget.SequenceWidget( orderable=True)) tags_widget = colander.SchemaNode( colander.String(), title=_("The widget users select tags with"), description=_( "tags_widget_description", default= "Note! Once the process have started, you can't change widget " "between different types. " "That would cause the saved result to break."), widget=deform.widget.RadioChoiceWidget( values=[(k, v) for (k, v) in TAG_WIDGET_TITLES.items()])) tags_perm = colander.SchemaNode( colander.String(), title=_("Require the following perm to tag"), description= _("tags_perm_description", default= "'${add_prop}' is a sensible default value. For everyone, use '${view}'", mapping={ 'add_prop': ADD_PROPOSAL, 'view': VIEW }), default=ADD_PROPOSAL, missing=ADD_PROPOSAL) process_open = colander.SchemaNode(colander.Bool(), title=_("Is the process open?")) icon = colander.SchemaNode( colander.String(), title=_("Icon CSS classes"), default="glyphicon glyphicon-tags", missing="", )
class AddMultiVotesSchema(BaseMultiVotesSchema): confirm = colander.SchemaNode( colander.Bool(), title=_("I understand the consequences of adding this"), validator=colander.Function(_only_true_validator, _("Confirmation not clicked")), )
class CopyAgendaSchema(colander.Schema): meeting_name = colander.SchemaNode( colander.String(), title=_("Copy Agenda from a previous meeting."), description=_( "You can only pick meeting where you've been a moderator. "), widget=deferred_copy_from_meeting_widget, ) copy_types = colander.SchemaNode( colander.Set(), title=_("Copy these types"), missing=(), default=[x[0] for x in _TYPES_CHOICES], widget=deform.widget.CheckboxChoiceWidget(values=_TYPES_CHOICES)) only_copy_prop_states = colander.SchemaNode( colander.Set(), title=_("Only copy proposals in these states"), missing=(), default=('published', 'approved', 'denied'), widget=prop_states_choice, ) all_props_published = colander.SchemaNode( colander.Bool(), title=_("Make all proposals published?"), description=_("Uncheck this to retain workflow state"))
def test_checkbox_widget_3(): """ Assert setter is implemented. Set True, False """ from pypom_form.widgets import CheckboxWidget import colander widget_class = CheckboxWidget mock_field = colander.SchemaNode( colander.Bool(), selector=('id', 'id1'), ) widget = widget_class(field=mock_field) get_input_element_mock = mock.MagicMock() widget.get_input_element = get_input_element_mock setter = widget.setter_factory() page_mock = mock.MagicMock() page_mock.__class__.setter = property(fset=setter) page_mock.setter = True # let's set False now page_mock.setter = False assert get_input_element_mock. \ return_value.check.call_count == 1 assert get_input_element_mock. \ return_value.uncheck.call_count == 1
class Schema(deform.schema.CSRFSchema): service_types = [(WPS_TYPE, "Web Processing Service"), (THREDDS_TYPE, "Thredds Catalog")] url = colander.SchemaNode( colander.String(), title='Service URL', description="Add URL of service (WPS, Thredds, ...). \ Example: http://localhost:8094/wps, http://localhost/thredds/catalog.xml", default='http://localhost:8094/wps', validator=colander.url, widget=deform.widget.TextInputWidget()) service_title = colander.SchemaNode( colander.String(), missing='', description="An optional service title. \ The title is used as a display name for the service. \ If a title is not provided it will be taken for the service metadata." ) service_name = colander.SchemaNode(colander.String(), missing='', description='An optional service name. \ The service name is used for service identification and must be unique. \ If a service name is not provided it will be generated, like "running_chicken".' ) service_type = colander.SchemaNode( colander.String(), default=WPS_TYPE, widget=deform.widget.RadioChoiceWidget(values=service_types)) public = colander.SchemaNode( colander.Bool(), title="Public access?", description= "Check this option if your service has no access restrictions.", default=False)
class SettingsSchema(colander.Schema): """ Settings for a Repeated IRV poll """ winners = colander.SchemaNode( colander.Int(), title=_("Winners"), description=_("repeated_irv_config_winners_description", default="Numbers of possible winners in the poll."), default=1, ) min_ranked = colander.SchemaNode( colander.Int(), title=_("Minimum ranked candidates"), description=_("repeated_irv_config_min_ranked_description", default="Minimum number of candidates to rank."), default=1, ) random_in_tiebreaks = colander.SchemaNode( colander.Bool(), title=_('Allow random in tiebreaks'), description=_( 'irv_config_random_tiebreak_description', default='Tiebreaks are unusual in real polls. ' 'Disabling this can sometimes lead to an incomplete results.'), default=True, )
class TOSSettingsSchema(colander.Schema): data_consent_managers = colander.SchemaNode( colander.Set(), title=_("Data Consent Manager(s)"), descruption=_( "Users handling consent issues - must have administrator rights"), widget=UserReferenceWidget(), validator=OnlyAdministratorsWithEmailValidator, ) email_consent_managers = colander.SchemaNode( colander.Bool(), title=_("Notify via email?"), description=_( "email_consent_managers_desc", default= "Email consent managers when a user revokes an important agreement.", ), ) tos_folder = colander.SchemaNode( colander.String(), title=_("Folder to place TOS in"), description=_( "tos_folder_schema_description", default= "If you don't have any folders yet, create one in the root of your site." ), widget=ReferenceWidget(multiple=False, query_params={"type_name": "Folder"}))
class TOSAgreeSchema(colander.Schema): widget = maybe_modal_form agree_check = colander.SchemaNode( colander.Bool(), title=_("I've read the full agreement and I agree to it"), validator=colander.Function( _return, _("You must agree to the terms to use this site.")), )
class TOSSchema(colander.Schema): title = colander.SchemaNode(colander.String(), title=_("Title")) body = colander.SchemaNode( colander.String(), title=_("Text to agree to"), widget=deform.widget.RichTextWidget(), ) collapse_text = colander.SchemaNode( colander.Bool(), title=_("Collapse agreement text?"), description=_("Causes a read full text link to be displayed instead."), ) revoke_body = colander.SchemaNode( colander.String(), title=_("Consequences of revoking the agreement"), description=_( "revoke_body_description", default="Will be displayed when the revocation form " "is shown to inform of the consequences. " "If the conseqences are severe, please do express that here!", ), widget=deform.widget.RichTextWidget(), missing="", ) lang = colander.SchemaNode( colander.String(), title=_("Only for this language"), description=_( "If set, only show this agreement for users using this lang."), widget=available_languages, default="", missing="", ) check_password_on_revoke = colander.SchemaNode( colander.Bool(), title=_("Require password check on revoke"), description=_("This will only be enforced for enabled TOS"), default=False, ) check_typed_on_revoke = colander.SchemaNode( colander.Bool(), title=enable_typed_revoke_description, description=_("This will only be enforced for enabled TOS"), default=False, )
class ProfileSchema(colander.MappingSchema): applicationId = colander.SchemaNode(colander.String()) candidateId = colander.SchemaNode(colander.Integer()) isRetake = colander.SchemaNode(colander.Bool()) invitationDate = colander.SchemaNode(colander.DateTime()) applicationTime = colander.SchemaNode(colander.DateTime()) speechToText = SpeechToTextSequence() videoLength = colander.SchemaNode(colander.Float()) score = colander.SchemaNode(colander.Integer())
class SelectContentSchema(colander.Schema): selected_content = colander.SchemaNode(colander.List(), title=_(u"Select content to show"), missing=(), widget=ReferenceWidget()) show_body = colander.SchemaNode( colander.Bool(), title=_(u"Show content body, if any"), )
class AgendaPortletSchema(colander.Schema): hide_type_count = colander.SchemaNode( colander.Bool(), title=_("Hide type and unread count"), description= _("Will speed up loading for physical meetings with lots of participants" ), default=False, missing=False, )
class EventHeader(colander.MappingSchema): id_ = colander.SchemaNode( colander.String(), name='id', default=deferred_guid, ) channel = colander.SchemaNode(colander.String()) timestamp = colander.SchemaNode(colander.DateTime(), default=deferred_utcnow) composition = colander.SchemaNode(colander.Bool(), default=colander.drop) context = EventContext(default=colander.drop)
class AnswerSchema(ContentSchema): title = colander.SchemaNode( colander.String(), title=_(u'Answering Choice:'), ) correct = colander.SchemaNode( colander.Bool(), title=_(u'Answer Type'), widget=RadioChoiceWidget(values=[ [True, _("Correct Answer")], [False, _("Incorrect Answer")]]) )
class Shop(colander.TupleSchema): """Activate entity in this Shop value: [ShopID, Bool] Example values: [ch_hobby, True] | [ch_hobby, True] | [ch_hobby, True] """ shopeid = ShopID() activated = colander.SchemaNode(colander.Bool(), default=False, missing=False)
class EffectSettingsSchema(colander.Schema): effect_active = colander.SchemaNode( colander.Bool(), title="Aktivera knapp för effekter", ) effect_actors = colander.SchemaNode( colander.String(), title="Aktörer", description= "Skrivs som sammansatta ord, utan # eller andra specialtecken. En per rad.", widget=deform.widget.TextAreaWidget(rows=5), validator=hashtag_text_validator, missing="", )
class AccountRegister(colander.MappingSchema): name = colander.SchemaNode(colander.String(), validator=colander.Regex(REGISTER_NAME_RE)) fullname = colander.SchemaNode(colander.String()) email = colander.SchemaNode(colander.String(), validator=colander.Email()) password1 = colander.SchemaNode(colander.String(), validator=colander.Length(min=4)) password2 = colander.SchemaNode(colander.String(), validator=colander.Length(min=4)) terms = colander.SchemaNode(colander.Bool()) subscribe_community = colander.SchemaNode(colander.Boolean(), missing=False) subscribe_developer = colander.SchemaNode(colander.Boolean(), missing=False)
class BaseSchema(colander.Schema): nav_visible = colander.SchemaNode(colander.Bool(), title=_(u"Show in navigations"), missing=colander.null, default=default_factory_attr, tab=tabs['visibility']) listing_visible = colander.SchemaNode( colander.Bool(), title=_(u"Show in listing or table views"), description= _(u"The content view will always show this regardless of what you set." ), missing=colander.null, default=default_factory_attr, tab=tabs['visibility']) search_visible = colander.SchemaNode( colander.Bool(), title=_(u"Include in search results"), description=_( u"Note that this is not a permission setting - it's just a matter of practicality for users. " u"They may even disable this setting."), missing=colander.null, default=default_factory_attr, tab=tabs['visibility'])
class PollSettingsSchema(colander.Schema): polls_menu_only_links = colander.SchemaNode( colander.Bool(), title=_("Disable modal popups for polls menu?"), description=_("schema_polls_menu_only_links_description", default="If disabled, the polls menu will simply link to " "the agenda item with the poll item instead."), missing=False, default=False, ) poll_proposals_default_order = colander.SchemaNode( colander.String(), title=_('Default proposal order'), widget=deform.widget.RadioChoiceWidget(values=PROPOSAL_ORDER_CHOICES), missing='', )