Example #1
0
class CreateExecutive(FlaskForm):
    username = StringField("username", [
        validators.DataRequired(message="Username is Required"),
        validators.Length(message='UserName should be Minimun 4 characters.',
                          min=4)
    ])
    name = StringField("name",
                       [validators.DataRequired(message="name  is Required")])
    address = StringField(
        "address", [validators.DataRequired(message="address  is Required")])
    phone = StringField(
        "phone",
        [validators.DataRequired(message="Mobile Number  is Required")])
    password = PasswordField("password", [
        validators.DataRequired(message="Password is Required"),
        validators.Length(message='Password should be and 5 characters.',
                          min=5),
        validators.Regexp(
            message=
            ' Password should contain 5 characters including one special character, one upper case, one numeric.',
            regex=r'^(?=.*[A-Z])(?=.*\d)(?=.*[\W\_])[A-Za-z\d\W\_]{5,}$')
    ])
    userlevel = IntegerField(
        "userlevel",
        [validators.DataRequired(message="Userlevel is Required")])
Example #2
0
class RasTargetAppForm(RasTargetForm):

    application = StringField(
        label=u'アプリケーション名',
        validators=[validators.DataRequired()],
    )
    name = StringField(
        label=u'監視名',
        validators=[validators.DataRequired()],
    )
    comment = TextAreaField(
        label=u'コメント',
        default=u'',
    )

    def _get_type(self):
        return 'app'

    def create(self, grpid):
        tgt = RasTarget()
        tgt.name = self.name.data
        tgt.group = grpid
        tgt.type = 'app'
        tgt.path = '{app}/{name}'.format(app=self.application.data,
                                         name=self.name.data)
        tgt.comment = self.comment.data
        tgt.save()
Example #3
0
class MaintenanceForm(FlaskForm):
    name = StringField('Name', validators=[validators.DataRequired()])
    description = StringField('Description')
    asset = SelectField('Asset')
    schedule_multiplier = StringField('Schedule count')
    schedule = SelectField('Schedule')
    enabled = BooleanField('Enabled')
    submit = SubmitField()
class RegistrationForm(FlaskForm):
    username = StringField('Username',
                           validators=[DataRequired(), Length(min=2, max=20)])
    email = StringField('Email',
                        validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired()])
    confirm_password = PasswordField('Confirm Password',
                                     validators=[DataRequired(), EqualTo('password')])
    submit = SubmitField('Sign Up')
Example #5
0
class ZoneRecordForm(Form):
    zone_id = HiddenField()
    host = StringField('Host', validators=[Required()])
    type = SelectField('Type', choices=[('A', 'A'), ('AAAA', 'AAAA'),
                                        ('CNAME', 'CNAME'), ('TXT', 'TXT'),
                                        ('NS', 'NS'), ('SOA', 'SOA'),
                                        ('MX', 'MX'), ('PTR', 'PTR'),
                                        ('SRV', 'SRV')],
                       validators=[Required()])
    data = StringField('Data', validators=[Required()])
    ttl = IntegerField('TTL', validators=[Required(), NumberRange(min=0)])
Example #6
0
class CreateHourlyForm(Form):
    bare_metal = HiddenField(default='1')
    location = SelectField('Data Center', default='FIRST_AVAILABLE')
    hostname = StringField('Hostname', validators=[Required()])
    domain = StringField('Domain', validators=[Required()])
    server = SelectField('Server', validators=[Required()])
    os = SelectField('Operating System', validators=[Required()])
    port_speed = SelectField('Network Speed', validators=[Required()])
    # TODO - This could be turned into a regular SelectField
    disks = FieldList(SelectField('Disks', validators=[Required()]),
                      min_entries=1,
                      max_entries=4)
