예제 #1
0
 class fields(ew_core.NameList):
     project_description = ew.HiddenField(label='Public Description')
     neighborhood = ew.HiddenField(label='Neighborhood')
     private_project = ew.Checkbox(label="", attrs={'class': 'unlabeled'})
     project_name = ew.InputField(label='Project Name',
                                  field_type='text',
                                  validator=formencode.All(
                                      fev.UnicodeString(not_empty=True,
                                                        max=40),
                                      V.MaxBytesValidator(max=40)))
     project_unixname = ew.InputField(
         label='Short Name',
         field_type='text',
         validator=formencode.All(
             fev.String(not_empty=True), fev.MinLength(3),
             fev.MaxLength(15),
             fev.Regex(
                 r'^[A-z][-A-z0-9]{2,}$',
                 messages={
                     'invalid':
                     'Please use only letters, numbers, and dashes 3-15 characters long.'
                 }), NeighborhoodProjectTakenValidator()))
     tools = ew.CheckboxSet(
         name='tools',
         options=[
             ## Required for Neighborhood functional tests to pass
             ew.Option(label='Wiki', html_value='wiki', selected=True)
         ])
예제 #2
0
 def fields(self):
     socialnetworks = aslist(
         tg.config.get('socialnetworks',
                       ['Facebook', 'Linkedin', 'Twitter', 'Google+']), ',')
     return [
         ew.SingleSelectField(name='socialnetwork',
                              label='Social network',
                              validator=fev.UnicodeString(not_empty=True),
                              options=[
                                  ew.Option(py_value=name, label=name)
                                  for name in socialnetworks
                              ]),
         ew.TextField(name='accounturl',
                      label='Account url',
                      validator=fev.UnicodeString(not_empty=True))
     ]
예제 #3
0
class RootController(BaseController):

    @expose()
    def index(self, **kw):
        now = datetime.utcnow()
        redirect(c.app.url + now.strftime('%Y/%m/%d/'))

    @expose('jinja:forgechat:templates/chat/search.html')
    @validate(dict(q=validators.UnicodeString(if_empty=None),
                   history=validators.StringBool(if_empty=False)))
    def search(self, q=None, history=None, **kw):
        'local tool search'
        results = []
        count=0
        if not q:
            q = ''
        else:
            results = search(
                q,
                fq=[
                    'is_history_b:%s' % history,
                    'project_id_s:%s' % c.project._id,
                    'mount_point_s:%s'% c.app.config.options.mount_point ])
            if results: count=results.hits
        return dict(q=q, history=history, results=results or [], count=count)

    @expose()
    def _lookup(self, y, m, d, *rest):
        y,m,d = int(y), int(m), int(d)
        return DayController(date(y,m,d)), rest
 class BurstNameForm(formencode.Schema):
     """
     Validate Burst name string
     """
     burst_name = formencode.All(
         validators.UnicodeString(not_empty=True),
         validators.Regex(regex=r"^[a-zA-Z\. _\-0-9]*$"))
예제 #5
0
class CreateSiteNotificationSchema(fe.Schema):
    active = fev.StringBool(if_missing=False)
    impressions = fev.Int(not_empty=True)
    content = fev.UnicodeString(not_empty=True)
    user_role = fev.FancyValidator(not_empty=False, if_empty=None)
    page_regex = fev.FancyValidator(not_empty=False, if_empty=None)
    page_tool_type = fev.FancyValidator(not_empty=False, if_empty=None)
예제 #6
0
파일: user.py 프로젝트: scmmmh/webrpg
class LoginUserSchema(schema.Schema):
    """Schema for validating login attempts."""

    email = validators.Email(not_empty=True)
    password = validators.UnicodeString(not_empty=True)

    chained_validators = [PasswordValidator()]
