Exemple #1
0
class CameraForm(FlaskForm):
    name = fields.StringField("Camera Name")
    frame_rate = fields.FloatField(
        default=15, validators=[validators.NumberRange(min=1, max=175)])
    frame_size = fields.SelectField("Frame Size")
    # width = fields.FloatField()
    # height = fields.FloatField()
    latitude = fields.FloatField(
        "Latitude", validators=[validators.NumberRange(min=-180, max=180)])
    longitude = fields.FloatField(
        "Longitude", validators=[validators.NumberRange(min=-180, max=180)])

    uri = fields.StringField("URI")

    brand = fields.SelectField("Camera Brand")
    # model = fields.SelectField("Camera Model")
    ip_address = fields.StringField("Camera IP Address")
    username = fields.StringField("Username")
    password = fields.StringField("Password")
    channel = fields.IntegerField("Channel", default=0)

    storage_period = fields.IntegerField(
        "Storage Period (Days)",
        default=30,
        validators=[validators.NumberRange(min=0)])
    motion_detector = fields.BooleanField("Motion Detector", default=False)
    sensitivity = fields.FloatField(
        "Sensitivity",
        default=50,
        validators=[validators.NumberRange(min=0, max=100)])
Exemple #2
0
class HeliocentricEllipticalForm(FlaskForm):
    class Meta:
        csrf = False

    i = fields.FloatField('inclination (degrees)',
                          validators=[validators.input_required()])
    O = fields.FloatField('longitude of ascending node (degrees)',
                          validators=[validators.input_required()])
    o = fields.FloatField('argument of perihelion (degrees)',
                          validators=[validators.input_required()])
    a = fields.FloatField('mean distance (AU)',
                          validators=[validators.input_required()])
    n = fields.FloatField('mean daily motion (degrees/day)',
                          validators=[validators.input_required()])
    e = fields.FloatField('eccentricity',
                          validators=[validators.input_required()])
    M = fields.FloatField('mean anomaly',
                          validators=[validators.input_required()])
    E = fields.DateField('epoch date (time of mean anomaly) (Y-m-d)',
                         validators=[validators.input_required()],
                         format='%Y-%m-%d')
    D = fields.FloatField('equinox year',
                          validators=[validators.input_required()])
    M1 = fields.FloatField('magnitude model first component',
                           validators=[validators.input_required()])
    M2 = fields.FloatField('magnitude model second component',
                           validators=[validators.input_required()])
Exemple #3
0
class ContractForm(Form):
    crop = fields.SelectField('Crop', choices=[])
    company = fields.StringField('Company', [validators.required()])
    tonnes = fields.FloatField('Tonnes')
    fixed = fields.FloatField('Fixed')
    price_per_tonne = fields.FloatField('Price per Tonne')
    contract_value = fields.FloatField('Contract Value')
    price = fields.FloatField('Price')
Exemple #4
0
class VisitForm(Form):
    browser = fields.StringField()
    date = fields.DateField(default=dt.now)
    event = fields.StringField()
    url = fields.StringField(validators=[Required()])
    ip_address = fields.StringField()
    location = fields.StringField()
    latitude = fields.FloatField()
    longitude = fields.FloatField()
    site = QuerySelectField(validators=[Required()], query_factory=lambda: Site.query.all())
class Form_hoa_don(FlaskForm):
    ma_don_hang = fields.StringField('Mã đơn hàng:')
    kenh_ban = fields.SelectField(
        choices=[('Sendo', 'Sendo'), ('Shopee', 'Shopee'), (
            'Lazada',
            'Lazada'), ('Khác',
                        'Khác'), ('Người quen',
                                  'Người quen'), ('Facebook',
                                                  'Facebook'), ('Zalo',
                                                                'Zalo')])
    ho_ten = fields.StringField('Tên khách hàng:')
    ngay_tao = fields.DateField('Ngày:', widget=DateInput())
    dia_chi = fields.StringField('Địa chỉ:')
    so_dien_thoai = fields.StringField('Số điện thoại:')
    giam_gia = fields.FloatField('Giảm giá:')
    nha_van_chuyen = fields.SelectField('Hãng ship:',
                                        choices=[('GHN', 'GHN'),
                                                 ('Viettel', 'Viettel Post'),
                                                 ('VNC', 'VNC'),
                                                 ('NJV', 'Ninja Van'),
                                                 ('LEX', 'Lazada Express'),
                                                 ('VNPost', 'VN Post'),
                                                 ('Others', 'Khác')])
    ma_van_don = fields.StringField('Mã vận đơn:')
    phi_van_chuyen = fields.FloatField('Phí ship:')
    ghi_chu = fields.TextField('Ghi chú:')
    submit = fields.SubmitField('Kế tiếp')

    def tao_khach_hang(self):
        khach_hang = Khach_hang()
        khach_hang.ten_khach_hang = self.ho_ten.data.strip().lower()
        khach_hang.dia_chi = self.dia_chi.data.strip().lower()
        khach_hang.dien_thoai = self.so_dien_thoai.data.strip()
        db.session.add(khach_hang)
        db.session.commit()
        return khach_hang.get_id()

    def tao_hoa_don(self, ngay_tao, ma_kh):
        hoa_don = Hoa_don()
        hoa_don.ma_hoa_don_kenh_ban = self.ma_don_hang.data.strip()
        hoa_don.ngay_tao_hoa_don = ngay_tao
        hoa_don.ma_khach_hang = ma_kh
        hoa_don.tong_tien = 0
        hoa_don.kenh_ban = self.kenh_ban.data
        hoa_don.nha_van_chuyen = self.nha_van_chuyen.data
        hoa_don.ma_van_don = self.ma_van_don.data.strip()
        hoa_don.phi_van_chuyen = self.phi_van_chuyen.data
        hoa_don.ghi_chu = self.ghi_chu.data
        hoa_don.giam_gia = self.giam_gia.data
        db.session.add(hoa_don)
        db.session.commit()
        return hoa_don.get_id()
