Beispiel #1
0
 def GET(self):
     if web.ctx.session.login != 1:
         raise web.seeother('/#login')
     addCard = form.Form(
         form.Textbox('card_num',
                      description='Card ID',
                      class_='form-control'),
         form.Textbox('card_name',
                      description='Name',
                      class_='form-control'),
         form.Textbox('unit', description='Unit', class_='form-control'),
         form.Dropdown('type', [('S', 'Student'), ('T', 'Teacher')],
                       description='Identity',
                       class_='form-control'),
         form.Hidden("optype", value="add"),
         # form.Button('Create', class_ = "btn btn-primary")
     )
     removeCard = form.Form(
         form.Textbox('card_num',
                      description="Card ID",
                      class_='form-control'),
         form.Hidden("optype", value="remove"),
         # form.Button("Submit", class_ = "btn btn-primary"),
     )
     return render.managecard(addCard, removeCard, web.ctx.session)
Beispiel #2
0
 def GET(self):
     if web.ctx.session.login != 1:
         raise web.seeother('/#login')
     addbook = form.Form(
         form.Textbox('book_num', description = "Book Number", class_ = 'form-control'),
         form.Textbox('type', description = 'Book type', class_ = 'form-control'),
         form.Textbox('title', description = 'Book name', class_ = 'form-control'),
         form.Textbox('press', description = 'Press', class_ = 'form-control'),
         form.Textbox('year', description = 'Year', class_ = 'form-control'),
         form.Textbox('author', description = 'Author', class_ = 'form-control'),
         form.Textbox('price', description = 'Price', class_ = 'form-control'),
         form.Textbox('amount', description = 'Amount', class_ = 'form-control'),
         form.Hidden('optype', value = 'addbook'),
         # form.Button("Submit", class_ = "btn btn-primary"),
         )
     appendbook = form.Form(
         form.Textbox('book_num', description = 'Book Number', class_ = 'form-control'),
         form.Textbox('quantity', description = 'Quantity', class_ = 'form-control'),
         form.Hidden('optype', value = 'appendbook'),
         )
     addbooklist = form.Form(
         form.File(name = "Upload"),
         # form.Button("Submit", class_ = "btn btn-primary"),
         )
     return render.addbook(addbook, appendbook, addbooklist,web.ctx.session)
	def GET(self):
		user_data = web.input(token="")
		token = user_data.token

		myform = form.Form(
			form.Password("password",
				form.notnull,
				description = "New Password"),
			form.Hidden("token", 
				form.notnull, 
				value=token, 
				description="Reset Token"),
			form.Button("Reset Password",
			description="Register"))
		msg = ""
		err = ""

		if token not in token_dic:
			err = "Invalid token."
			return render.generic(self.nullform(), msg, err)

		if token_dic[token].timeout <= datetime.datetime.now():
			err = "Token expired."
			return render.generic(self.nullform(), msg, err)

		msg = "Reset Password for: " + token_dic[token].user
		return render.generic(myform, msg, err)
Beispiel #4
0
    def getDynamicForm(self):
        dynamic_form = DynamicForm(form.Hidden('placeholder'))

        #for setting, dict in settings.settings.iteritems():
        for setting, dict in sorted(settings.settings.iteritems(),
                                    key=lambda (x, y): y['formOrder']):
            if dict["formNullable"] == 'notnull':
                nullArg = "form.notnull"
            else:
                nullArg = ()
            if dict["formType"] == 'textbox':
                dynamic_form.add_input(
                    form.Textbox(
                        dict["key"],
                        description=dict[
                            "description"],  #, form.regexp(dict["formRegexp"], dict["formRegexpMessage"])
                        value=dict["value"]))  # , *nullArg
            elif dict["formType"] == 'radio':
                dynamic_form.add_input(
                    form.Radio(dict["key"],
                               args=dict["formDropdownValues"],
                               description=dict["description"],
                               value=dict["value"]))
            elif dict["formType"] == 'dropdown':
                dynamic_form.add_input(
                    form.Dropdown(dict["key"],
                                  args=dict["formDropdownValues"],
                                  description=dict["description"],
                                  value=dict["value"]))

        return dynamic_form