Example #7
0
class ParsleyTestForm(Form):
    email = StringField(
        'E-Mail Address',
        [validators.Email('Sorrry, not a valid email address.')],
        default='*****@*****.**')
    first_value = StringField('Some Value', default='Some value')
    second_value = StringField('Should be identical', [
        validators.EqualTo(message='Sorry, values do not match.',
                           fieldname='first_value')
    ],
                               default='Some value')
    ip_address = StringField(
        'IP4 Address',
        [validators.IPAddress(message='Sorry, not a valid IP4 Address.')],
        default='127.0.0.1')
    string_length = StringField('Length of String (5 to 10)', [
        validators.Length(
            message='Length should be between 5 and 10 characters.',
            min=5,
            max=10)
    ],
                                default='Hello!')
    number_range = IntegerField('Number Range (5 to 10)', [
        validators.NumberRange(
            message='Range should be between 5 and 10.', min=5, max=10)
    ],
                                default=7)

    required_text = StringField(
        'Required Field',
        [validators.DataRequired(message='Sorry, this is a required field.')],
        default='Mandatory text')
    required_select = SelectField(
        'Required Select',
        [validators.DataRequired(message='Sorry, you have to make a choice.')],
        choices=[('', 'Please select an option'), ('cpp', 'C++'),
                 ('py', 'Python'), ('text', 'Plain Text')],
        default='py')
    required_checkbox = BooleanField(
        'Required Checkbox',
        [validators.DataRequired(message='Sorry, you need to accept this.')],
        default=True)
    regexp = StringField('Regex-Matched Hex Color-Code', [
        validators.Regexp(message='Not a proper color code, sorry.',
                          regex=r'^#[A-Fa-f0-9]{6}$')
    ],
                         default='#7D384F')
    url = StringField(
        'URL Field',
        [validators.URL(message='Sorry, this is not a valid URL,')],
        default='http://example.com/parsley')
    anyof = StringField('Car, Bike or Plane?', [
        validators.AnyOf(
            message='Sorry, you can only choose from car, bike and plane',
            values=['car', 'bike', 'plane'])
    ],
                        default='car')
Example #8
0
class CashTransfer(FlaskForm):
    CustomerID = IntegerField(
        "CustomerID",
        [validators.DataRequired(message="CustomerID  is Required")])
    SourceAccountType = StringField(
        "SourceAccountType",
        [validators.DataRequired(message="SourceAccountType is Required")])
    TargetAccountType = StringField(
        "TargetAccountType",
        [validators.DataRequired(message="TargetAccountType is Required")])
    TransferAmount = FloatField(
        "TransferAmount",
        [validators.DataRequired(message="TransferAmount is Required")])
Example #9
0
class RasActionMailForm(RasActionBaseForm):

    to = StringField(
        label=u'宛先(To)',
        validators=[validators.DataRequired(),
                    validators.Email()],
    )
    title = StringField(
        label=u'件名',
        validators=[validators.DataRequired()],
    )
    message = TextAreaField(label=u'本文', default='{default}')
    attach = BooleanField(label=u'データファイル添付', )

    def _get_type(self):
        return 'smtp'
Example #10
0
class RasActionSyslogForm(RasActionBaseForm):

    PROTOCOL = ['udp', 'tcp', 'unix']
    FACILITY = SyslogConf.FACILITY
    PRIORITY = SyslogConf.PRIORITY

    address = StringField(label=u'アドレス(:ポート)',
                          validators=[validators.DataRequired()])
    protocol = SelectField(
        label=u'プロトコル',
        choices=[(i, i) for i in PROTOCOL],
    )
    facility = SelectField(
        label=u'ファシリティ',
        choices=[(i, i) for i in FACILITY],
        default='user',
    )
    priority = SelectField(
        label=u'プライオリティ',
        choices=[(i, i) for i in PRIORITY],
        default='info',
    )
    message = TextAreaField(
        label=u'メッセージ',
        default='{default}',
    )

    def _get_type(self):
        return 'syslog'
Example #11
0
class RasActionScriptForm(RasActionBaseForm):

    cmdline = TextAreaField(
        label=u'コマンドライン',
        validators=[validators.DataRequired()],
    )

    workdir = StringField(
        label=u'作業ディレクトリ',
        validators=[validators.DataRequired()],
        default='{default}',
    )

    script = FileField(label=u'スクリプト', )

    def _get_type(self):
        return 'script'

    def _save(self, action, tgtid, script_data=None):
        with database.database.atomic():
            super(RasActionScriptForm, self)._save(action, tgtid, script_data)
            script = RasScript()
            logger.debug("SCRIPT: {}".format(script_data))
            if script_data is not None:
                script.script = script_data
            script.action = action
            script.save()