Exemple #6
0
class ImagingParametersForm(FlaskForm):
    microscope = fields.StringField('Microscope')
    camera = fields.StringField('Camera')
    magnification = fields.FloatField(
        'Magnification (e.g. 40x)', validators=[validators.NumberRange(0)]
    )
    na = fields.FloatField('NA', validators=[validators.NumberRange(0, 5)])
    binning = fields.StringField('Binning', validators=[validators.Length(0, 1000)])
    pixel_size = fields.StringField(
        'Pixel Size', validators=[validators.Length(0, 255)]
    )
    exposure_time = fields.StringField(
        'Exposure Time', validators=[validators.Length(0, 255)]
    )
Exemple #7
0
class SubmitObjectForm(FlaskForm):
    obj_name = fields.StringField('object Name')
    typedesig = fields.SelectField('object type',
                                   [validators.input_required()],
                                   coerce=str,
                                   choices=[('f', 'fixed'),
                                            ('v', 'periodic fixed'),
                                            ('e', 'heliocentric elliptical'),
                                            ('h', 'heliocentric hyperbolic'),
                                            ('p', 'heliocentric parabolic'),
                                            ('E', 'geocentric elliptical')])
    obj_ra = fields.FloatField('Right Ascension (deg)',
                               validators=(validators.Optional(), ))
    obj_dec = fields.FloatField('Declination (deg)',
                                validators=(validators.Optional(), ))
    add_obj = fields.SubmitField('Add object')
Exemple #8
0
class UserPreferenceForm(Form):
    """Form for creating or updating a user preference."""

    user_id = fields.IntegerField(u'User ID', [validators.required()])
    ingredient_id = fields.IntegerField(u'Ingredient ID',
                                        [validators.required()])
    coefficient = fields.FloatField(u'Coefficient', [validators.required()])
Exemple #9
0
class GameForm(form.Form):
    name = fields.StringField(u'游戏名', [validators.Required()])
    url = fields.StringField(u'Android下载链接', [validators.Optional()])
    url_ios = fields.StringField(u'IOS跳转链接', [validators.Optional()])
    description = fields.TextAreaField(u'描述', [validators.Required()])
    intro = fields.StringField(u'简介', [validators.Optional()])
    slogan = fields.StringField(u'标语', [validators.Optional()])
    developer = fields.StringField(u'开发者', [validators.Required()])
    package_id = fields.StringField(u'软件包ID', [validators.Required()])
    package_segment = fields.StringField(u'主播工具匹配包名特征',
                                         [validators.Optional()])
    bid = fields.StringField(u'咪咕平台游戏ID', [validators.Optional()])
    bcode = fields.StringField(u'咪咕平台CODE', [validators.Optional()])
    version = fields.StringField(u'版本号', [validators.Required()])
    size = fields.FloatField(u'包大小(M)', [validators.Required()], default=0.0)
    contain_sdk = fields.BooleanField(u'是否包含SDK', default=False)
    cover = fields.StringField(u'封面图片', [validators.Required()])
    icon = fields.StringField(u'图标', [validators.Required()])
    big_icon = fields.StringField(u'大图标', [validators.Required()])
    status = fields.SelectField(u'状态', [validators.InputRequired()],
                                coerce=int,
                                choices=[(const.ONLINE, u'上架'),
                                         (const.OFFLINE, u'下线'),
                                         (const.UNDER_TEST, u'测试'),
                                         (const.OFFSHELF, u'非上架')])
    migu = JsonField(u'咪咕信息', [validators.Optional()])
    is_download = fields.BooleanField(u'是否可下载(Android)', default=False)
    is_subscribe = fields.BooleanField(u'是否可订阅(Android)', default=False)
    is_download_ios = fields.BooleanField(u'是否可下载(IOS)', default=False)
    is_subscribe_ios = fields.BooleanField(u'是否可订阅(IOS)', default=False)
    on_assistant = fields.BooleanField(u'是否在游玩助手上架', default=True)
    categories = fields.SelectMultipleField(u'分类', [validators.Optional()],
                                            coerce=ObjectId)
Exemple #10
0
 def handle_primary_key(self, model, field, **kwargs):
     if field.column_class == IntegerColumn:
         field_obj = f.IntegerField(**kwargs)
     elif field.column_class in (FloatColumn, DoubleColumn):
         field_obj = f.FloatField(**kwargs)
     else:
         field_obj = f.TextField(**kwargs)
     return field.name, field_obj
Exemple #11
0
class PeriodicForm(FlaskForm):
    class Meta:
        csrf = False

    mdj0 = fields.IntegerField('mjd of period start',
                               validators=[validators.input_required()])
    phasedays = fields.FloatField('period length (days)',
                                  validators=[validators.input_required()])
Exemple #12
0
class ApplyCashFrom(Form):

    amount = f.FloatField("提现金额",
                          validators=[
                              validators.DataRequired(message="必填项"),
                              validators.NumberRange(min=1,
                                                     message="提现金额必须大于1元")
                          ])