Beispiel #5
0
def ArticleUpdateForm(article, categoryDict):
    """ 文章更新表单"""
    updateForm = form.Form(
        form.Hidden("article_id", value=article.key().id()),
        form.Textbox("article_title",
                     Validation['notnull'],
                     description=u"标题:",
                     value=article.title),
        form.Textarea("article_content",
                      Validation['notnull'],
                      description=u"内容:",
                      value=article.content),
        form.Dropdown("article_display",
                      args=[('1', '是'), ('0', '否')],
                      description=u"显示:",
                      value=article.display and "1" or "0"),
        form.Dropdown("article_commentEnable",
                      args=[('1', '是'), ('0', '否')],
                      description=u"允许评论:",
                      value=article.display and "1" or "0"),
        form.Dropdown("article_category",
                      args=categoryDict,
                      description=u"分类:",
                      value=article.category.key().id()),
        form.Button("article_submit", type="submit", html=u'提交'),
    )
    return updateForm
Beispiel #6
0
def get_apply_permissions_form(identifier=0, read_permission="TRUE", write_permission="FALSE",
                               modify_permission="FALSE", userid=None):
    """
    Get the form used to set permissions for each applicant
            :param identifier: The id of this element
            :param user_name: The current user
            :param read_permission: Permit user to read
            :param write_permission: Permit user to write
            :param modify_permission: Permit user to modify
            :type identifier: int
            :type user_name: str
            :type read_permission: bool
            :type write_permission: bool
            :type modify_permission: bool
            :return: A form object
    """
    user_permissions = form.Form(
        form.Button("remove_user", type="submit", description="User to remove", value=userid, html="X"),
        form.Hidden("user_" + str(identifier), description="User to apply for project", value=userid),
        form.Checkbox("read_permission_" + str(identifier), description="Read Permission",
                      checked=(read_permission == "TRUE"), value=True),
        form.Checkbox("write_permission_" + str(identifier), description="Write Permission",
                      checked=(write_permission == "TRUE"), value=True),
        form.Checkbox("modify_permission_" + str(identifier), description="Modify Permission",
                      checked=(modify_permission == "TRUE"), value=True)
    )
    return user_permissions
Beispiel #7
0
def CategoryUpdateForm(category):
    """分类更新表单"""
    updateForm = form.Form(
        form.Hidden("category_id", value=category.key().id()),
        form.Textbox("category_name", description="分类名称:",
                     value=category.name),
        form.Button("submit", type="submit", html=u'提交'),
    )
    return updateForm
Beispiel #8
0
 def alter_article_form(self):
     return form.Form(
         form.Textbox('name',form.notnull,description='Name:',class_="form-control"),
         form.Textbox('title',form.notnull,description='Title:',class_="form-control"),
         form.Textbox('parent',form.notnull,description='parent:',class_="form-control"),
         form.Textbox('has_child_p',form.notnull,description='has_child_p:',class_="form-control"),
         form.Textarea('content',description="Content:",class_="form-control",rows="10"),
         form.Button('submit',type='submit',class_="btn btn-primary"),
         form.Hidden('aid')
     )
Beispiel #9
0
class reset:
    myform = form.Form(
        form.Password("password", form.notnull, description="New Password"),
        form.Hidden("token", form.notnull, value="",
                    description="Reset Token"),
        form.Button("Reset Password", description="Register"))

    nullform = form.Form()

    def GET(self):
        user_data = web.input(token="")
        token = user_data.token

        myform = form.Form(
            form.Password("password", form.notnull,
                          description="New Password"),
            form.Hidden("token",
                        form.notnull,
                        value=token,
                        description="Reset Token"),
            form.Button("Reset Password", description="Register"))
        msg = ""
        err = ""

        if token not in token_dic:
            err = "Invalid token."
            return render.generic(self.nullform(), msg, err)

        if token_dic[token].timeout <= datetime.datetime.now():
            err = "Token expired."
            return render.generic(self.nullform(), msg, err)

        msg = "Reset Password for: " + token_dic[token].user
        return render.generic(myform, msg, err)

    def POST(self):
        form = self.myform()
        msg = ""
        err = ""

        if not form.validates():
            err = "Invalid form data."
            return render.generic(self.nullform, msg, err)

        #Make sure it's a valid token, and remove it once used
        if form.d.token in token_dic and token_dic[
                form.d.token].timeout > datetime.datetime.now():
            msg = "Password reset for user: "******"Invalid token."

        return render.generic(self.nullform, msg, err)