예제 #7
0
class RootController(BaseController):
    @expose()
    def index(self, **kw):
        now = datetime.utcnow()
        redirect(c.app.url + now.strftime('%Y/%m/%d/'))

    @with_trailing_slash
    @expose('jinja:forgechat:templates/chat/search.html')
    @validate(
        dict(q=validators.UnicodeString(if_empty=None),
             project=validators.StringBool(if_empty=False)))
    def search(self, q=None, project=None, limit=None, page=0, **kw):
        c.search_results = SearchResults()
        c.help_modal = SearchHelp(comments=False, history=False)
        search_params = kw
        search_params.update({
            'q': q or '',
            'project': project,
            'limit': limit,
            'page': page,
            'allowed_types': ['Chat Message'],
        })
        d = search_app(**search_params)
        d['search_comments_disable'] = True
        d['search_history_disable'] = True
        return d

    @expose()
    def _lookup(self, y, m, d, *rest):
        y, m, d = int(y), int(m), int(d)
        return DayController(date(y, m, d)), rest
예제 #8
0
class SearchController(BaseController):

    @expose('jinja:allura:templates/search_index.html')
    @validate(dict(q=V.UnicodeString(),
                   history=V.StringBool(if_empty=False)))
    @with_trailing_slash
    def index(self, q=None, history=None, **kw):
        c.search_results = SearchResults()
        c.help_modal = SearchHelp(comments=False)
        pids = [c.project._id] + [
            p._id for p in c.project.subprojects]
        project_match = ' OR '.join(
            'project_id_s:%s' % pid
            for pid in pids)
        search_params = kw
        search_params.update({
            'q': q,
            'history': history,
            'app': False,
            'fq': [
                'project_id_s:(%s)' % project_match,
                '-deleted_b:true',
            ],
        })
        d = search_app(**search_params)
        d['search_comments_disable'] = True
        d['hide_app_project_switcher'] = True
        return d
예제 #9
0
 def fields(self):
     fields = [
         ew.TextField(name='summary', label='Title',
             attrs={'style':'width: 425px','placeholder':'Title'},
             validator=fev.UnicodeString(not_empty=True, messages={'empty':"You must provide a Title"})),
         ffw.MarkdownEdit(label='Description',name='description',
                 attrs={'style':'width: 95%'}),
         ew.SingleSelectField(name='status', label='Status',
             options=lambda: c.app.globals.all_status_names.split()),
         ffw.ProjectUserCombo(name='assigned_to', label='Owner'),
         ffw.LabelEdit(label='Labels',name='labels', className='ticket_form_tags'),
         ew.Checkbox(name='private', label='Mark as Private', attrs={'class':'unlabeled'}),
         ew.InputField(name='attachment', label='Attachment', field_type='file', validator=fev.FieldStorageUploadConverter(if_missing=None)),
         ffw.MarkdownEdit(name='comment', label='Comment',
                     attrs={'style':'min-height:7em; width:97%'}),
         ew.SubmitButton(label=self.submit_text,name='submit',
             attrs={'class':"ui-button ui-widget ui-state-default ui-button-text-only"}),
         ew.HiddenField(name='ticket_num', validator=fev.Int(if_missing=None)),
     ]
     # milestone is kind of special because of the layout
     # add it to the main form rather than handle with the other customs
     if c.app.globals.custom_fields:
         for cf in c.app.globals.custom_fields:
             if cf.name == '_milestone':
                 fields.append(TicketCustomField.make(cf))
                 break
     return ew_core.NameList(fields)
예제 #10
0
파일: account.py 프로젝트: teamwalkr/walkr
class RegisterForm(formencode.Schema):
    """
    Validator for the registration form rendered by 
    ``AccountController.register()``and accepted by 
    ``AccountController.submit()``
    """
    allow_extra_fields = True
    filter_extra_fields = True
    fullname =v.UnicodeString()
    username = formencode.All(v.UnicodeString(not_empty=True), 
                              UsernameValidator())
    password =v.UnicodeString(not_empty=True)
    confirm_password =v.UnicodeString(not_empty=True)
    email =v.Email(not_empty=True)
    confirm_email =v.Email(not_empty=True)
    chained_validators = [v.FieldsMatch('email', 'confirm_email'),
                          v.FieldsMatch('password', 'confirm_password')]