class AdminConfLogForm(AdminConfBaseForm):

    level = IntegerField(
        label=u'ログレベル',
        validators=[validators.DataRequired()],
        default=SyslogConf.DEFAULT['level'],
    )

    address = StringField(
        label=u'Syslogサーバ',
        validators=[validators.DataRequired()],
        default=SyslogConf.DEFAULT['address'],
    )

    facility = SelectField(
        label=u'ファシリティ',
        choices=[(i, i) for i in SyslogConf.FACILITY],
        default=SyslogConf.DEFAULT['facility'],
    )
    priority = SelectField(
        label=u'プライオリティ',
        choices=[(i, i) for i in SyslogConf.PRIORITY],
        default=SyslogConf.DEFAULT['priority'],
    )

    def conf_type(self):
        return SyslogConf.NAME
Example #13
0
class LoginForm(Form):
    email = StringField(u'Email', validators=[
        DataRequired(), Email()
    ])
    password = PasswordField(u'Password', validators=[
        DataRequired()
    ])
Example #14
0
class AdminConfSmtpForm(AdminConfBaseForm):

    server = StringField(
        label=u'SMTPサーバ',
        validators=[validators.DataRequired()],
        default=SmtpConf.DEFAULT['server'],
    )

    addr = StringField(
        label=u'送信者アドレス(From)',
        validators=[validators.DataRequired(),
                    validators.Email()],
        default=SmtpConf.DEFAULT['addr'],
    )

    def conf_type(self):
        return SmtpConf.NAME
Example #15
0
class CreateVMForm(Form):
    datacenter = SelectField('Data Center')
    hostname = StringField('Hostname', validators=[Required()])
    domain = StringField('Domain', validators=[Required()])
    os = SelectField('Operating System', validators=[Required()])
    cpus = SelectField('CPUs', validators=[Required()])
    memory = SelectField('Memory (GB)', validators=[Required()])
    network = RadioField(choices=[('10',
                                   '10Mbps'), ('100',
                                               '100Mbps'), ('1000',
                                                            '1000 Mbps')])
    tags = StringField('Tags',
                       validators=[
                           Regexp(
                               r'^[A-Za-z0-9_\.\-,\ ]*$',
                               message="Tags must be alphanumeric, _ . or -")
                       ])
Example #16
0
class NodeForm(BaseForm):
    hostname = StringField(
        label=u'ホスト名',
        validators=[validators.DataRequired()],
    )
    user = StringField(
        label=u'ユーザ',
        validators=[validators.DataRequired()],
        default='paxos',
    )
    password = PasswordField(label=u'パスワード', )
    port = IntegerField(
        label=u'sshポート番号',
        validators=[validators.NumberRange(
            min=0,
            max=65535,
        )],
        default=22,
    )
    paxos_home = StringField(
        label=u'PAXOS HOME',
        validators=[validators.DataRequired()],
        default='/home/paxos/PAXOS',
    )

    def create(self):
        node = Node()
        self.populate_obj(node)
        node.id = None
        try:
            node.check_and_save()
            node.deploy_async()
            return True
        except IntegrityError as e:
            logger.error(str(e))
            self.hostname.errors.append(e.message)

    def update(self, id):
        node = Node().get(Node.id == id)
        self.populate_obj(node)
        node.check_and_save()

    @classmethod
    def delete(cls, id):
        Node.delete().where(Node.id == id).execute()
Example #17
0
class UpdateCustomer(FlaskForm):
    name = StringField("Name", [
        validators.DataRequired(message="Name is Required"),
        validators.Regexp(message='Name should only alphabet',
                          regex=r'^[a-zA-Z ]*$'),
        validators.Length(
            message='Name should only alphabet and minimum 3 character',
            min=3,
            max=25)
    ])
    age = IntegerField("Age", [
        validators.DataRequired(message="Age is Required"),
        validators.NumberRange(message='Minimum age is 10', min=10, max=120)
    ])
    address = StringField(
        "Address", [validators.DataRequired(message="Address is Required")])
    message = StringField(
        "Message", [validators.DataRequired(message="Message is Required")])
