Esempio n. 1
0
    class RegistrationForm(TableForm):
        # set additional extra info here to bring them across the registration process
        # you might want to serialize the extra info in json or something similar
        extra = HiddenField()

        user_name = TextField(label=l_('User Name'),
                              validator=UniqueUserValidator(not_empty=True))
        email_address = TextField(
            label=l_('Email'), validator=UniqueEmailValidator(not_empty=True))
        password = PasswordField(label=l_('Password'), validator=Required)
        password_confirm = PasswordField(label=l_('Confirm Password'),
                                         validator=Required)
        validator = validators.FieldsMatch('password', 'password_confirm')
Esempio n. 2
0
 class fields(WidgetsList):
     user_name = TextField(
         label_text=l_('User Name'),
         validator=UniqueUserValidator(not_empty=True))
     email_address = TextField(
         label_text=l_('Email'),
         validator=UniqueEmailValidator(not_empty=True))
     password = PasswordField(
         label_text=l_('Password'),
         validator=validators.UnicodeString(not_empty=True))
     password_confirm = PasswordField(
         label_text=l_('Confirm Password'),
         validator=validators.UnicodeString(not_empty=True))
Esempio n. 3
0
 class fields(WidgetsList):
     event = HiddenField()
     cal = HiddenField(validator=SQLAEntityConverter(model.Calendar))
     name = TextField(
         label_text=l_('Event Name'),
         validator=validators.UnicodeString(not_empty=True))
     summary = TextArea(
         label_text=l_('Event short summary'),
         validator=validators.UnicodeString(not_empty=False))
     datetime = CalendarDateTimePicker(label_text=l_('Event date'))
     location = TextField(
         label_text=l_('Event Location (es: turin,it)'),
         validator=validators.UnicodeString(not_empty=True))
     linked_entity = SingleSelectField(label_text=l_('Linked Entity'))
Esempio n. 4
0
class NewCategoryForm(ListForm):
    name = TextField(label=l_('Name'), validator=Validator(required=True), css_class='form-control',
                     container_attrs={'class': 'form-group'})
    parent_id = SingleSelectField(label=l_('Parent'),
                                  css_class="form-control", container_attrs={'class': 'form-group'},
                                  options=Deferred(lambda: [(c._id, c.name[tg.config.lang])
                                                            for c in app_globals.shop.category.get_all()]))
    submit = SubmitButton(value=l_('Create'), css_class='btn btn-default')