예제 #11
0
class ActionSchema(CSRFSchema):
    """The :class:`~wte.views.user.ActionSchema` handles the validation of
    user action requests.
    """
    action = All(validators.UnicodeString(not_empty=True),
                 validators.OneOf(['validate', 'password', 'delete']))
    """The action to apply"""
    confirm = validators.StringBool(if_empty=False, if_missing=False)
    """Whether the user has confirmed the action"""
    user_id = ForEach(validators.Int(), if_missing=None)
    """User ids to apply the action to"""
    q = validators.UnicodeString(if_empty=None, if_missing=None)
    """Optional query parameter for the redirect"""
    status = validators.UnicodeString(if_empty=None, if_missing=None)
    """Optional status parameter for the redirect"""
    start = validators.UnicodeString(if_empty=None, if_missing=None)
    """Optional start parameter for the redirect"""
예제 #12
0
class TransferSchema(AuthFormSchema):
    "Validate a transfer."
    allow_extra_fields = False
    debtor_id = validators.Int(not_empty=True)
    creditor_id = validators.Int(not_empty=True)
    amount = model.types.CurrencyValidator(not_empty=True)
    description = validators.UnicodeString()
    date = validators.DateConverter()
예제 #13
0
    class fields(ew_core.NameList):
        subject = ew.TextField(validator=fev.UnicodeString(
            not_empty=True, messages={'empty': "You must provide a Subject"}),
                               attrs=dict(
                                   placeholder='Enter your subject here',
                                   title='Enter your subject here',
                                   style='width: 425px'),
                               label='Subject')

        message = ew.TextArea(validator=fev.UnicodeString(
            not_empty=True, messages={'empty': "You must provide a Message"}),
                              attrs=dict(placeholder='Enter your message here',
                                         title='Enter your message here',
                                         style='width: 425px; height:200px'),
                              label='Message')

        cc = ew.Checkbox(label='Send me a copy')
예제 #14
0
class KeycloakLoginForm(formencode.Schema):
    """
        Validate for Login UI Form
    """
    empty_msg = 'Please enter a value'
    auth_token = validators.UnicodeString(not_empty=True,
                                          use_builtins_gettext=False,
                                          messages={'empty': empty_msg})
예제 #15
0
class ForgottenPasswordSchema(CSRFSchema):
    """The :class:`~pywebtools.pyramid.auth.views.ForgottenPasswordSchema` handles the
    validation of forgotten password requests.
    """
    return_to = validators.UnicodeString(if_missing=None)
    """URL to redirect to after a successful password request"""
    email = validators.Email(not_empty=True)
    """E-mail to request a new password or validation token for"""
예제 #16
0
class ProfileForm(Schema):
    allow_extra_fields = True
    filter_extra_fields = True
    delete = validators.StringBoolean(if_missing=False)
    identifier = validators.OpenId(not_empty=True)
    name = validators.UnicodeString(not_empty=True, strip=True)
    email = validators.Email(not_empty=False, resolve_domain=True)
    website = validators.URL(add_http=True)
예제 #17
0
파일: forms.py 프로젝트: githubcodi/allura
 def fields(self):
     return [
         ew.PasswordField(name='oldpw',
                          label='Old Password',
                          validator=fev.UnicodeString(not_empty=True)),
         ew.PasswordField(
             name='pw',
             label='New Password',
             validator=fev.UnicodeString(
                 not_empty=True,
                 min=asint(tg.config.get('auth.min_password_len', 6)),
                 max=asint(tg.config.get('auth.max_password_len', 30)))),
         ew.PasswordField(name='pw2',
                          label='New Password (again)',
                          validator=fev.UnicodeString(not_empty=True)),
         ew.HiddenField(name='return_to'),
     ]
예제 #18
0
class SettingsForm(formencode.Schema):
    """
    Validate Settings Page inputs.
    """

    ADMINISTRATOR_NAME = formencode.All(
        validators.UnicodeString(not_empty=True), validators.PlainText())
    ADMINISTRATOR_PASSWORD = validators.UnicodeString(not_empty=True)
    ADMINISTRATOR_EMAIL = validators.Email(not_empty=True)

    WEB_SERVER_PORT = PortValidator()
    URL_WEB = validators.URL(not_empty=True, require_tld=False)

    SELECTED_DB = validators.UnicodeString(not_empty=True)
    URL_VALUE = validators.UnicodeString(not_empty=True)
    DEPLOY_CLUSTER = validators.Bool()
    CLUSTER_SCHEDULER = validators.UnicodeString(not_empty=True)

    KEYCLOAK_CONFIGURATION = validators.UnicodeString(not_empty=True)
    TVB_STORAGE = validators.UnicodeString(not_empty=True)
    USR_DISK_SPACE = DiskSpaceValidator(not_empty=True)
    MATLAB_EXECUTABLE = MatlabValidator()
    MAXIMUM_NR_OF_THREADS = ThreadNrValidator()
    MAXIMUM_NR_OF_VERTICES_ON_SURFACE = SurfaceVerticesNrValidator()
    MAXIMUM_NR_OF_OPS_IN_RANGE = validators.Int(min=5,
                                                max=5000,
                                                not_empty=True)