Beispiel #10
0
def CommentNewForm(articleID):
    """评论新建表单"""
    newForm = form.Form(
        form.Hidden("comment_article_id",
                    description="article ID:",
                    value=articleID),
        form.Textbox("comment_nickname", description="昵称:"),
        form.Textbox("comment_email", description="邮箱:"),
        form.Textbox("comment_website", description="邮箱:"),
        form.Textarea("comment_content", description="内容:"),
        form.Button("comment_submit", type="submit", html=u'提交'),
    )
    return newForm
Beispiel #11
0
def NavigationUpdateForm(navigation):
    """ 导航更新表单 """
    updateForm = form.Form(
        form.Hidden("navigation_id", value=navigation.key().id()),
        form.Textbox("navigation_name",
                     description=u"名称:",
                     value=navigation.name),
        form.Textbox("navigation_link",
                     description=u"链接:",
                     value=navigation.link),
        form.Textbox("navigation_weight",
                     description=u"优先级",
                     value=navigation.weight),
        form.Button("navigation_submit", type="submit", html=u'提交更新'),
    )
    return updateForm
Beispiel #12
0
def AlonePageUpdateForm(alonePage):
    """ 页面更新表单"""
    updateForm = form.Form(
        form.Hidden("page_id", value=alonePage.id),
        form.Textbox("page_title", description="标题:", value=alonePage.title),
        form.Textbox("page_link", description="链接:", value=alonePage.link),
        form.Textarea("page_content",
                      description="内容:",
                      value=alonePage.content),
        form.Dropdown("page_display",
                      args=[('1', '是'), ('0', '否')],
                      description="显示:",
                      value=alonePage.display and "1" or "0"),
        form.Dropdown("page_commentEnable",
                      args=[('1', '是'), ('0', '否')],
                      description="允许评论:",
                      value=alonePage.commentEnable and "1" or "0"),
        form.Button("page_submit", type="submit", html=u'提交'),
    )
    return updateForm
class contact:
    contact_form = form.Form(
        form.Hidden("Contact_Id", description="contact_id"),
        form.Textbox("Name", form.notnull, description="name"),
        form.Textbox("Telephone1", description="telephone1"),
        form.Textbox("Telephone2", description="telephone2"),
        form.Textbox("Location", description="location"),
        form.Textbox("Industry", description="industry"))

    def GET(self):
        f = contact.contact_form()
        if globals.has_loggedin():
            # render contact data
            data = model.get_all_contact()
            return render.contact(f, data)
        else:
            raise web.seeother("/", True)

    def POST(self):
        '''
		Add a new contact
		'''

        if not globals.has_loggedin():
            raise web.seeother("/contact/", True)

        f = contact.contact_form()
        if not f.validates():
            raise web.seeother('/contact/', True)

        data = contact_data(f['Contact_Id'].value, f['Name'].value,
                            f['Telephone1'].value, f['Telephone2'].value,
                            f['Location'].value, f['Industry'].value)

        # if this contact has been in db, del/new as update it
        #if model.get_contact(data.id) is not None:
        #	model.del_contact(data.id)

        model.new_contact(data)
        web.seeother("/contact/", True)
dic_requestable = {}
for requestable in requestables:
    dic_requestable.update({requestable.rqbl_name.value: requestable})