Exemple #13
0
 def __init__(self, copy=None):
     cls = self.__class__
     obj_fields = list(cls.__dict__['__ordered__'])
     if not hasattr(cls, '_tinydb_initialised'):
         attr_dict = {}
         cls.column_list = ()
         cls.column_sortable_list = ()
         obj_fields.append('source_host')  # add this field to all instances
         cls.source_host = Constant.HOST_NAME
         first_check = True
         for attr in obj_fields:
             if utils.is_primitive(attr, getattr(cls, attr)):
                 if first_check:
                     if attr != 'id':
                         L.l.error(
                             'First key is not id, but {}. list is {}'.
                             format(attr, cls.__dict__))
                         L.l.info('dicts={}'.format(dict(cls.__dict__)))
                         L.l.info('ordered={}'.format(
                             collections.OrderedDict(cls.__dict__)))
                     first_check = False
                 attr_type = type(getattr(self, attr))
                 if attr_type is int:
                     fld = fields.IntegerField(attr)
                 elif attr_type is float:
                     fld = fields.FloatField(attr)
                 elif attr_type is bool:
                     fld = fields.BooleanField(attr)
                 elif attr_type is datetime:
                     fld = fields.DateTimeField(attr)
                 elif attr_type is str:
                     fld = fields.StringField(attr)
                 else:
                     fld = fields.StringField(attr)
                 attr_dict[attr] = fld
                 # self.column_list = self.column_list + (attr,)
                 # self.column_sortable_list = self.column_sortable_list + (attr,)
                 cls.column_list = cls.column_list + (attr, )
                 setattr(
                     cls, attr, attr
                 )  # set class field values to equal names, for ORM autocompletion
         # http://jelly.codes/articles/python-dynamically-creating-classes/
         self.form = type(
             type(self).__name__ + 'Form', (form.Form, ), attr_dict)
         collx = getattr(db, type(self).__name__.lower())
         ModelView.__init__(self, collx, type(self).__name__)
         cls.t = self.coll.table
         cls.coll = self.coll
         cls._tinydb_initialised = True
     else:
         for attr in obj_fields:
             setattr(self, attr, None)
         self.source_host = Constant.HOST_NAME
     if copy is not None:
         for fld in copy:
             if hasattr(self, fld):
                 setattr(self, fld, copy[fld])
             self._listener_executed = None
Exemple #14
0
class PartnerForm(Form):
    name = fields.StringField(
        'Company Name',
        validators=[validators.required(),
                    validators.length(max=255)],
        render_kw={"placeholder": "Insert your company or personal name"})
    description = fields.StringField(
        'Description', render_kw={"placeholder": "Company description"})
    company_number = fields.StringField(
        'Company registration',
        render_kw={"placeholder": "Company registration ID"})
    vat_number = fields.StringField(
        'VAT number', render_kw={"placeholder": "VAT registration ID"})
    partner_type = fields.SelectField('Partner Type',
                                      validators=[validators.required()],
                                      choices=PARTNER_TYPE,
                                      default=2)
    address_city = fields.StringField(
        'City', validators=[validators.required(),
                            validators.length(max=255)])
    address_street = fields.StringField(
        'Street',
        validators=[validators.required(),
                    validators.length(max=255)])
    address_street_no = fields.StringField(
        'Street Number',
        validators=[validators.required(),
                    validators.length(max=50)])
    address_zip_code = fields.StringField(
        'ZIP Code',
        validators=[validators.required(),
                    validators.length(max=50)])
    address_longitude = fields.FloatField('Longitude')
    address_latitude = fields.FloatField('Latitude')
    address_country_code = fields.SelectField(
        'Country',
        validators=[validators.required(),
                    validators.length(max=255)],
        choices=COUNTRY_CODES,
        default='CZ')
    address_geo_location_type = fields.SelectField(
        'Type',
        validators=[validators.required()],
        choices=GEO_LOCATION_TYPE,
        default=2)
Exemple #15
0
class FindObjectForm(FlaskForm):
    obj_name = fields.StringField('object name contains',
                                  validators=(validators.Optional(), ))
    typedesig = fields.SelectField('object type',
                                   [validators.input_required()],
                                   coerce=str,
                                   choices=[('', ''), ('f', 'fixed'),
                                            ('v', 'periodic fixed'),
                                            ('e', 'heliocentric elliptical'),
                                            ('h', 'heliocentric hyperbolic'),
                                            ('p', 'heliocentric parabolic'),
                                            ('E', 'geocentric elliptical')])
    obj_ra = fields.FloatField('Right Ascension (deg)',
                               validators=(validators.Optional(), ))
    obj_dec = fields.FloatField('Declination (deg)',
                                validators=(validators.Optional(), ))
    radius = fields.FloatField('radius (arcsec)',
                               validators=(validators.Optional(), ))
    submit_obj = fields.SubmitField('seach for object')
Exemple #16
0
    def from_floatfield(self, document_field, **kwargs):
        """
        Convert ``document_field`` into a ``FloatField``.

        :param document_field:
            Instance of Mongoengine field.

        :return:
            Instance of :py:class:`!wtforms.fields.FloatField`.

        """
        self.set_common_number_kwargs(document_field, kwargs)
        return fields.FloatField(**kwargs)
