class MySchema(MappingSchema): name = SchemaNode(String(), description='The name of this thing') title = SchemaNode(String(), widget=widget.TextInputWidget(size=40), validator=Length(max=20), description='A very short title') password = SchemaNode(String(), widget=widget.CheckedPasswordWidget(), validator=Length(min=5)) is_cool = SchemaNode(Boolean(), default=True) dates = DatesSchema() color = SchemaNode(String(), widget=widget.RadioChoiceWidget(values=colors), validator=OneOf(('red', 'blue')))
class SignupSchema(colander.MappingSchema): """ Signup form schema for creation and validation. """ username = colander.SchemaNode(colander.String(), validator=colander.Regex(usernameregex, msg)) firstname = colander.SchemaNode(colander.String()) lastname = colander.SchemaNode(colander.String()) password = colander.SchemaNode(colander.String(), validator=colander.Length(min=5, max=100), widget=widget.CheckedPasswordWidget(size=20), description='Enter a password') email = colander.SchemaNode(colander.String(), validator=colander.Email()) gender = colander.SchemaNode(colander.String(), widget=widget.RadioChoiceWidget(values=(('male', 'Male'), ('female', 'Female'),('other', 'Other'))), title='Choose your gender', description='Select a gender', validator=colander.OneOf(('male', 'female', 'other'))) interestedin = colander.SchemaNode(Set(), widget=widget.CheckboxChoiceWidget(values=(('men', 'Men'), ('women', 'Women')))) lookingfor =colander.SchemaNode(Set(), widget=widget.CheckboxChoiceWidget(values=looking_fors)) age = colander.SchemaNode(colander.String(), widget=widget.SelectWidget(values=ages)) class EditSchema(colander.MappingSchema): """ Profile edit schema for form creation and validation. """
class EditRequestSchema(colander.Schema): # cybeTimestamp couTimestamp = colander.SchemaNode( colander.DateTime(), title='Security and Acceptable Use Policy Acceptance', description='date', widget=widget.DateInputWidget(), oid='couTimestamp' ) givenName = colander.SchemaNode( colander.String(), title='Given/First name', description='Your given or first name', validator=colander.Length(min=1, max=64), widget=widget.TextInputWidget(), oid='givenName' ) middleName = colander.SchemaNode( colander.String(), title='Middle name/initial', description='Middle name or initial', validator=colander.Length(min=0, max=64), widget=widget.TextInputWidget(), missing=unicode(''), oid='middleName' ) sn = colander.SchemaNode( colander.String(), title='Family/Last Name', description='family Name / Last Name', validator=colander.Length(min=1, max=64), widget=widget.TextInputWidget(), oid='sn' ) suffix = colander.SchemaNode( colander.String(), title='Suffix', description='(Sr. Jr. IV, etc.)', validator=colander.Length(min=0, max=32), widget=widget.TextInputWidget(), missing=unicode(''), oid='suffix' ) cn = colander.SchemaNode( colander.String(), title='Common or Nick Name', description='Your full name. How you want to be addressed.', validator=colander.Length(min=3, max=64), widget=widget.TextInputWidget(), missing=unicode(''), oid='cn' ) street = colander.SchemaNode( colander.String(), title='Street Address', description='', validator=colander.Length(min=0, max=200), widget=widget.TextInputWidget(), oid='street' ) lcity = colander.SchemaNode( colander.String(), title='City', description='', validator=colander.Length(min=1, max=128), widget=widget.TextInputWidget(), oid='lcity' ) st = colander.SchemaNode( colander.String(), title='State/Province', description='', validator=colander.Length(min=1, max=128), widget=widget.TextInputWidget(), oid='l' ) postalCode = colander.SchemaNode( colander.String(), title='Post/ZIP Code', description='', validator=colander.Length(min=2, max=64), widget=widget.TextInputWidget(), oid='postalCode' ) country = colander.SchemaNode( colander.String(), title='Country', description='', widget=widget.TextInputWidget(values=country_codes), validator=valid_country, oid='country' ) mail = colander.SchemaNode( colander.String(), title='EMail', description='Your primary email account', widget=widget.TextInputWidget(), oid='mail' ) # # mailPreferred = colander.SchemaNode( # colander.String(), # title='Preferred EMail', # description='optional preferred email account', # missing=unicode(''), # widget=widget.TextInputWidget(), # oid='mail' # ) phone = colander.SchemaNode( colander.String(), title='Phone number', description='Please provide your primary telephone number', validator=phone_validator, widget=widget.TextInputWidget(), oid='phone' ) cell = colander.SchemaNode( colander.String(), title='Cell phone number', description='For contact and verification', validator=phone_validator, missing=unicode(''), widget=widget.TextInputWidget(), oid='cell' ) employerType = colander.SchemaNode( colander.String(), # validator=colander.OneOf([x[0] for x in employer_types]), validator=colander.OneOf([x[0] for x in employer_types]), widget=deform.widget.RadioChoiceWidget(values=employer_types), title='Employer Type', description='', oid="employerType" ) employerName = colander.SchemaNode( colander.String(), title='Employer/Institution/Sponsor', description='Provided employer or institution name', validator=colander.Length(min=3, max=128), widget=widget.TextInputWidget(), oid='employerName' ) citizenStatus = colander.SchemaNode( colander.String(), title='Citizenship Status', description='Select one of the following options ' 'that best describes your U.S. citizenship status', validator=colander.OneOf([x[0] for x in citizen_types]), widget=widget.RadioChoiceWidget(values=citizen_types), oid='citizenStatus' ) citizenships = colander.SchemaNode( colander.Set(), title='Citizenships', description='Please select your country or countries of citizenship', # validator=valid_countries, default=deferred_citz_default, widget=deferred_citizenships_widget, oid='citizenships', ) birthCountry = colander.SchemaNode( colander.String(), title='Country of birth', description='Please enter/select your country of birth', validator=valid_country, # widget=widget.Select2Widget(values=country_codes), widget=widget.TextInputWidget(), oid='birthCountry', ) nrelUserID = colander.SchemaNode( colander.String(), title='Your Existing NREL HPC UserID', description='If you have --or previously had-- an NREL UserID, ' 'enter it here.', validator=colander.Length(min=1, max=16), widget=widget.TextInputWidget(), missing=unicode(''), oid='nrelUserID' ) justification = colander.SchemaNode( colander.String(), title='Justification', widget=widget.TextAreaWidget(), missing=unicode(''), validator=colander.Length(max=1000), description="The provided justification/comments for new account.", oid='comments' ) preferredUID = colander.SchemaNode( colander.String(), title='Requested UserID', description="The userid the user would prefer", validator=colander.Length(min=3, max=16), widget=widget.TextInputWidget(), missing=unicode(''), oid='preferredUID' ) comments = colander.SchemaNode( colander.String(), title='Additional Notes or Comments', widget=widget.TextAreaWidget(), missing=unicode(''), validator=colander.Length(max=1000), description='Additional information', oid='comments' ) UserID = colander.SchemaNode( colander.String(), title='Assigned Permanent HPC UserID', description='Determined by Center Operations.' ' This MUST match what is in IDM.', validator=colander.Length(min=1, max=16), widget=widget.TextInputWidget(), default=None, missing=unicode(''), oid='UserID' ) approvalStatus = colander.SchemaNode( colander.Integer(), title='Approval Status', description='The current status of the request\'s review process', validator=colander.OneOf([x[0] for x in approval_status]), default=0, widget=widget.RadioChoiceWidget(values=approval_status), oid='approvalStatus' )
def deferred_review_status_widget(node, kw): return widget.RadioChoiceWidget(values=approval_status)
class AddAccountSchema(colander.Schema): """ """ # couTimestamp cou = colander.SchemaNode( colander.Boolean(), title='Security and Acceptable Use Policy Acceptance', description='Terms and Conditions Agreement - Check this if ' 'you have read and agree to abide by the Center\'s ' 'Security and Acceptable Use Policies.', widget=widget.CheckboxWidget(), validator=cou_validator, oid='cou') # storTimestamp stor = colander.SchemaNode( colander.Boolean(), title='Data Security Policy Acceptance', description='Check this if you have read and agree ' 'to the Center\'s storage policies.', widget=deform.widget.CheckboxWidget(), validator=stor_validator, oid='stor') # cybeTimestamp # cyber = colander.SchemaNode( # colander.Boolean(), # title='Cyber Security Policy Acceptance', # description='Check this if you have read and agree to abide by ' # 'the Center\'s Cyber Security policies.', # widget=deform.widget.CheckboxWidget(), # validator=cyber_validator, # oid='cyber' # ) # titlePrefix = colander.SchemaNode( # colander.String(), # title='Honorary', # description='If you prefer to use n honorary, enter it here.', # # validator=colander.ContainsOnly([x[0] for x in title_prefixes]), # #validator=colander.Length(min=1, max=64), # widget=widget.TextInputWidget(placeholder="Dr., Mr., Ms., etc."), # missing=unicode(''), # oid='titlePrefix' # ) givenName = colander.SchemaNode( colander.String(), title='Given/First name', description='Your given or first name', validator=colander.Length(min=1, max=64), widget=widget.TextInputWidget(placeholder=''), oid='givenName') middleName = colander.SchemaNode( colander.String(), title='Middle name/initial', description='Middle name or initial', validator=colander.Length(min=0, max=64), widget=widget.TextInputWidget(placeholder=''), missing=unicode(''), oid='middleName') sn = colander.SchemaNode(colander.String(), title='Family/Last Name', description='family Name / Last Name', validator=colander.Length(min=1, max=64), widget=widget.TextInputWidget(placeholder=''), oid='sn') suffix = colander.SchemaNode( colander.String(), title='Suffix', description='(Sr. Jr. IV, etc.)', validator=colander.Length(min=0, max=32), widget=widget.TextInputWidget(placeholder='example: III, PhD, etc.'), missing=unicode(''), oid='suffix') cn = colander.SchemaNode( colander.String(), title='Common or Nick Name', description='Your full name. How you want to be addressed.', validator=colander.Length(min=3, max=64), widget=widget.TextInputWidget( placeholder='(Optional) How you want to be addressed ' 'if different from: FirstName LastName'), missing=unicode(''), oid='cn') street = colander.SchemaNode( colander.String(), title='Street Address', description='', validator=colander.Length(min=0, max=200), widget=widget.TextInputWidget( placeholder='business/institution address'), oid='street') lcity = colander.SchemaNode(colander.String(), title='City', description='', validator=colander.Length(min=1, max=128), widget=widget.TextInputWidget(), oid='lcity') st = colander.SchemaNode(colander.String(), title='State/Province', description='', validator=colander.Length(min=1, max=128), widget=widget.TextInputWidget(), oid='l') postalCode = colander.SchemaNode(colander.String(), title='Post/ZIP Code', description='', validator=colander.Length(min=2, max=64), widget=widget.TextInputWidget(), oid='postalCode') country = colander.SchemaNode( colander.String(), title='Country', description='', widget=widget.SelectWidget(values=country_codes), #validator=colander.OneOf([x[0] for x in country_codes]), validator=valid_country, oid='country') mail = colander.SchemaNode( colander.String(), title='EMail', description='Your primary email account', # validator=colander.Email(msg="Please provide your work Email address. This will be the primary account we use to contact you."), widget=email_confirm_widget, oid='mail') # mailPreferred = colander.SchemaNode( # colander.String(), # title='Preferred EMail', # description='optional preferred email account', # missing=unicode(''), # widget=pref_email_confirm_widget, # oid='mail' # ) phone = colander.SchemaNode( colander.String(), title='Phone number', description='Please provide your primary telephone number', validator=phone_validator, widget=widget.TextInputWidget(), oid='phone') cell = colander.SchemaNode( colander.String(), title='Cell phone number', description='For contact and verification', validator=phone_validator, missing=unicode(''), widget=widget.TextInputWidget( placeholder='(Optional) example: +1-000-000-0000'), oid='cell') employerType = colander.SchemaNode( colander.String(), validator=colander.OneOf([x[0] for x in employer_types]), widget=deform.widget.RadioChoiceWidget(values=employer_types), title='Employer Type', description='Select the employer type from the list below that ' 'is most appropriate to your request', oid="employerType") employerName = colander.SchemaNode( colander.String(), title='Employer, Institution, or Sponsor Name', description='Please provide the name of your employer or ' 'the institution you represent', validator=colander.Length(min=3, max=128), widget=widget.TextInputWidget(placeholder='employer name here'), oid='employerName') citizenStatus = colander.SchemaNode( colander.String(), title='Citizenship Status', description='Select one of the following options ' 'that best describes your U.S. citizenship status', validator=colander.OneOf([x[0] for x in citizen_types]), widget=widget.RadioChoiceWidget(values=citizen_types), oid='citizenStatus') citizenships = colander.SchemaNode( colander.Set(), title='Citizenships', description='Please select your country or countries of citizenship', validator=valid_countries, widget=widget.Select2Widget(values=country_codes, multiple=True), oid='citizenships', ) # birthCountry birthCountry = colander.SchemaNode( colander.String(), title='Country of birth', description='Please enter/select your country of birth', validator=valid_country, widget=widget.Select2Widget(values=country_codes), oid='birthCountry', ) isnreluser = colander.SchemaNode( colander.String(), title='Existing NREL Account?', description="Select the option that is most true for you.", widget=deform.widget.RadioChoiceWidget(values=has_account), missing=unicode(''), label='Existing or Previous ESIF HPC UserID', oid='isnreluser') nrelUserID = colander.SchemaNode( colander.String(), title='Your Existing NREL HPC UserID', description='If you have --or previously had-- an NREL UserID, ' 'enter it here.', validator=colander.Length(min=1, max=16), widget=widget.TextInputWidget(placeholder='example: jsmythe'), missing=unicode(''), oid='nrelUserID') justification = colander.SchemaNode( colander.String(), title='NREL HPC User Credential Information', widget=widget.TextAreaWidget(rows=6, columns=60), missing=unicode(''), validator=colander.Length(max=1000), description="If you don't have an account on NREL HPC systems, " "we need some additional information. Please provide " "the project handles or titles of the project allocations " "you are associated with. " "If you don't have an allocation, please tell us " "why you are requesting NREL HPC login credentials.", oid='comments') preferredUID = colander.SchemaNode( colander.String(), title='*New* ESIF HPC UserID', description="Please provide your desired User ID here.<sup>1</sup>" "(3 to 16 characters, all lower case.)", validator=colander.Length(min=3, max=16), widget=widget.TextInputWidget(placeholder="example: jsmythe"), missing=unicode(''), oid='preferredUID') comments = colander.SchemaNode( colander.String(), title='Additional Notes or Comments', widget=deform.widget.TextAreaWidget( rows=6, columns=60, placeholder='If you think we need any additional ' 'information to process or approve your request, ' 'please let us know (project name, PI, NREL contact, etc.).'), missing=unicode(''), validator=colander.Length(max=1000), description='If you think we need any additional ' 'information to process or approve your request, ' 'please let us know.', oid='comments')