Beispiel #1
0
    class child(BaseLayout):
        inline_engine_name = 'kajiki'

        template = '''

    <div py:strip="">
        <py:for each="c in w.children_hidden">
            ${c.display()}
        </py:for>

        <div class="form form-horizontal">
            <div class="form-group">
            <div class="mail-templates-title">Send Test Email</div>
                <div class="col-md-12">
                 <div py:with="c=w.children.email"
                         class="form-group ${c.error_msg and 'has-error' or ''}">
                        <label for="${c.compound_id}" class="col-md-2 control-label">${c.label}</label>
                        <div class="col-md-10">
                            ${c.display()}
                            <span class="help-block" py:content="c.error_msg"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    '''
        translation_id = HiddenField()
        language = HiddenField()
        body = HiddenField()
        subject = HiddenField()
        email = TextField(label='Recipient', css_class='form-control',
                          validator=twc.EmailValidator(not_empty=True))
Beispiel #2
0
    class child(BaseLayout):
        inline_engine_name = 'kajiki'

        template = '''

<div py:strip="">
    <py:for each="c in w.children_hidden">
        ${c.display()}
    </py:for>

    <div class="form form-horizontal">
        <div class="form-group">
        <div class="mail-templates-title">Edit mail translation</div>
            <div class="col-md-12">
                <div py:with="c=w.children.language"
                     class="form-group ${c.error_msg and 'has-error' or ''}">
                    <label for="${c.compound_id}" class="col-md-2 control-label">${c.label}</label>
                    <div class="col-md-2">
                        ${c.display()}
                        <span class="help-block" py:content="c.error_msg"/>
                    </div>
                    <span class="alert alert-danger" py:for="error in w.rollup_errors"> ${error}</span>
                </div>
                <div py:with="c=w.children.subject"
                     class="form-group ${c.error_msg and 'has-error' or ''}">
                    <label for="${c.compound_id}" class="col-md-2 control-label">${c.label}</label>
                    <div class="col-md-10">
                        ${c.display()}
                        <span class="help-block" py:content="c.error_msg"/>
                    </div>
                </div>
                <div py:with="c=w.children.body"
                     class="form-group ${c.error_msg and 'has-error' or ''}">
                    <label for="${c.compound_id}" class="col-md-2 control-label">${c.label}</label>
                    <div class="col-md-10">
                        ${c.display()}
                        <span class="help-block" py:content="c.error_msg"/>
                    </div>
                </div>

            </div>
        </div>

    </div>
     <input type="submit" class="btn btn-warning col-md-1 col-md-push-10" formaction="validate_template_edit" value="Validate"></input>
     <input type="submit" class="btn btn-default" formaction="test_email" value="Send test email"></input>
</div>
'''
        translation_id = HiddenField()
        model_id = HiddenField()
        language = TextField(label='Language', css_class='form-control',
                             validator=UnicodeString(not_empty=True, outputEncoding=None))
        subject = TextField(label='Subject', css_class='form-control',
                            validator=KajikiTextTemplateValidator())

        body = TextArea(label='Email content', rows=10, css_class='form-control',
                        validator=KajikiTemplateValidator())
Beispiel #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'))
Beispiel #4
0
class BuyProductForm(Form):
    child = CustomListLayout
    css_class = "form-horizontal"

    product = HiddenField(validator=Validator(required=True))

    quantity = SingleSelectField(label=l_("Quantity"), options=[],
                                 validator=IntValidator(min=1, required=True),
                                 container_attrs={'class': 'form-group'},
                                 label_attrs={'class': 'col-sm-12'},
                                 wrapper_attrs={'class': 'col-sm-4'},
                                 css_class="form-control -quantity")
    submit = None

    submit1 = SubmitButton(value=l_('Add to cart'), key='add_to_cart', name='action',
                          css_class='btn btn-block btn-success stroller2-buy-product-submit-button')
    submit2 = SubmitButton(value=l_('Buy now'), key='buy_now', name='action',
                           css_class='btn btn-block btn-success stroller2-buy-product-submit-button')

    def prepare(self):
        super(BuyProductForm, self).prepare()

        product_field = self.child.children.product
        quantity_field = self.child.children.quantity
        product = app_globals.shop.product.get(_id=product_field.value)
        opts = [({'value': c}, c) for c in range(1, product.configurations[0].qty + 1)]
        quantity_field.grouped_options = [(None, opts)]
Beispiel #5
0
class EditProductForm(ListForm):
    product_id = HiddenField()
    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_('Save'), css_class='btn btn-default')
Beispiel #6
0
    class child(BaseLayout):
        inline_engine_name = 'kajiki'

        template = '''

<div py:strip="">
    <py:for each="c in w.children_hidden">
        ${c.display()}
    </py:for>

    <div class="form form-horizontal">
        <div class="form-group">
        <div class="mail-templates-title">Edit model description</div>
            <div class="col-md-12">
             <div py:with="c=w.children.description"
                     class="form-group ${c.error_msg and 'has-error' or ''}">
                    <label for="${c.compound_id}" class="col-md-2 control-label">${c.label}</label>
                    <div class="col-md-10">
                        ${c.display()}
                        <span class="help-block" py:content="c.error_msg"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
'''
        model_id = HiddenField()
        description = TextArea(label='Description', css_class='form-control')