Exemple #17
0
class HarvestForm(Form):
    date = fields.DateTimeField('Date',
                                id="date",
                                format='%Y-%m-%d',
                                validators=[validators.required()])
    section_from = extfields.ExtendedSelectField(
        'From Field Section',
        id='section_from',
        validators=[
            validators.NoneOf(-1, message="Please select a field"),
            validators.required()
        ])
    bin_to = fields.SelectField('To Bin',
                                id='bin_to',
                                choices=[],
                                validators=[validators.required()])
    amount = fields.FloatField('Size in tonnes',
                               validators=[validators.required()])
Exemple #18
0
class RequestForm(FlaskForm):
    # object data
    obj_name = fields.StringField('Object Name', [validators.input_required()])
    obj_ra = fields.StringField('RA', [validators.Optional()])
    obj_dec = fields.StringField('DEC', [validators.Optional()])
    typedesig = fields.SelectField('object type',
                                   [validators.input_required()],
                                   coerce=str,
                                   choices=[('f', 'fixed'),
                                            ('v', 'periodic fixed'),
                                            ('e', 'heliocentric elliptical'),
                                            ('h', 'heliocentric hyperbolic'),
                                            ('p', 'heliocentric parabolic'),
                                            ('E', 'geocentric elliptical')])
    # required and optional fields for requests
    allocation = fields.SelectField('allocation', [validators.data_required()],
                                    coerce=int,
                                    choices=[])
    priority = fields.FloatField('priority', [validators.input_required()])
    filters_op = fields.SelectField('filters', [validators.input_required()],
                                    coerce=str,
                                    choices=[(' 1, 1, 1, 1}', 'u-g-r-i'),
                                             (' 0, 1, 1, 1}', "g-r-i")])
    seq_repeats = fields.IntegerField('# of repeats', default=1)
    ifu = fields.BooleanField('IFU image', [validators.Optional()])
    ab = fields.BooleanField('A B pair', [validators.Optional()])
    cadence = fields.FloatField('cadence',
                                default=None,
                                validators=(validators.Optional(), ))
    min_moon_dist = fields.FloatField(
        'minimum moon distance (degrees)',
        validators=(validators.Optional(), validators.number_range(0., 180.)))
    max_moon_illum = fields.FloatField(
        'maximum moon illumination (fractional)',
        validators=(validators.Optional(), validators.number_range(0., 1.)))
    max_cloud_cover = fields.FloatField(
        'maximum cloud cover (fractional)',
        validators=(validators.Optional(), validators.number_range(0., 1.)))
    phasesamples = fields.FloatField('samples per period',
                                     default=None,
                                     validators=(validators.Optional(), ))
    inidate = fields.DateField('start date (Y-m-d)',
                               validators=[validators.input_required()],
                               format='%Y-%m-%d')
    enddate = fields.DateField('end date (Y-m-d)',
                               validators=[validators.input_required()],
                               format='%Y-%m-%d')
    #elliptical = fields.FormField(HeliocentricEllipticalForm, validators=(validators.Optional(),))
    #hyperbolic = fields.FormField(HeliocentricHyperbolicForm, validators=(validators.Optional(),))
    #parabolic = fields.FormField(HeliocentricParabolicForm, validators=(validators.Optional(),))
    #satellite = fields.FormField(EarthSatelliteForm, validators=(validators.Optional(),))
    submit_req = fields.SubmitField('submit request')
Exemple #19
0
class GamePlatformForm(form.Form):
    url = fields.StringField(u"下载链接", [validators.Optional()])
    package_id = fields.StringField(u'软件包ID', [validators.Required()])
    package_segment = fields.StringField(u'主播工具匹配包名特征',
                                         [validators.Optional()])
    bid = fields.StringField(u'咪咕平台游戏ID', [validators.Optional()])
    bcode = fields.StringField(u'咪咕平台CODE', [validators.Optional()])
    version = fields.StringField(u'版本号', [validators.Required()])
    size = fields.FloatField(u'包大小(M)', [validators.Required()], default=0.0)
    contain_sdk = fields.BooleanField(u'是否包含SDK', default=False)
    cover = fields.StringField(u'封面图片', [validators.Required()])
    icon = fields.StringField(u'图标', [validators.Required()])
    big_icon = fields.StringField(u'大图标', [validators.Required()])
    status = fields.SelectField(u'状态', [validators.InputRequired()],
                                coerce=int,
                                choices=[(const.ONLINE, u'在线'),
                                         (const.OFFLINE, u'下线'),
                                         (const.UNDER_TEST, u'测试')])
    migu = JsonField(u'咪咕信息', [validators.Optional()])
    is_download = fields.BooleanField(u'是否可下载', default=False)
    is_subscribe = fields.BooleanField(u'是否可订阅', default=False)
Exemple #20
0
class EarthSatelliteForm(FlaskForm):
    class Meta:
        csrf = False

    T = fields.DateField('Epoch of following fields (Y-m-d)',
                         validators=[validators.input_required()],
                         format='%Y-%m-%d')
    i = fields.FloatField('inclination (degrees)',
                          validators=[validators.input_required()])
    ra = fields.FloatField('RA of ascending node (degrees)',
                           validators=[validators.input_required()])
    e = fields.FloatField('Eccentricity',
                          validators=[validators.input_required()])
    P = fields.FloatField('argument of perigee (degrees)',
                          validators=[validators.input_required()])
    M = fields.FloatField('mean anomaly (degrees)',
                          validators=[validators.input_required()])
    n = fields.FloatField('mean motion (revs/day)',
                          validators=[validators.input_required()])
    d = fields.FloatField('orbit decay rate (revs/day^2)',
                          validators=[validators.input_required()])
    r = fields.FloatField('integral reference orbit no. at Epoch',
                          validators=[validators.input_required()])