Example #18
0
class RasActionForm(Form):

    _action_no = 0

    LABEL = collections.OrderedDict([
        ('smtp', u'メール通知'),
        ('syslog', u'Syslog通知'),
        ('http', u'WebAPI実行'),
        ('restart', u'自動起動'),
        ('script', u'スクリプト実行'),
    ])

    type = HiddenField(label=u'')
    name = StringField(
        label=u'アクション名',
        validators=[
            validators.DataRequired(),
            validators.Length(min=1, max=256),
            validators.Regexp('^\w+$')
        ],
    )

    def __init__(self,
                 formdata=None,
                 obj=None,
                 prefix='',
                 data=None,
                 meta=None,
                 **kwargs):
        super(RasActionForm, self).__init__(formdata, obj, prefix, data, meta,
                                            **kwargs)
        self.type.data = self._get_type()
        if not self.name.data:
            self.name.data = '{}{}'.format(self.type.data,
                                           RasActionForm._action_no)

    def get_labels(self, target):
        if target.type != 'app':
            return self.LABEL.items()
        else:
            labels = copy.copy(self.LABEL)
            del labels['restart']
            return labels.items()

    @classmethod
    def delete(cls, id):
        RasAction.delete().where(RasAction.id == id).execute()

    def update(self, actid, tgtid, script_data=None):
        action = RasAction()
        action.id = actid
        self._save(action, tgtid, script_data)

    def create(self, tgtid, script_data=None):
        action = RasAction()
        self._save(action, tgtid, script_data)
        RasActionForm._action_no += 1
Example #19
0
class SignUpForm(Form):
    email = StringField(u'Email', validators=[
        DataRequired(), Email()
    ])
    password = PasswordField(u'New Password', validators=[
        DataRequired(),
        EqualTo('confirm', message='Passwords must match')
    ])
    confirm = PasswordField(u'Confirm Password')
Example #20
0
class CreateAccount(FlaskForm):
    customerID = IntegerField(
        "CustomerID",
        [validators.DataRequired(message="CustomerID  is Required")])
    AccountType = StringField(
        "AccountType",
        [validators.DataRequired(message="AccountType is Required")])
    DepositAmount = FloatField(
        "DepositAmount",
        [validators.DataRequired(message="DepositAmount is Required")])
Example #21
0
class UserForm(FlaskForm):
    name = StringField('Name', validators=[validators.DataRequired()])
    email = StringField('Email', validators=[
        validators.DataRequired(),
        validators.Email(message="Not a valid email address")
        ])
    old_password = PasswordField('Current Password', validators=[validators.DataRequired()])
    password = PasswordField('Password', validators=[
        validators.DataRequired(),
        validators.Regexp(
            '^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z' + PASSWORD_CHARS + ']{' + PASSWORD_MINLEN + ',' + PASSWORD_MAXLEN + '}$',
            message='Allowed characters: [0-9, a-z, A-Z, {chars}] Password must contain at least one letter, at least one number, and be at least {minlen} charaters long.'.format(
                minlen=PASSWORD_MINLEN,
                chars=PASSWORD_CHARS
                ))
        ])
    password_repeat = PasswordField('Password again', validators=[
        validators.DataRequired(),
        validators.EqualTo('password', message='Passwords must match')
        ])
    submit = SubmitField()
Example #22
0
class CellNodeForm(BaseForm):
    node = SelectField(
        label=u'サーバ',
        coerce=int,
        choices=[],
    )
    udp_addr = StringField(
        label=u'ホストアドレス(UDP)',
        validators=[validators.DataRequired(),
                    validators.IPAddress()],
    )
    udp_port = IntegerField(
        label=u'UDPポート番号',
        validators=[
            validators.DataRequired(),
            validators.NumberRange(
                min=0,
                max=65535,
            )
        ],
        default=14000,
    )
    tcp_addr = StringField(
        label=u'ホストアドレス(TCP)',
        validators=[validators.DataRequired(),
                    validators.IPAddress()],
    )
    tcp_port = IntegerField(
        label=u'TCPポート番号',
        validators=[
            validators.DataRequired(),
            validators.NumberRange(
                min=0,
                max=65535,
            )
        ],
        default=14000,
    )
    node_id = HiddenField()