# Web page inputs
first_form = form.Form(
    form.Dropdown("OrderType", dic_order_type, description="Order Type"),
    form.Dropdown("NewContentType", dic_content_type, description="New Content Type"),
    form.Dropdown("LocationNewContent", dic_location, description="Location of New Content"),
    form.Button("submit", type="submit", description="Continue to second stage"),
)

second_form = form.Form(
    form.Hidden("OrderType"),
    form.Hidden("NewContentType"),
    form.Hidden("LocationNewContent"),
    form.Dropdown("Requestable", dic_requestable, description="Requestable"),
    form.Button("submit", type="submit", description="Create order"),
)

urls = (
    '/', 'CreateOrder',
    '/CreateOrderFirst', 'CreateOrderFirst',
    '/CreateOrderSecond', 'CreateOrderSecond',
)


class CreateOrder:
Beispiel #15
0
                          validators=[
                              form.Validator(
                                  "密码确认不符",
                                  lambda i: i.opr_passwd == i.opr_passwd2)
                          ])

node_update_form = form.Form(
    form.Textbox("node_id",
                 description="节点编号:(由定长6位数字或字母组成)",
                 readonly="readonly",
                 **input_style),
    form.Textbox("node_name",
                 len_of(1, 32),
                 description="节点名称:(1-32个汉字以内)",
                 **input_style),
    form.Hidden("opr_id", description="管理员名称:(6-32位不定长数字或字母组成)"),
    form.Textbox("opr_name",
                 is_alphanum2(6, 32),
                 description="管理员名称:(6-32位不定长数字或字母组成)",
                 **input_style),
    form.Textbox("opr_ip", description="管理员工作IP:(如192.168.1.1)",
                 **input_style),
    form.Password("opr_passwd",
                  is_alphanum2(6, 20),
                  description="管理员密码:(密码由6-20个字符组成)",
                  **input_style),
    form.Textarea("node_desc",
                  len_of(0, 254),
                  description="节点描述:(127个汉字以内)",
                  rows="5",
                  **input_style),
Beispiel #16
0
                 description='Validity period'),
    form.Textbox('commonname',
                 form.notnull,
                 type='text',
                 class_='form-control input-sm',
                 description='Common Name'),
    form.Textbox('email',
                 form.notnull,
                 class_='form-control input-sm',
                 description='E-mail'),
    form.Password('password',
                  form.notnull,
                  class_='form-control input-sm',
                  description='Password'),
    form.Hidden('certtype',
                type='readonly',
                class_='form-control input-sm',
                value='Client'),
    form.Hidden('mode',
                type='readonly',
                class_='form-control input-sm',
                value='manual')
)