Exemple #21
0
class HeliocentricHyperbolicForm(FlaskForm):
    class Meta:
        csrf = False

    T = fields.DateField('date of ephoch of perihelion (Y-m-d)',
                         validators=[validators.input_required()],
                         format='%Y-%m-%d')
    i = fields.FloatField('inclination (degrees)',
                          validators=[validators.input_required()])
    O = fields.FloatField('longitude of ascending node (degrees)',
                          validators=[validators.input_required()])
    o = fields.FloatField('argument of perihelion (degrees)',
                          validators=[validators.input_required()])
    e = fields.FloatField('eccentricity',
                          validators=[validators.input_required()])
    q = fields.FloatField('perihelion distance (AU)',
                          validators=[validators.input_required()])
    D = fields.FloatField('equinox year',
                          validators=[validators.input_required()])
    M1 = fields.FloatField('magnitude model first component',
                           validators=[validators.input_required()])
    M2 = fields.FloatField('magnitude model second component',
                           validators=[validators.input_required()])
class CalculateRunForm(FlaskForm):
    activity = fields.StringField(
        'Activity',
        validators=[
            validators.DataRequired(),
            validators.AnyOf(
                values=['walk', 'run'],
                message=
                "I don't know what nonsense you're doing, but we only support 'walk' and 'run'"
            )
        ])

    distance = fields.FloatField(
        'Distance',
        validators=[
            validators.DataRequired(),
            validators.NumberRange(
                min=0.01,
                message="Come on, distance must be at least %(min)s!")
        ])

    # Duration
    hours = fields.IntegerField(
        'Hours',
        validators=[
            validators.Optional(),
            validators.NumberRange(min=0)  # Cannot be negative
        ],
        default=0)
    minutes = fields.IntegerField(
        'Minutes',
        validators=[
            validators.Optional(),
            validators.NumberRange(min=0)  # Cannot be negative
        ],
        default=0)
    seconds = fields.IntegerField(
        'Seconds',
        validators=[
            validators.Optional(),
            validators.NumberRange(min=0)  # Cannot be negative
        ],
        default=0)

    bodyweight = fields.FloatField(
        'Bodyweight',
        validators=[
            validators.DataRequired(),
            validators.NumberRange(
                min=0.01, message="Bodyweight must be at least %(min)s")
        ])

    elevation_gain = fields.IntegerField('elevation_gain',
                                         validators=[validators.Optional()],
                                         default=0)

    units = fields.StringField(
        'Units',
        validators=[
            validators.Optional(),
            validators.AnyOf(values=['imperial', 'metric'])
        ],
        default='imperial')
def convert_FloatProperty(model, prop, kwargs):
    """Returns a form field for a ``db.FloatProperty``."""
    return f.FloatField(**kwargs)
Exemple #24
0
class AddNewProductTypeForm(Form):
    description = fields.StringField()
    weight = fields.FloatField()
    dimensions = fields.StringField()
Exemple #25
0
 def conv_Float(self, model, field, kwargs):
     self._number_common(model, field, kwargs)
     return f.FloatField(**kwargs)