Example #23
0
class RasActionHttpForm(RasActionBaseForm):

    METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']

    method = SelectField(label=u'メソッド', choices=[(i, i) for i in METHODS])
    url = StringField(label=u'URL',
                      validators=[validators.DataRequired(),
                                  validators.URL()])
    params = TextAreaField(label=u'パラメータ', )
    header = TextAreaField(label=u'ヘッダ', )

    def _get_type(self):
        return 'http'
Example #24
0
class CreateMonthlyForm(Form):
    package_id = HiddenField(validators=[Required()])
    location = SelectField('Data Center', default='FIRST_AVAILABLE')
    hostname = StringField('Hostname', validators=[Required()])
    domain = StringField('Domain', validators=[Required()])
    server = SelectField('CPU', validators=[Required()])
    ram = SelectField('Memory', validators=[Required()])
    os = SelectField('Operating System', validators=[Required()])
    port_speed = SelectField('Network Speed', validators=[Required()])
    disks = FieldList(SelectField('Disks', validators=[Required()]),
                      min_entries=1)
    disk_controller = SelectField('Disk Controller', validators=[Required()])

    @classmethod
    def add_disk(cls, required=True):
        validators = []
        if required:
            validators.append(Required())

        new_field = SelectField('Disk', validators=validators)

        cls.disks.append_entry(new_field)
Example #25
0
class CreateCustomer(FlaskForm):
    ssnid = IntegerField("SSN ID", [
        validators.DataRequired(message="SSN ID is Required"),
        validators.NumberRange(
            message='SSN should be exactly 9', min=100000000, max=999999999)
    ])
    name = StringField("Name", [
        validators.DataRequired(message="Name is Required"),
        validators.Regexp(message='Name should only alphabet',
                          regex=r'^[a-zA-Z ]*$'),
        validators.Length(
            message='Name should only alphabet and minimum 3 character',
            min=3,
            max=25)
    ])
    age = IntegerField("Age", [
        validators.DataRequired(message="Age is Required"),
        validators.NumberRange(message='Minimum age is 10', min=10, max=120)
    ])
    address = StringField(
        "Address", [validators.DataRequired(message="Address is Required")])
    state = StringField()
    city = StringField()
Example #26
0
class RasActionRestartForm(RasActionForm):

    retry = StringField(
        label=u'再試行',
        default='5',
        validators=[validators.DataRequired(),
                    validators.NumberRange(min=0)],
    )
    interval = StringField(
        label=u'インターバル(秒)',
        default='60',
        validators=[validators.DataRequired(),
                    validators.NumberRange(min=0)],
    )

    def _get_type(self):
        return 'restart'

    def _save(self, action, tgtid, script_data=None):
        tgt = RasTarget.get(RasTarget.id == tgtid)
        action.target = tgtid
        action.name = self.name.data
        action.mode = 1 << 1
        action.type = 'restart'
        action.data = json.dumps({
            'type': tgt.type,
            'retry': int(self.retry.data),
            'interval': int(self.interval.data)
        })
        action.save()

    @classmethod
    def obj2dict(cls, obj):
        ret = json.loads(obj.data)
        ret['type'] = obj.type
        ret['name'] = obj.name
        return ret
Example #27
0
class LoginForm(FlaskForm):
    username = StringField("username", [
        validators.DataRequired(message="Username is Required"),
        validators.Length(message='UserName should be Minimun 4 characters.',
                          min=4)
    ])
    password = PasswordField("Password", [
        validators.DataRequired(message="Password is Required"),
        validators.Length(message='Password should be and 5 characters.',
                          min=5),
        validators.Regexp(
            message=
            ' Password should contain 5 characters including one special character, one upper case, one numeric.',
            regex=r'^(?=.*[A-Z])(?=.*\d)(?=.*[\W\_])[A-Za-z\d\W\_]*$'),
    ])
class LoginForm(FlaskForm):
    email = StringField('Email',
                        validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember = BooleanField('Remember Me')
    submit = SubmitField('Login')
Example #29
0
class LoginForm(Form):
    username = StringField('Username', validators=[Required()])
    password = PasswordField('Password', validators=[Required()])
    remember_me = BooleanField('Remember Me', default=False)
Example #30
0
class TwoFactorForm(Form):
    passcode = StringField('Passcode', validators=[Required()])