Esempio n. 5
0
class NewProductForm(ListForm):

    name = TextField(label=l_('Name'), validator=Validator(required=True), css_class='form-control',
                     container_attrs={'class': 'form-group'})
    description = TextArea(label=l_('Description'), validator=Validator(required=True), css_class='form-control',
                           container_attrs={'class': 'form-group'})
    sku = TextField(label=l_('SKU'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    categories_ids = MultipleSelectField(label=l_('Categories'), validator=Validator(required=True),
                                         css_class="form-control", container_attrs={'class': 'form-group'},
                                         options=Deferred(lambda: [(c._id, c.name_with_ancestors)
                                                                   for c in app_globals.shop.category.get_all()]))
    price = TextField(label=l_('Price'), validator=Number(min=0.0, not_empty=True), css_class='form-control',
                      container_attrs={'class': 'form-group'})
    rate = TextField(label=l_('Rate'), validator=IntValidator(min=0, required=True), css_class='form-control',
                     container_attrs={'class': 'form-group'})
    vat = TextField(label=l_('Vat'), validator=Number(min=0.0, not_empty=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    qty = TextField(label=l_('Quantity'), validator=IntValidator(min=0, required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    weight = TextField(label=l_('Weight (g)'), validator=Number(min=0.0, not_empty=True),
                       css_class='form-control')
    photos = AjaxManagePhotos(label=l_('Photos'),
                              css_class="ajax_manage_photos",
                              action=json_lurl('/commerce/manage/product/photos/save'),
                              delete_action=json_lurl('/commerce/manage/product/photos/remove'))

    submit = SubmitButton(value=l_('Create'), css_class='btn btn-default')
Esempio n. 6
0
 class fields(WidgetsList):
     name = TextField(
         label_text=l_("Calendar Name"),
         validator=validators.UnicodeString(not_empty=True))
     events_type = SingleSelectField(
         label_text=l_('Events Type'),
         options=lambda:
         [e.name for e in config['_calendarevents']['event_types']],
         validator=validators.UnicodeString(not_empty=False))
Esempio n. 7
0
 class NewCalendarForm(TableForm):
     name = TextField(label=l_("Calendar Name"), validator=Required)
     events_type = SingleSelectField(
         label=l_('Events Type'),
         prompt_text=None,
         validator=Required,
         options=Deferred(
             lambda:
             [e.name for e in config['_calendarevents']['event_types']]))
Esempio n. 8
0
    class NewEventForm(TableForm):
        event = HiddenField()
        cal = HiddenField(validator=SQLAEntityConverter(model.Calendar))
        name = TextField(label=l_('Event Name'), validator=Required)
        summary = TextArea(label=l_('Event short summary'))
        datetime = CalendarDateTimePicker(label=l_('Event date'))
        location = TextField(label=l_('Event Location (es: turin,it)'),
                             validator=Required)
        linked_entity = SingleSelectField(label=l_('Linked Entity'))

        def prepare(self):
            #simulate ToscaWidget1 child_args
            for c in self.child.children:
                if c.key == 'linked_entity':
                    c.options = self.child_args.get('linked_entity',
                                                    {}).get('options', [])
                    break

            super(NewEventForm, self).prepare()
Esempio n. 9
0
def create_user_form(user):
    profile_form = getattr(user, 'profile_form', None)
    if not profile_form:
        user_data, user_avatar = get_user_data(user)
        profile_form = UserForm()
        profile_form.child = profile_form.child()

        profile_form.child.children.append(
            ImageField(id='avatar', name="avatar", initial_src=user_avatar))

        for name, info in user_data.items():
            profile_form.child.children.append(
                TextField(id=name, validator=Required, label=info[0]))

        profile_form = profile_form()
    return profile_form
Esempio n. 10
0
    class child(twf.TableLayout):
        inline_engine_name = 'kajiki'
        template = '''

                    <div  style="padding-top:20px">

                            <div class="col-md-12 ks-section-name">
                                Recover password
                                <hr/>
                            </div>
                            <div class="form-group col-md-4">

                                ${w.children.email_address.display()}
                             <span class="help-block" py:content="w.children.email_address.error_msg"/>
                            </div>
                     </div>
                '''
        email_address = TextField(label=l_('Email address'), validator=RegisteredUserValidator(required=True), css_class="form-control",placeholder=l_('Email address'))
Esempio n. 11
0
class EditUserAddressForm(ListForm):
    address_id = HiddenField()
    receiver = TextField(label=l_('Receiver'), validator=Validator(required=True), css_class='form-control',
                         container_attrs={'class': 'form-group'})
    address = TextArea(label=l_('Address'), validator=Validator(required=True), css_class='form-control',
                       container_attrs={'class': 'form-group'})
    city = TextField(label=l_('City'), validator=Validator(required=True), css_class='form-control',
                     container_attrs={'class': 'form-group'})
    province = TextField(label=l_('Province'), validator=Validator(required=True), css_class='form-control',
                         container_attrs={'class': 'form-group'})
    state = TextField(label=l_('State'), validator=Validator(required=True), css_class='form-control',
                      container_attrs={'class': 'form-group'})
    zip = TextField(label=l_('Zip Code'), validator=Validator(required=True), css_class='form-control',
                        container_attrs={'class': 'form-group'})
    country = TextField(label=l_('Country'), validator=Validator(required=True), css_class='form-control',
                        container_attrs={'class': 'form-group'})
    details = TextField(label=l_('Details'), validator=Validator(required=True), css_class='form-control',
                        container_attrs={'class': 'form-group'})

    submit = SubmitButton(value=l_('Save'), css_class='btn btn-default')
Esempio n. 12
0
class NewUserAddressForm(ListForm):
    receiver = TextField(label=l_('Receiver'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    address = TextArea(label=l_('Address'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    city = TextField(label=l_('City'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    province = TextField(label=l_('Province'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    state = TextField(label=l_('State'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    zip = TextField(label=l_('Zip Code'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    country = TextField(label=l_('Country'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    details = TextField(label=l_('Details'), validator=Validator(required=True), css_class='form-control',
                    container_attrs={'class': 'form-group'})
    image = FileField(label=l_('Image'),
                            css_class='form-control', container_attrs={'class': 'form-group', 'accept': 'image/*'})
    submit = SubmitButton(value=l_('Create'), css_class='btn btn-default')
Esempio n. 13
0
class PhoneNumberForm(TableForm):
    country_code = SingleSelectField(validator=Required)
    phone_number = TextField(validator=UniquePhoneNumberValidator(
        not_empty=True))
Esempio n. 14
0
 class BogusUserForm(FormBase):
     __entity__ = User
     field = TextField()
Esempio n. 15
0
try:
    unicode('test Python2')
except Exception:  # pragma: no cover
    unicode = str


def slice_dataframe(df, fields):
    """Returns a subset of the columns from the DataFrame"""
    return df[list(fields)]


slice_dataframe.form_fields = [
    TextField('fields',
              label=l_('Fields'),
              validator=CommaSeparatedListValidator(required=True),
              value='{{.options.fields}}',
              placeholder='comma separated fields (name, surname, age)')
]


def group(df, aggregation, **kwargs):
    """Groups the data by one or more columns and applies an aggregation function"""
    g = df.groupby(as_index=bool(kwargs.pop('as_index', False)), **kwargs)
    return g.agg(aggregation)


group.form_fields = [
    TextField('by',
              label=l_('Group By'),
              validator=CommaSeparatedListValidator(required=True),
Esempio n. 16
0
 class UserView(ViewBase):
     __entity__ = User
     __metadata_type__ = DummyMetadata
     __field_widgets__ = {'password': TextField(id='password')}
Esempio n. 17
0
class ResetPasswordForm(TableForm):
    email_address = TextField(label=l_('Email address'),
                              validator=RegisteredUserValidator(required=True))
    submit = SubmitButton(value=l_('Send Request'))