Exemple #26
0
class DomDivForm(FlaskForm):
    # Expansions
    choices = domdiv.main.EXPANSION_CHOICES
    # make pretty names for the expansion choices
    choiceNames = []
    replacements = {
        "1stedition": "1st Edition",
        "2ndeditionupgrade": "2nd Edition Upgrade",
        "2ndedition": "2nd Edition",
    }
    for choice in choices:
        for s, r in replacements.items():
            if choice.lower().endswith(s):
                choiceNames.append("{} {}".format(
                    choice[:-len(s)].capitalize(), r))
                break
        else:
            choiceNames.append(choice.capitalize())
    expansions = wtf_fields.SelectMultipleField(
        label="Expansions to Include (Cmd/Ctrl click to select multiple)",
        choices=list(zip(choices, choiceNames)),
        default=["dominion2ndEdition"],
    )
    # Now Fan expansions
    choices = domdiv.main.FAN_CHOICES
    # make pretty names for the expansion choices
    choiceNames = []
    for choice in choices:
        for s, r in replacements.items():
            if choice.lower().endswith(s):
                choiceNames.append("{} {}".format(
                    choice[:-len(s)].capitalize(), r))
                break
        else:
            choiceNames.append(choice.capitalize())
    fan = wtf_fields.SelectMultipleField(
        choices=list(zip(choices, choiceNames)),
        label="Fan Expansions to Include (Cmd/Ctrl click to select multiple)",
    )
    orientation = wtf_fields.SelectField(
        label="Divider Orientation",
        choices=[("horizontal", "Horizontal"), ("vertical", "Vertical")],
        default="horizontal",
    )

    pagesize = wtf_fields.SelectField(
        label="Paper Size",
        choices=list(
            zip(
                PAPER_SIZES + domdiv.main.LABEL_KEYS,
                PAPER_SIZES + domdiv.main.LABEL_SELECTIONS,
            )),
        default="Letter",
    )

    choices = ["Sleeved - Thin", "Sleeved - Thick", "Unsleeved"]
    cardsize = wtf_fields.SelectField(choices=list(zip(choices, choices)),
                                      label="Card Size",
                                      default="Unsleeved")
    tabwidth = wtf_fields.FloatField(
        label="Width of Tab in centimeters",
        default=4.0,
    )
    back_offset = wtf_fields.FloatField(
        label="Back page horizontal offset points to shift to the right",
        default=0,
    )
    back_offset_height = wtf_fields.FloatField(
        label="Back page vertical offset points to shift upward",
        default=0,
    )

    horizontal_gap = wtf_fields.FloatField(
        label="Horizontal gap between dividers in centimeters",
        default=0,
    )
    vertical_gap = wtf_fields.FloatField(
        label="Vertical gap between dividers in centimeters",
        default=0,
    )

    black_tabs = wtf_fields.BooleanField(label="Black tab background", )
    tabwidth = wtf_fields.FloatField(label="Width of Tab in centimeters",
                                     default=4.0)
    base_cards_with_expansion = wtf_fields.BooleanField(
        label="Include Base cards with the expansion", default=False)
    upgrade_with_expansion = wtf_fields.BooleanField(
        label="Include upgrade cards with the expansion being upgraded",
        default=False)
    edition = wtf_fields.SelectField(
        choices=list(
            zip(domdiv.main.EDITION_CHOICES, domdiv.main.EDITION_CHOICES)),
        label="Edition",
        default="all",
    )
    cropmarks = wtf_fields.BooleanField(label="Cropmarks Instead of Outlines",
                                        default=False)
    linetype = wtf_fields.SelectField(
        choices=list(zip(domdiv.main.LINE_CHOICES, domdiv.main.LINE_CHOICES)),
        label="Outline Type",
        default="line",
    )
    wrapper = wtf_fields.BooleanField(label="Slipcases Instead of Dividers",
                                      default=False)
    notch = wtf_fields.BooleanField(
        label="If Slipcases, add a notch in corners", default=False)
    tab_serpentine = wtf_fields.BooleanField(
        label=
        "For 3 or more tabs, tab location reverses when the end is reached instead of resetting to the start",
        default=False,
    )
    expansion_reset_tabs = wtf_fields.BooleanField(
        label="Restart tab starting location with every expansion.",
        default=True)
    count = wtf_fields.BooleanField(label="Show number of Cards per Divider",
                                    default=False)
    types = wtf_fields.BooleanField(label="Show Card Type on each Divider",
                                    default=False)
    tab_name_align = wtf_fields.SelectField(
        choices=list(
            zip(domdiv.main.NAME_ALIGN_CHOICES,
                domdiv.main.NAME_ALIGN_CHOICES)),
        default=domdiv.main.NAME_ALIGN_CHOICES[0],
    )
    tab_number = wtf_fields.SelectField(choices=list(
        TAB_NUMBER_SELECTION.items()),
                                        label="Number of tabs",
                                        default=1)

    for x in domdiv.main.TAB_SIDE_CHOICES:
        if x not in TAB_SIDE_SELECTION:
            TAB_SIDE_SELECTION[x] = x.title()
    tab_side = wtf_fields.SelectField(
        choices=list(TAB_SIDE_SELECTION.items()),
        label="Starting tab location",
        default="left",
    )

    order = wtf_fields.SelectField(
        label="Divider Order",
        choices=list(zip(domdiv.main.ORDER_CHOICES,
                         domdiv.main.ORDER_CHOICES)),
        default=domdiv.main.ORDER_CHOICES[0],
    )
    group_special = wtf_fields.BooleanField(
        label="Group Special Cards (e.g. Prizes with Tournament)",
        default=True)
    group_kingdom = wtf_fields.BooleanField(
        label="Group cards without randomizers separately", default=False)
    # global grouping
    choices = domdiv.main.GROUP_GLOBAL_CHOICES
    # make pretty names for the global group choices
    choiceNames = []
    for choice in choices:
        choiceNames.append(choice.capitalize())
    group_global = wtf_fields.SelectMultipleField(
        choices=list(zip(choices, choiceNames)),
        label=
        "Group these card types globally (Cmd/Ctrl click to select multiple)",
        default="",
    )
    start_decks = wtf_fields.BooleanField(
        label="Group four start decks with the Base cards")
    curse10 = wtf_fields.BooleanField(
        label="Group Curse cards into groups of ten cards")
    no_trash = wtf_fields.BooleanField(label="Exclude Trash from cards")
    expansion_dividers = wtf_fields.BooleanField(
        label="Include Expansion Dividers", default=False)
    centre_expansion_dividers = wtf_fields.BooleanField(
        label="If Expansion Dividers, centre the tabs on expansion dividers",
        default=False,
    )
    expansion_dividers_long_name = wtf_fields.BooleanField(
        label=("If Expansion Dividers, use edition "
               "on expansion dividers names"),
        default=False,
    )
    set_icon = wtf_fields.SelectField(
        choices=list(
            zip(domdiv.main.LOCATION_CHOICES, domdiv.main.LOCATION_CHOICES)),
        label="Set Icon Location",
        default="tab",
    )
    cost = wtf_fields.SelectField(
        choices=list(
            zip(domdiv.main.LOCATION_CHOICES, domdiv.main.LOCATION_CHOICES)),
        label="Cost Icon Location",
        default="tab",
    )
    language = wtf_fields.SelectField(
        choices=list(
            zip(domdiv.main.LANGUAGE_CHOICES, domdiv.main.LANGUAGE_CHOICES)),
        label="Language",
        default="en_us",
    )
    exclude_events = wtf_fields.BooleanField(
        label="Exclude Individual Events & Landmarks", default=False)
    text_front = wtf_fields.SelectField(
        label="Front Text",
        choices=list(zip(domdiv.main.TEXT_CHOICES, domdiv.main.TEXT_CHOICES)),
        default="card",
    )
    text_back = wtf_fields.SelectField(
        label="Back Text",
        choices=list(
            zip(
                domdiv.main.TEXT_CHOICES + ["none"],
                domdiv.main.TEXT_CHOICES + ["no back page"],
            )),
        default="rules",
    )
    no_page_footer = wtf_fields.BooleanField(
        label="Omit the expansion name at the bottom of the page",
        default=False)

    def clean_options(self):
        form_options = argparse.Namespace()
        self.populate_obj(form_options)
        options = domdiv.main.parse_opts([])
        logger.info(f"valid options: {sorted(list(vars(options).keys()))}")
        is_label = False
        for option, value in vars(form_options).items():
            # option = option.replace('_', '-')
            logger.info(f"option {option} ({type(option)}): {value}")
            if option == "tab_number":
                value = int(value)
            if option in ["expansions", "fan"]:
                value = [[v] for v in value]
            if option == "cardsize":
                logger.info("handling cardsize")
                options.size = "unsleeved" if "Unsleeved" in value else "sleeved"
                options.sleeved_thick = "Thick" in option
                options.sleeved_thin = "Thin" in option
            elif option == "pagesize":
                logger.info("handling pagesize")
                if value in PAPER_SIZES:
                    options.papersize = value
                    options.label_name = None
                else:
                    options.label_name = value
                    options.papersize = "letter"
                    options.wrapper = False
                    options.notch = False
                    options.cropmarks = False
                    is_label = True
            else:
                assert hasattr(options,
                               option), f"{option} is not a script option"
                if is_label and option in ["wrapper", "notch", "cropmarks"]:
                    logger.info(
                        f"skipping {option} because we're printing labels")
                    continue
                logger.info(f"{option} --> {value}")
                options.__setattr__(option, value)

            if not options.group_global:
                options.group_global = None

        logger.info(f"options after populate: {options}")
        options = domdiv.main.clean_opts(options)
        logger.info(f"options after cleaning: {options}")
        return options

    def generate(self, num_pages=None, **kwargs):
        options = self.clean_options()
        if num_pages is not None:
            options.num_pages = num_pages

        buf = BytesIO()
        options.outfile = buf
        domdiv.main.generate(options)
        logger.info("done generation, returning pdf")
        buf.seek(0)
        return buf