Beispiel #7
0
    class child(twf.TableLayout):
        inline_engine_name = 'kajiki'
        template = '''
         <div  style="padding-top:20px">
<py:for each="c in w.children_hidden">
                ${c.display()}
            </py:for>
                            <div class="col-md-12 ks-section-name">
                                Recover password
                                <hr/>
                            </div>
        <div class="row">
            <div class="form-group col-md-4">
                ${w.children.password.display()}
                <span class="help-block" py:content="w.children.password.error_msg"/>
            </div>
        </div>
        <div class="row">
            <div class="form-group col-md-4">
                ${w.children.password_confirm.display()}
                <span class="help-block" py:content="w.children.password_confirm.error_msg"/>
        </div>
        </div>
        </div>

                '''
        data = HiddenField()
        password = PasswordField(label=l_('New password'), validator=Validator(required=True), css_class='form-control', placeholder=l_('New password'))
        password_confirm = PasswordField(label=l_('Confirm new password'), validator=Validator(required=True), css_class='form-control', placeholder=l_('Confirm password'))
        validator = FieldsMatch('password', 'password_confirm')
Beispiel #8
0
class NewPasswordForm(TableForm):
    data = HiddenField()
    password = PasswordField(label=l_('New password'),
                             validator=Validator(required=True))
    password_confirm = PasswordField(label=l_('Confirm new password'),
                                     validator=Validator(required=True))
    validator = FieldsMatch('password', 'password_confirm')
    submit = SubmitButton(value=l_('Save new password'))
Beispiel #9
0
    def __create_hidden_fields(self):
        fields = {}
        fields['sprox_id'] = HiddenField(id='sprox_id')

        for field_name in self.__hide_fields__:
            if field_name not in self.__omit_fields__:
                args = {}
                try:
                    field = self.__metadata__[field_name]
                    args = self._do_get_field_widget_args(field_name, field)
                except KeyError:  #pragma: no cover
                    pass
                if field_name in self.__field_widget_args__:
                    args.update(self.__field_widget_args__[field_name])
                fields[field_name] = HiddenField(**args)

        return fields
Beispiel #10
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()
Beispiel #11
0
class EditCategoryForm(ListForm):
    category_id = HiddenField()
    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_('Save'), css_class='btn btn-default')
Beispiel #12
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')
Beispiel #13
0
    def _do_get_field_widgets(self, fields):

        metadata_keys = list(self.__metadata__.keys())
        widgets = {}
        for field_name in fields:
            if field_name in self.__field_widgets__:
                widgets[field_name] = self.__field_widgets__[field_name]
                continue
            if field_name in self.__add_fields__:
                widget = self.__add_fields__[field_name]
                if widget is None:
                    widget = Widget(field_name)
                widgets[field_name] = widget
                continue
            if field_name in self.__ignore_field_names__:
                continue
            if field_name in self.__hide_fields__:
                continue
            if field_name not in metadata_keys:
                continue

            field = self.__metadata__[field_name]
            field_widget_type = self._do_get_field_widget_type(
                field_name, field)
            field_widget_args = self._do_get_field_widget_args(
                field_name, field)

            if field_name in self._do_get_disabled_fields():
                # in this case, we display the current field, disabling it, and also add
                # a hidden field into th emix
                field_widget_args['disabled'] = True
                field_widget_args['attrs'] = {'disabled': True}

                if hasattr(Widget, 'req'):
                    hidden_id = 'disabled_' + field_name.replace('.', '_')
                else:  #pragma: no cover
                    hidden_id = field_name.replace('.', '_')

                widgets[field_name] = (HiddenField(id=hidden_id,
                                                   key=field_name,
                                                   name=field_name,
                                                   identifier=field_name),
                                       field_widget_type(**field_widget_args))
            else:
                widgets[field_name] = field_widget_type(**field_widget_args)

        widgets.update(self.__create_hidden_fields())
        return widgets
Beispiel #14
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')
Beispiel #15
0
    def _do_get_field_widget(self, field_name, field):
        field_widget_type = self._do_get_field_widget_type(field_name, field)
        field_widget_args = self._do_get_field_widget_args(field_name, field)

        if field_name in self._do_get_disabled_fields():
            # in this case, we display the current field, disabling it, and also add
            # a hidden field into th emix
            field_widget_args['disabled'] = True
            field_widget_args['attrs'] = {'disabled': True}

            if hasattr(Widget, 'req'):
                hidden_id = 'disabled_' + field_name.replace('.', '_')
            else:  #pragma: no cover
                hidden_id = field_name.replace('.', '_')

            return (HiddenField(id=hidden_id,
                                key=field_name,
                                name=field_name,
                                identifier=field_name),
                    field_widget_type(**field_widget_args))
        else:
            return field_widget_type(**field_widget_args)
Beispiel #16
0
 def _do_get_field_widgets(self, fields):
     widgets = super(FormBase, self)._do_get_field_widgets(fields)
     widgets['sprox_id'] = HiddenField('sprox_id', validator=String(if_missing=None))
     return widgets
Beispiel #17
0
class UserForm(ListForm):
    nothing = HiddenField()  # just to create children
    submit = SubmitButton(value=l_('Save'))