예제 #19
0
class BurstNameForm(formencode.Schema):
    """
    Validate Recover Password Form
    """
    burst_name = formencode.All(validators.UnicodeString(not_empty=True), validators.Regex(regex=r"^[a-zA-Z _\-0-9]*$"))
    
    
    
    
예제 #20
0
class ResetForm(formencode.Schema):
    """
    Validator for the reset form rendered by 
    ``AccountController.reset()``and accepted by 
    ``AccountController.reset_submit()``
    """
    allow_extra_fields = True
    filter_extra_fields = True
    login = formencode.All(v.UnicodeString(not_empty=False),
                           LoginExistsValidator())
예제 #21
0
class ExpenditureSchema(AuthFormSchema):
    "Validate an expenditure."
    allow_extra_fields = False
    pre_validators = [NestedVariables()]
    spender_id = validators.Int(not_empty=True)
    amount = model.types.CurrencyValidator(not_empty=True)
    description = validators.UnicodeString(not_empty=True)
    date = validators.DateConverter()
    shares = ForEach(ShareSchema)
    chained_validators = [ValidateNotAllZero]
예제 #22
0
파일: base.py 프로젝트: petertsehsun/allura
class ProjectImportForm(schema.Schema):
    def __init__(self, source):
        super(ProjectImportForm, self).__init__()
        provider = ProjectRegistrationProvider.get()
        self.add_field('tools', ToolsValidator(source))
        self.add_field('project_shortname', provider.shortname_validator)
        self.allow_extra_fields = True

    neighborhood = fev.NotEmpty()
    project_name = fev.UnicodeString(not_empty=True, max=40)
예제 #23
0
class PlanSchema(Schema):
    filter_extra_fields = True
    allow_extra_fields = True
    name = validators.UnicodeString(not_empty=True, strip=True)
    price_per_month = validators.Number(not_empty=True, strip=True)
    max_listings = validators.Int(not_empty=True, strip=True)
    max_premium_listings = validators.Int(not_empty=True, strip=True)
    max_blogposts = validators.Int(not_empty=True, strip=True)
    max_premium_blogposts = validators.Int(not_empty=True, strip=True)
    featured_profile = validators.Bool(not_empty=True)
예제 #24
0
class AnswerPost(Schema):
    allow_extra_fields = True
    filter_extra_fields = True

    q_id = validators.Int()
    body = validators.UnicodeString(
        not_empty=True,
        min=3,
        messages={'empty': u'Please answer the question before submitting'})
    anonymous = validators.Int(if_missing=0)
예제 #25
0
파일: forms.py 프로젝트: githubcodi/allura
    def display(self, **kw):
        categories = kw.get('categories')

        self.fields['selected_category'].options = [
            ew.Option(py_value=el.trove_cat_id, label=el.fullname)
            for el in categories
        ]
        self.fields['selected_category'].validator = formencode.All(
            V.OneOfValidator(categories), fev.UnicodeString(not_empty=True))
        return super(ForgeForm, self).display(**kw)
예제 #26
0
class RegisterForm(Schema):
    forename = v.UnicodeString(not_empty=True)
    surname = v.UnicodeString(not_empty=True)
    middlename = v.UnicodeString()
    username = v.UnicodeString(not_empty=True)
    username = v.UnicodeString(not_empty=True)
    password = v.UnicodeString(not_empty=True)
    password_2 = v.UnicodeString(not_empty=True)
    email = v.UnicodeString(not_empty=True)

    chained_validators = [
        Match('password', 'password_2'),
    ]