Exemple #27
0
class InputForm_gui(Form):
    # No Interactive selection version. 2016.07.28
    variantinputtype = fields.SelectField(label='In ',
                                          choices=[('1', 'Variant IDs'),
                                                   ('2', 'Region(bp)'),
                                                   ('3', 'Genes')],
                                          default='2')

    ########## Specify method of selection ########
    variant_id_text = fields.TextAreaField(
        label='Comma separated ILVDB variant IDs',
        default='Comma separated ISVDB variant IDs')
    #variantfile = fields.FileField('Upload variant_id file(Unavailable)')

    chr = fields.SelectField(label='Chrom',
                             choices=chrom_list_choice,
                             default='19')
    strnum = fields.FloatField(label='Start', default=30000000)
    endnum = fields.FloatField(label='End', default=35000000)
    #bedfile = fields.FileField('Upload bed file (Unavailable)')

    genesearch = fields.TextAreaField(
        label='Comma separated Ensembl IDs',
        default='ENSMUSG00000051951, ENSMUSG00000025931, ENSMUSG00000026596')
    #gene_list = fields.SelectField(label='Genes search result', choices=genenamechoice)
    #genefile = fields.FileField('Upload gene list file(Unavailable)')
    ######### Specify view table to use #########
    view = fields.SelectField(label='View ', choices=viewchoices)
    # currently just use all selection?
    selectCollum1 = fields.SelectMultipleField(
        label='Select included fields',
        choices=genotype_view_choice,
        default=genotype_view_choice_seed)
    selectCollum2 = fields.SelectMultipleField(
        label='Select included fields',
        choices=diplotype_view_choice,
        default=diplotype_view_choice_seed)
    selectCollum3 = fields.SelectMultipleField(
        label='Select included fields',
        choices=genotype_cross_view_choice,
        default=genotype_cross_view_seed2)
    selectCollum4 = fields.SelectMultipleField(
        label='Select included fields',
        choices=diplotype_cross_view_choice,
        default=diplotype_cross_view_seed2)

    ######## Specify target strain/founder ########
    strainlistnew = fields.SelectMultipleField(
        label='Of strains',
        choices=strain_list,
        default=['1', '2', '3', '4', '5', '6', '7', '8', '9'])
    strainp1new = fields.SelectField(label=' of S1',
                                     choices=strain_list,
                                     default='8')
    strainp2new = fields.SelectField(label=' with S2',
                                     choices=strain_list,
                                     default='3')

    ######## add filter to final data #########
    prob_cutoff = fields.FloatField(label='Prob >=', default=0.00)
    h**o = fields.SelectField(label='Zygosity:',
                              choices=[('H**o', 'Homozygous'),
                                       ('Hetero', 'Heterozygous'),
                                       ('All', 'All')],
                              default='All')
    ismax = fields.BooleanField(label='Only show max probability?', default=0)
    consequence = fields.SelectMultipleField(label='With consequences',
                                             choices=consequence_list)

    ############### limit
    limnum = fields.FloatField(label='Output limit', default=1000)