servercert_form = BootstrapFormTable(
    form.Dropdown('selected_ca',
                  [('value1', 'description1'), ('value2', 'description2')],
                  class_='form-control input-sm',
                  description='Select CA'),
    form.Textbox('validity',
                 form.notnull,
                 form.regexp('([\d+])', 'Please provide a valid duration'),
Beispiel #17
0
import web
from web import form
import application.models.model_cliente

render = web.template.render('application/views/clientes/', base='master')
model = application.models.model_cliente

vemail = form.regexp(r".*@.*", "Must be a valid email address")
'''
Here we define the form fields for use in all the views
'''
form_cliente = form.Form(
    form.Hidden('id_cliente',
                description="",
                value="0",
                class_="form-control",
                required=True),
    form.Textbox('nombre',
                 description="nombre",
                 class_="form-control",
                 required=True),
    form.Textbox('apellido_paterno',
                 description="apellido_paterno",
                 class_="form-control",
                 required=True),
    form.Textbox('apellido_materno',
                 description="apellido_materno",
                 class_="form-control",
                 required=True),
    form.Textbox('telefono',
                 description="telefono",
Beispiel #18
0
    "opposingLanes",
    "overtakingLane",
    "rightHandTurningLane",
    "rightLane",
    "rushHourLane",
    "setDownArea",
    "slowVehicleLane",
    "throughTrafficLane",
    "tidalFlowLane",
    "turningLane",
    "verge",
)

# XXX: Needs to have both side & direction...?
MST_ADMIN_STATION_FORM = form.Form(
    form.Hidden('station'),
    form.Dropdown('measurementside', [DATEX2_DIRECTIONS]),
    form.Button('Submit'),
)


class AdminMstStations:
    """Allows configuration of station specific Datex2 MST parameters."""
    def GET(self):
        check_admin_password(*get_httpauth())
        i = web.input(station=None)
        vmdb_id = i.station
        if vmdb_id:
            stations = db.query("""SELECT * FROM exportws.stations as st
                                   JOIN icecast.station as s
                                     ON s.vmdb_id=st.vmdb_id
Beispiel #19
0
	def create_delete_form(cls, key): 
		return form.Form(
			form.Hidden('key', value=key),
			form.Button('submit', type_='submit'),
			form.Button('cancel', type_='cancel')
			)
Beispiel #20
0
def create_form(entity):
	#todo: proper validation for tags
	if entity.__class__.__name__ == 'Entry':
		q = Category.query().order(Category.name)
		categories = q.fetch(10)
		
		try:
			tags = reduce(lambda x,y: x + ' ' + y, entity.tags)
		except:
			tags = ''

		createform = form.Form(
			form.Checkbox(
							'published',
							value=entity.published if entity.published else False, 
							checked=entity.published
						),
			form.Textbox(
							'title',
							form.notnull,
							value=entity.title
						),
			form.Dropdown(
							'category', 
							map(lambda x: (x.key.urlsafe(), x.name), categories)
						), 
			form.Hidden(
							'content', 
							form.notnull,
							value=entity.content,
						),
			form.Hidden(
							'intro',
							value=entity.intro
						),
			form.Div(
						'content',
						value=entity.content,
						id='epiceditor'
					),
			form.Textbox(
							'tags', 
							form.regexp(
								r'^$|[a-zA-Z- ]', 
								'Invalid tag(s) entered.'
							),
							value=tags
						),
			form.Button(
							'submit', 
							type_='submit', 
							class_='btn btn-primary btn-large'
						)
			)

	elif entity.__class__.__name__ == 'Category':
		createform = form.Form(
			form.Textbox(
							'name', 
							form.notnull,
							form.regexp(
									r'[a-zA-Z ]', 
									'Invalid chars entered.'
							),
							value=entity.name
						),
			form.Textbox(
							'desc', 
							form.notnull,
							value=entity.desc
						),
			form.Button(
							'submit', 
							type_='submit', 
							class_='btn btn-primary btn-large'
						)
			)

	return createform
Beispiel #21
0
    and a followup interview
    '''
    routine_textbox_names = ['General Mental Ability', 'Academic History'
                             , 'Family Relationship'
                             , 'Personal/Emotional', 'Peer Relationship'
                             , 'Goals/Motivation', 'Recommendation']
    routine_form = form.Form(*[form.Textarea(name,form.notnull, rows=15,cols=75) for name in routine_textbox_names])

    followup_textbox_names = ['Comments', 'Planned Intervention']
    followup_form = lambda self, nature_of_problems: form.Form(form.Dropdown('Nature of problem', args=[(nature.id, nature.name) for nature in nature_of_problems],value=1)
                                                               ,*[form.Textarea(name,form.notnull, rows=15, cols=75) for name in self.followup_textbox_names])

    other_textbox_names = ['Content']
    other_form = form.Form(*[form.Textarea(name=name, rows=15,cols=75) for name in other_textbox_names])

    hidden_forms = lambda self, period, student, type: form.Form(*[form.Hidden(name='period_id', value=period.id)
                                                                   , form.Hidden(name='student_id', value=student.id)
                                                                   , form.Hidden(name='interview_type', value=type.id)])

    button_names = ['save as draft', 'submit']
    button_form = form.Form(*[form.Button(button_name,form.notnull) for button_name in button_names])

    def GET(self):
        if session.user is None:
            web.seeother('/')
        elif session.user.position.title in ['Counselor', 'Head Counselor']:
            data = web.input()
            try:
                num = int(data['num'])
                date = iso_to_date(data['date'])
                student_id = int(data['student'])
Beispiel #22
0
def buildform(key, config):
    if not key in config['forms']: raise Exception("Form not found")
    inputs = []
    for i in config['forms'][key]:
        if not 'name' in i: raise Exception("Needs a name")
        if not 'type' in i: raise Exception("Needs a type")
        k = i['name']
        if i['type'] == "text":
            opts = {}
            opts['description'] = _(k)
            opts['post'] = helplink(i.get('help'))
            if 'disabled' in i or 'readonly' in i:
                opts['readonly'] = True
            if 'url' in i:
                opts['data-url'] = i['url']
            if 'pick' in i:
                opts['data-pick'] = i['pick'] = json.dumps(i['pick'])  # ???
            inputs.append(form.Textbox(k, **opts))
        elif i['type'] == "hidden":
            inputs.append(form.Hidden(k, description=_(k)))
        elif i['type'] == "checkbox":
            inputs.append(
                form.Checkbox(k,
                              value="y",
                              description=_(k),
                              post=helplink(i.get('help'))))
        elif i['type'] == 'select':
            default = i.get('default', '')
            if 'options' in i:
                options = [''] + i['options']
                inputs.append(form.Dropdown(k, options, description=_(k)))
            elif 'sql' in i:
                db = web.database(dbn='sqlite',
                                  db=config['source']['database'])
                data = web.input()
                if 'match' in i:
                    wheres = []
                    for m in i['match']:
                        if data.get(m):
                            wheres.append("WHERE %s = %s" %
                                          (m, web.sqlquote(data[m])))
                    query = i['sql'] % (" AND ".join(wheres))
                else:
                    query = i['sql'] % ""
                results = [v.values()[0] for v in db.query(query)]
                results = filter(None, results)
                results = [(v, _(v)) for v in results]
                results.insert(0, default)
                inputs.append(form.Dropdown(k, results, description=_(k)))
            elif 'source' in i:
                key = i['source'] + "-" + i['name']
                source = json.loads(web.ctx.metadata.get(key))
                options = [''] + [d['label'] for d in sorted(source)]
                inputs.append(form.Dropdown(k, options, description=_(k)))
        elif i['type'] == 'textfield':
            inputs.append(
                form.Textarea(k,
                              description=_(k),
                              post=helplink(i.get('help'))))
        elif i['type'] == 'date':
            inputs.append(
                form.Textbox("year",
                             description=_('year'),
                             post=helplink('help-year')))
            inputs.append(
                form.Textbox("month",
                             description=_('month'),
                             post=helplink('help-month')))
            inputs.append(
                form.Textbox("day",
                             description=_('day'),
                             post=helplink('help-day')))
        elif i['type'] == 'location':
            inputs.append(
                form.Textbox("county", description=_('county'), readonly=True))
            inputs.append(
                form.Textarea("locality",
                              description=_('locality'),
                              readonly=True))
            inputs.append(
                form.Textbox("verbatimCoordinates",
                             description=_('verbatimCoordinates'),
                             readonly=True))
            inputs.append(
                form.Hidden("verbatimWKT",
                            description=_('verbatimWKT'),
                            readonly=True))
            inputs.append(
                form.Hidden("verbatimLatitude",
                            description=_('verbatimLatitude'),
                            readonly=True))
            inputs.append(
                form.Hidden("verbatimUncertaintyInMeters",
                            description=_('verbatimUncertaintyInMeters'),
                            readonly=True))
            inputs.append(
                form.Hidden("verbatimLongitude",
                            description=_('verbatimLongitude'),
                            readonly=True))
        elif i['type'] == "annotation":
            inputs.append(form.Hidden(k))
            inputs.append(
                form.Textbox(_('marked-pages'),
                             readonly=True,
                             id="marked-pages"))
            inputs.append(form.Button(_("mark-page"), id="mark-page"))
        else:
            raise Exception("Unknown type %s" % i['type'])
    return form.Form(*inputs)
Beispiel #23
0
        filtered = filter(lambda i: 'DEV' not in i.attrs or config.DEV, inputs)
        super(DevelopmentForm, self).__init__(*filtered, **kw)


validaccounts = form.Validator(
    "There should be - at least - one external account linked!",
    lambda i: any(v for v in i.itervalues()))
validcurrency = form.Validator('€, $ ..', parsers.currency)
validformat = form.Validator('tsv, csv ..', parsers.format)
validamount = form.Validator('Invalid (e.g. 1.00)', parsers.amount)
validdate = form.Validator('Invalid (e.g. 1/22/2013)', parsers.date_us)
validimportdata = form.Validator('Invalid format', parsers.expenses)
validcolor = form.Validator('Invalid color (e.g. #1234ab)', parsers.color)

users_avatar = form.Form(
    form.Hidden('id'),
    ImageBootstrap2('avatar',
                    form.notnull,
                    width=config.AVATAR_WIDTH,
                    height=config.AVATAR_HEIGHT,
                    src=config.AVATAR_PLACEHOLD,
                    description='Avatar'),
)

users_edit = form.Form(
    form.Hidden('id'),
    form.Textbox('name',
                 form.notnull,
                 description='Name',
                 placeholder="John Smith"),
    form.Dropdown('currency',
Beispiel #24
0
    form.Textbox("company", description="Company"),
    form.Textbox("email", vemail, description="Email Address"),
    form.Textbox("street_address", description="Street address"),
    form.Textbox("city", description="City"),
    form.Textbox("state", description="State"),
    form.Textbox("postal_code", number, description="Postal code"),
    form.Textbox("country", description="Country"),
    form.Password("password", vpass, description="Password"),
    form.Button("Register", type="submit", description="Register")
)


# Define the project view form
project_form = form.Form(
    form.Input("myfile", type="file"),
    form.Hidden("taskid"),
    form.Button("submit", type="submit", html="Upload"),
    form.Button("deliver", type="submit", value=True, html="Deliver"),
    form.Button("accepted", type="submit", value=True, html="Accept Delivery"),
    form.Button("declined", type="submit", value=True, html="Decline Delivery")
)


def get_task_form_elements(identifier=0, task_title="", task_description="", budget=""):
    """
    Generate a set of task form elements
        :param identifier: The id of the task
        :param task_title: Task title
        :param task_description: Task description 
        :param budget: Task budget
        :type identifier: int, str
Beispiel #25
0
from string import translate, maketrans, punctuation
import web
from web import form
import config
import dbus
from util import get_properties, get_raw_value, get_value, get_str_value, \
    get_dict_value, get_service, get_security

vssid = form.regexp(r".{1,32}$", "Must be between 1 and 32 characters")
vprefix = form.Validator('Must be between 0 and 128',
                         lambda x: x == "" or int(x) >= 0 and int(x) <= 128)
vallowempty = form.Validator('', lambda x: x == "")
vpin = form.regexp(r".{4,8}$", "Must be between 4 and 8 characters")

form = web.form.Form(
    form.Hidden('servicetype'),
    form.Radio('autoconnect', args=["Yes", "No"], description="Autoconnect"),
    form.Textbox("domains", class_="textEntry", size=64,
                 description="Domains"),
    form.Textbox("timeservers",
                 class_="textEntry",
                 size=64,
                 description="Timeservers"),
    form.Textbox("nameservers",
                 class_="textEntry",
                 size=64,
                 description="Nameservers"),
    form.Dropdown("ipv4method", [('fixed', 'Fixed'), ('dhcp', 'DHCP'),
                                 ('manual', 'Manual'), ('off', 'Off')],
                  onChange="show_hide_ipv4_fields(this);",
                  description="IPv4 configuration"),
Beispiel #26
0
                                 'get_ad': ad.get_ad,
                             })


def temp_validator(temp):
    if not isinstance(temp, str) or len(temp) > 5:
        return False
    try:
        val = float(temp)
        return 35.0 <= val <= 42.0
    except ValueError:
        return False


MorningForm = form.Form(
    form.Hidden('date', value=''),
    form.Textbox('学号', id='sid', maxlength=16, value=''),
    form.Textbox('姓名', id='name', maxlength=8, value=''),
    form.Textbox('体温', id='temp', value=''),
    form.Checkbox('确认已在APP打卡', id='appchecked', value='t', checked=True),
)

NoonForm = form.Form(
    form.Hidden('date', value=''),
    form.Textbox('学号', id='sid', maxlength=16, value=''),
    form.Textbox('姓名', id='name', maxlength=8, value=''),
    form.Textbox('体温', id='temp', value=''),
)

EveningForm = form.Form(
    form.Hidden('date', value=''),
Beispiel #27
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import dbus
import web
from web import form
from subprocess import Popen, PIPE, STDOUT
from time import sleep
import eca
from util import get_service

vpassphrase = form.regexp(r".{8,64}$", "Must be between 8 and 64 characters")
psk_form = web.form.Form(form.Hidden('servicetype'),
                         form.Password("passphrase",
                                       autocomplete="off",
                                       description="Passphrase"),
                         form.Password("passphrase2",
                                       autocomplete="off",
                                       description="Repeat passphrase"),
                         form.Button("Submit", type="submit", value="new_psk"),
                         validators=[
                             form.Validator(
                                 "Passphrase do not match",
                                 lambda i: i.passphrase == i.passphrase2)
                         ])

wep_form = web.form.Form(form.Hidden('servicetype'),
                         form.Password("passphrase",
Beispiel #28
0
                 description="Title:",
                 size='80'),
    form.Textbox('pid',
                 form.Validator("Address can't be blank", bool),
                 form.Validator('ID already exists, Choose a different one.',
                                petitionnotexists),
                 pre='http://watchdog.net/c/',
                 description='URL:',
                 size='30'),
    form.Textarea('msg',
                  form.Validator("Description can't be blank", bool),
                  description="Description:",
                  rows='15',
                  cols='80'),
    form.Checkbox('tocongress', value='', description="Petition to Congress?"),
    form.Hidden('userid'))

wyrform = form.Form(
    form.Dropdown('prefix', ['Mr.', 'Mrs.', 'Dr.', 'Ms.', 'Miss'],
                  description='Prefix'),
    form.Textbox('lname',
                 form.Validator("Last name can't be blank", bool),
                 size='16',
                 description='Last Name'),
    form.Textbox('fname',
                 form.Validator("First name can't be blank", bool),
                 size='16',
                 description='First Name'),
    form.Textbox('email',
                 form.notnull,
                 form.regexp(email_regex, 'Please enter a valid email'),
Beispiel #29
0
                            ('OK', 'Oklahoma'), ('OR', 'Oregon'),
                            ('PA', 'Pennsylvania'), ('RI', 'Rhode Island'),
                            ('SC', 'South Carolina'), ('SD', 'South Dakota'),
                            ('TN', 'Tennessee'), ('TX', 'Texas'),
                            ('UT', 'Utah'), ('VT', 'Vermont'),
                            ('VA', 'Virginia'), ('WA', 'Washington'),
                            ('WV', 'West Virginia'), ('WI', 'Wisconsin'),
                            ('WY', 'Wyoming')],
                  description="State"),
    form.Textbox("country", form.notnull, value="US", description="Country"),
    form.Textbox("zip",
                 form.notnull,
                 form.regexp('\d+', 'Must be a digit'),
                 form.Validator('Must be more than 5', lambda x: int(x) > 5),
                 description="Zip Code"),
    form.Hidden(name='approved', value='0'),
    form.Button('Add User'),
    validators=[
        form.Validator("Passwords did't match",
                       lambda i: i.password == i.password2)
    ])


class index:
    def GET(self):
        form = addform()
        users = model.get_users()
        return render.index(users, form)

    def POST(self):
        form = addform()