예제 #27
0
 def fields(self):
     fields = [
         ew.HiddenField(name='app_id', label='App'),
         ew.TextField(name='name', label='Name',
                      validator=fev.UnicodeString()),
         ew.TextField(name='shortname', label='Short Name',
                      validator=All(
                          fev.Regex(ur"^[^\s\/\.]*$", not_empty=True, messages={
                              'invalid': 'Shortname cannot contain space . or /',
                              'empty': 'You must create a short name for the forum.'}),
                          UniqueForumShortnameValidator())),
         ew.TextField(name='parent', label='Parent Forum'),
         ew.TextField(name='description', label='Description',
                      validator=fev.UnicodeString()),
         ew.TextField(name='monitoring_email',
                      label='Monitoring Email', validator=fev.Email()),
         ew.Checkbox(name="members_only", label="Developer Only"),
         ew.Checkbox(name="anon_posts", label="Allow Anonymous Posts")
     ]
     return fields
예제 #28
0
 class fields(ew_core.NameList):
     name = ew.InputField(
         field_type='text',
         label='Name',
         validator=formencode.All(fev.UnicodeString(not_empty=True, max=40),
                                  V.MaxBytesValidator(max=40)),
         attrs=dict(
             maxlength=40,
             title=
             "This is the publicly viewable name of the project, and will appear on project listings. It should be what you want to see as the project title in search listing."
         ))
     summary = ew.InputField(field_type="text",
                             label='Short Summary',
                             validator=formencode.All(
                                 fev.UnicodeString(max=70),
                                 V.MaxBytesValidator(max=70)),
                             attrs=dict(maxlength=70))
     short_description = ew.TextArea(
         label='Full Description',
         validator=formencode.All(fev.UnicodeString(max=1000),
                                  V.MaxBytesValidator(max=1000)),
         attrs=dict(
             title=
             "Add a few paragraphs describing your project to new users."))
     icon = ew.FileField(label='Icon')
     external_homepage = ew.InputField(field_type="text", label='Homepage')
     support_page = ew.InputField(field_type="text", label='Support Page')
     support_page_url = ew.InputField(field_type="text",
                                      label='Support Page URL')
     removal = ew.InputField(field_type="text", label='Removal')
     moved_to_url = ew.InputField(field_type="text",
                                  label='Moved Project to URL')
     export_controlled = ew.InputField(field_type="text",
                                       label='Export Control')
     export_control_type = ew.InputField(field_type="text",
                                         label='Export Control Type')
     delete = ew.InputField(field_type="hidden", label='Delete')
     delete_icon = ew.InputField(field_type="hidden", label='Delete Icon')
     undelete = ew.InputField(field_type="hidden", label='Undelete')
     tracking_id = ew.InputField(field_type="text",
                                 label="Analytics Tracking ID")
예제 #29
0
class EditForm(formencode.Schema):
    """
    Validator for the registration form rendered by 
    ``AccountController.register()``and accepted by 
    ``AccountController.submit()``
    """
    allow_extra_fields = True
    filter_extra_fields = True
    fullname = v.UnicodeString()
    email = v.Email()
    confirm_email = v.Email()
    password = v.UnicodeString()
    confirm_password = v.UnicodeString()
    '''
    first_area = v.Int()
    first_area_level = v.Int()
    second_area = v.Int()
    second_area_level = v.Int()
    '''
    chained_validators = [v.FieldsMatch('email', 'confirm_email'),
                          v.FieldsMatch('password', 'confirm_password')]
예제 #30
0
class Test_and_Spec(formencode.Schema):
    reference = validators.UnicodeString(not_empty=True, strip=True, encoding='utf-8')
    name = validators.UnicodeString(encoding='utf-8')
    test_group = compound.Any(validators.OneOf(["none","new"]), TestGroupId())    
    new_group = validators.UnicodeString(encoding='utf-8')    
    description = validators.UnicodeString(encoding='utf-8')
    expected_result = validators.UnicodeString(encoding='utf-8')
    code = validators.UnicodeString(encoding='utf-8')
    comment = validators.UnicodeString(encoding='utf-8')
    dependencies = formencode.ForEach(TestSpecId())