Exemple #28
0
class AddFixedRequest(FlaskForm):
    # object data
    request_id = fields.HiddenField('Hidden')
    object_id = fields.HiddenField('Hidden')
    marshal_id = fields.HiddenField('Hidden', default=-1)
    user_id = fields.HiddenField('Hidden')
    allocation_id = fields.HiddenField('Hidden')
    obj_name = fields.StringField('Object Name', [validators.input_required()])
    status = fields.SelectField('Status',
                                coerce=str,
                                choices=[('DEFAULT', "--------"),
                                         ('EXPIRED', 'EXPIRED'),
                                         ('COMPLETED', 'COMPLETED'),
                                         ('ACTIVE', 'ACTIVE'),
                                         ('CANCELED', 'CANCELED'),
                                         ('PENDING', 'PENDING')])
    obj_ra = fields.StringField('RA (HH:MM:SS or Degrees)')
    obj_dec = fields.StringField('DEC (DD:MM:SS or Degrees)')
    obj_epoch = fields.StringField('EPOCH', default='2000')
    obj_mag = fields.FloatField('Magnitude')
    allocation = fields.SelectField('allocation')

    priority = fields.FloatField('priority', default=.99)
    filters_op = fields.SelectField('filters',
                                    coerce=str,
                                    choices=[(' 1, 1, 1, 1}', 'u-g-r-i'),
                                             (' 0, 1, 1, 1}', 'g-r-i'),
                                             (' 0, 1, 0, 0}', 'g'),
                                             (' 0, 0, 1, 0}', 'r'),
                                             ('0, 0, 0, 1}', 'i'),
                                             ('0, 0, 0, 0}', '-')])
    do_r = fields.BooleanField('r')
    do_g = fields.BooleanField('g')
    do_i = fields.BooleanField('i')
    do_u = fields.BooleanField('u')
    r_exptime = fields.IntegerField('Exptime (seconds)', default=0)
    g_exptime = fields.IntegerField('Exptime (seconds)', default=0)
    i_exptime = fields.IntegerField('Exptime (seconds)', default=0)
    u_exptime = fields.IntegerField('Exptime (seconds)', default=0)
    r_repeats = fields.IntegerField('# Repeats', default=1)
    g_repeats = fields.IntegerField('# Repeats', default=1)
    i_repeats = fields.IntegerField('# Repeats', default=1)
    u_repeats = fields.IntegerField('# Repeats', default=1)

    rc_use_mag = fields.BooleanField(
        'Use object magnitude to set exposure time')
    seq_repeats = fields.IntegerField('# of Repeated Sequences', default=1)
    seq_completed = fields.IntegerField('# of Sequences Already Completed',
                                        default=0)
    ifu = fields.BooleanField('Take IFU Exposure')
    rc = fields.BooleanField('Take RC Exposure')
    ifu_use_mag = fields.BooleanField(
        'Use object magnitude to set exposure time')
    ifu_exptime = fields.IntegerField(
        'Enter Total IFU Exposure Time in seconds')
    ab = fields.BooleanField('Select For AB pair')

    cadence = fields.FloatField('cadence', default=None)

    min_moon_dist = fields.FloatField(
        'minimum moon distance (degrees)',
        validators=(validators.Optional(), validators.number_range(0., 180.)),
        default=30)

    max_moon_illum = fields.FloatField(
        'Maximum Moon Illumination (fractional 0 to 1)',
        validators=(validators.Optional(), validators.number_range(0., 1.)),
        default=1)
    maxairmass = fields.FloatField('Maximum Airmass',
                                   validators=(validators.Optional(),
                                               validators.number_range(1, 5)),
                                   default=2.5)
    max_cloud_cover = fields.FloatField(
        'Maximum Cloud Cover (fractional)',
        validators=(validators.Optional(), validators.number_range(0., 1.)),
        default=1)
    max_fwhm = fields.FloatField('Maximum FWHM',
                                 validators=(validators.Optional(),
                                             validators.number_range(0., 10.)),
                                 default=10)
    phasesamples = fields.FloatField('samples per period', default=None)
    sampletolerance = fields.FloatField('samples tolerance', default=None)
    inidate = fields.DateField('start date (Y-m-d)',
                               validators=[validators.input_required()],
                               format='%Y-%m-%d',
                               default=datetime.datetime.utcnow())

    enddate = fields.DateField('end date (Y-m-d)',
                               validators=[validators.input_required()],
                               format='%Y-%m-%d',
                               default=(datetime.datetime.utcnow() +
                                        datetime.timedelta(days=3)))
    creationdate = fields.Label('creationdate', 'Creation Date')
    lastmodified = fields.Label('lastmodified', 'Last Modified')
    last_obs_jd = fields.Label('last_obs_jd', 'Last observation')
    submit_req = fields.SubmitField('Submit Request')
Exemple #29
0
class UtilizationForm(form.Form):
    """飞行器利用率的相关信息。"""
    hours = fields.FloatField('小时/月')
    times = fields.IntegerField('起落次数/月')
Exemple #30
0
class Form_khoan_chi(FlaskForm):
    ten = fields.TextField([validators.required()])
    noi_dung = fields.TextField()
    so_tien = fields.FloatField([validators.required()])
    submit_1 = fields.SubmitField('Hoàn tất')