Пример #1
0
class ShippingWay_Configure(AutoForm):

    access = 'is_allowed_to_edit'
    title = MSG(u'Edit')

    schema = delivery_schema

    context_menus = [EditLanguageMenu()]

    widgets = [
        TextWidget('title', title=MSG(u'Title')),
        ImageSelectorWidget('logo', title=MSG(u'Logo')),
        MultilineWidget('description', title=MSG(u'Description')),
        BooleanRadio('enabled', title=MSG(u'Enabled ?')),
        SelectWidget('mode', title=MSG(u'Mode ?'), has_empty_option=False),
        TextWidget('insurance', title=MSG(u'Insurance %')),
        BooleanRadio('is_free', title=MSG(u'Shipping way is free ?')),
        SelectWidget('only_this_models',
                     title=MSG(u'Only for this products models')),
        SelectWidget('only_this_groups',
                     title=MSG(u'Only for this user groups')),
    ]

    def get_value(self, resource, context, name, datatype):
        language = resource.get_content_language(context)
        return resource.get_property(name, language)

    def action(self, resource, context, form):
        language = resource.get_content_language(context)
        for key in self.schema.keys():
            if key in ['title', 'description']:
                resource.set_property(key, form[key], language)
            else:
                resource.set_property(key, form[key])
        return context.come_back(messages.MSG_CHANGES_SAVED)
Пример #2
0
class Addresses_Search(SearchTable_View):

    access = 'is_admin'

    search_schema = {
        'user': String,
        'firstname': Unicode,
        'lastname': Unicode,
        'zipcode': String,
        'town': Unicode,
        'country': CountriesEnumerate
    }

    search_widgets = [
        TextWidget('user', title=MSG(u'Id user')),
        TextWidget('firstname', title=MSG(u'Firstname')),
        TextWidget('lastname', title=MSG(u'Lastname')),
        TextWidget('zipcode', title=MSG(u'Zipcode')),
        TextWidget('town', title=MSG(u'Town')),
        SelectWidget('country', title=MSG(u'Country'))
    ]

    def get_table_columns(self, resource, context):
        return (SearchTable_View.get_table_columns(self, resource, context) +
                [('user', MSG(u'Id user'))])

    def get_item_value(self, resource, context, item, column):
        if column == 'user':
            handler = resource.handler
            value = handler.get_record_value(item, column)
            return value, '/users/%s' % value
        return SearchTable_View.get_item_value(self, resource, context, item,
                                               column)
Пример #3
0
    def get_widgets(self, resource, context):
        cgu_description = MSG(u"I'm agree with the conditions general of use")
        if context.query['abspath']:
            # on review module
            review_module = resource
        else:
            # on product review
            review_module = get_module(resource, ShopModule_Review.class_id)

        cgu = review_module.get_resource('cgu')
        cgu_link = context.get_link(cgu)
        return [
            HiddenWidget('abspath', title=None),
            TextWidget('title', title=MSG(u'Review title')),
            NoteWidget('note', title=MSG(u'Note'), has_empty_option=False),
            MultilineWidget('description', title=MSG(u'Your review')),
            TextWidget('advantages', title=MSG(u'Advantages')),
            TextWidget('disadvantages', title=MSG(u'Disadvantages')),
            FileWidget('images', title=MSG(u'Images')),
            SelectRadio('recommended',
                        title=MSG(u'Recommendation'),
                        has_empty_option=False,
                        is_inline=True),
            BooleanCheckBox_CGU('cgu',
                                title=MSG(u'Conditions of use'),
                                link=cgu_link,
                                description=cgu_description)
        ]
Пример #4
0
class Payments_AddPayment(AutoForm):

    access = 'is_admin'
    title = MSG(u'Add a new payment')

    schema = {
        'payment_way': PaymentWaysEnumerate(mandatory=True),
        'ref': String(mandatory=True),
        'user': String,
        'state': Boolean,
        'amount': Decimal(mandatory=True),
        'description': Unicode
    }

    widgets = [
        SelectWidget('payment_way', title=MSG(u'Payment way')),
        TextWidget('ref', title=MSG(u'Reference')),
        TextWidget('user', title=MSG(u'User Id')),
        BooleanCheckBox('state', title=MSG(u'Payed ?')),
        TextWidget('amount', title=MSG(u'Amount')),
        MultilineWidget('description', title=MSG(u'Description')),
    ]

    def action(self, resource, context, form):
        root = context.root
        if root.get_resource('users/%s' % form['user'], soft=True) is None:
            context.message = ERROR(u'User do not exist')
            return
        shop = get_shop(resource)
        payments_table = shop.get_resource('payments/%s/payments' %
                                           form['payment_way']).handler
        del form['payment_way']
        payments_table.add_record(form)
        return context.come_back(MSG(u'New payment added !'), goto='./')
Пример #5
0
class ShopModule_ProductImagesSlider(ShopModule):

    class_id = 'shop_module_product_images_slider'
    class_title = MSG(u'Product images slider')
    class_views = ['edit']
    class_description = MSG(u'Product images slider')

    item_schema = {'big_img_width': Integer(default=500),
                   'big_img_height': Integer(default=600),
                   'thumb_img_width': Integer(default=90),
                   'thumb_img_height': Integer(default=90),
                   'show_cover': Boolean,
                   'show_loupe': Boolean,
                   'change_img_on_hover': Boolean,
                   'activate_lightbox': Boolean}

    item_widgets = [
      TextWidget('big_img_width', title=MSG(u'Width of big image')),
      TextWidget('big_img_height', title=MSG(u'Height of big image')),
      TextWidget('thumb_img_width', title=MSG(u'Width of thumb image')),
      TextWidget('thumb_img_height', title=MSG(u'Height of thumb image')),
      BooleanRadio('show_cover', title=MSG(u'Show cover ?')),
      BooleanRadio('show_loupe', title=MSG(u'Show loupe ?')),
      BooleanRadio('change_img_on_hover', title=MSG(u'Change img on hover ?')),
      BooleanRadio('activate_lightbox', title=MSG(u'Activate lightbox ?')),
      ]


    def render(self, resource, context):
        return ShopModule_ProductImagesSlider_View().GET(self, context)
Пример #6
0
class ShopModule_FacebookLike(ShopModule):

    class_id = 'shop_module_facebook_like'
    class_title = MSG(u'Facebook like')
    class_views = ['edit']
    class_description = MSG(u'Facebook like')

    item_schema = {
        'layout': Layout,
        'the_action': Action,
        'width': Integer,
        'height': Integer,
        'colorscheme': ColorScheme,
        'show_faces': Boolean
    }

    item_widgets = [
        SelectWidget('layout', title=MSG(u'Layout'), has_empty_option=False),
        SelectWidget('the_action',
                     title=MSG(u'Action'),
                     has_empty_option=False),
        SelectWidget('colorscheme',
                     title=MSG(u'Color Scheme'),
                     has_empty_option=False),
        TextWidget('width', title=MSG(u'Width (px)')),
        TextWidget('height', title=MSG(u'Height (px)')),
        BooleanRadio('show_faces', title=MSG(u'Show faces ?'))
    ]

    def render(self, resource, context):
        return ShopModule_FacebookLike_View().GET(self, context)
Пример #7
0
class ShippingWayTable(Table):

    class_id = 'shipping-way-table'
    class_handler = ShippingWayBaseTable

    form = [
        TextWidget('ref', title=MSG(u'Facture number')),
        SelectWidget('state', title=MSG(u'State')),
        TextWidget('price', title=MSG(u'Price')),
        TextWidget('weight', title=MSG(u'Weight')),
        TextWidget('number', title=MSG(u'Numéro')),
        TextWidget('description', title=MSG(u'Description')),
        ]

    def get_record_namespace(self, context, record):
        namespace = {}
        # Id
        namespace['id'] = record.id
        namespace['shipping_mode'] = self.parent.get_title()
        # Complete id
        namespace['complete_id'] = '%s-%s' % (self.parent.name, record.id)
        # Base namespace
        for key in self.handler.record_properties.keys():
            namespace[key] = self.handler.get_record_value(record, key)
        # State
        namespace['state'] = ShippingStates.get_value(namespace['state'])
        # Timestamp
        accept = context.accept_language
        value = self.handler.get_record_value(record, 'ts')
        namespace['ts'] = format_datetime(value,  accept)
        return namespace
Пример #8
0
class Supplier(Folder):

    class_id = 'supplier'
    class_title = MSG(u'Supplier')
    class_views = ['edit']

    edit = AutomaticEditView()
    add_image = CurrentFolder_AddImage()

    # Edit views
    edit_schema = {
        'address': Unicode(mandatory=True),
        'phone': String,
        'fax': String,
        'email': Email,
        'description': Unicode(multilingual=True)
    }

    edit_widgets = [
        MultilineWidget('address', title=MSG(u'Address')),
        TextWidget('phone', title=MSG(u'Phone')),
        TextWidget('fax', title=MSG(u'Fax')),
        TextWidget('email', title=MSG(u'Email')),
        MultilineWidget('description', title=MSG(u'Description'))
    ]

    @classmethod
    def get_metadata_schema(cls):
        return merge_dicts(Folder.get_metadata_schema(), cls.edit_schema)
Пример #9
0
class CrossSelling_Configure(ImprovedAutoForm):

    access = 'is_allowed_to_edit'
    title = MSG(u'Configure cross selling')

    shop_configuration = BooleanRadio('use_shop_configuration',
                                      title=MSG(u'Use shop configuration'))

    actions = [
        Button(access='is_allowed_to_edit',
               name='configure',
               title=MSG(u'Configure'))
    ]

    widgets = [
        BooleanRadio('enabled', title=MSG(u'Enabled')),
        TextWidget('products_quantity',
                   title=MSG(u'Numbers of products'),
                   size=3),
        CrossSelling_Widget('widget', title=MSG(u'Table')),
        TextWidget(
            'filter_text',
            title=MSG(u'Extend with products that contains this title')),
        SelectRadio('categories',
                    title=MSG(u'Extend with products from categories...'),
                    has_empty_option=False),
        SelectRadio('show_product_with_promotion',
                    title=MSG(u'Extend with promotion ?'),
                    is_inline=True,
                    has_empty_option=False),
        SelectWidget('product_model', title=MSG(u'Product Model')),
        DualSelectWidget('tags',
                         title=MSG(u'Extend products associated to this tags'),
                         is_inline=True,
                         has_empty_option=False),
        SelectWidget('sort', title=MSG(u'Selection'), has_empty_option=False),
    ]

    def get_schema(self, resource, context):
        site_root = resource.get_site_root()
        return merge_dicts(cross_selling_schema,
                           tags=TagsList(site_root=site_root, multiple=True))

    def get_widgets(self, resource, context):
        if get_shop(resource) == resource.parent:
            return self.widgets
        return [self.shop_configuration] + self.widgets

    def get_value(self, resource, context, name, datatype):
        return resource.get_property(name)

    def action_configure(self, resource, context, form):
        for key in self.get_schema(resource, context).keys():
            resource.set_property(key, form[key])
        return context.come_back(messages.MSG_CHANGES_SAVED)
Пример #10
0
class CreditAvailable_Table(Table):

    class_id = 'credit-available-table'
    class_handler = CreditAvailable_Basetable
    class_views = ['view', 'back']

    back = GoToSpecificDocument(specific_document='..',
                                title=MSG(u'Back'))

    form = [SelectWidget('user', title=MSG(u'User id')),
            TextWidget('amount', title=MSG(u'Credit amount')),
            TextWidget('description', title=MSG(u'Description'))]
Пример #11
0
class Product_SendToFriend(AutoForm):

    access = True
    title = MSG(u'Send to a friend')
    submit_value = MSG(u'Send to my friend')

    meta = [('robots', 'noindex, follow', None)]

    schema = {
        'widget': String, # XXX not used
        'my_email': Email(mandatory=True),
        'my_name': Unicode(mandatory=True),
        'email': Email(mandatory=True),
        'message': Unicode}

    widgets = [MiniProductWidget('widget', title=MSG(u"Product")),
               TextWidget('my_email', title=MSG(u"Your email")),
               TextWidget('my_name', title=MSG(u"Your name")),
               TextWidget('email', title=MSG(u"Email of your friend")),
               MultilineWidget('message',
                title=MSG(u"You can write a message for your friend"))]

    mail_subject = MSG(u"{my_name} advice you this product: {product_title}")
    mail_body = MSG(u"Your friend {my_name} advice you this product: \n\n"
                    u" {product_title}\n\n"
                    u"All details are here:\n\n"
                    u" {product_uri}\n\n"
                    u" {message}\n\n")


    def get_value(self, resource, context, name, datatype):
        if context.user:
            if name == 'my_email':
                return context.user.get_property('email')
            elif name == 'my_name':
                return context.user.get_title()
        return AutoForm.get_value(self, resource, context, name,
                 datatype)



    def action(self, resource, context, form):
        kw = {'product_uri': context.uri.resolve('./'),
              'product_title': resource.get_title(),
              'message': form['message'],
              'my_name': form['my_name']}
        subject = self.mail_subject.gettext(**kw)
        body = self.mail_body.gettext(**kw)
        context.root.send_email(form['email'], subject,
              from_addr=form['my_email'], text=body)

        msg = u'An email has been send to your friend'
        return context.come_back(MSG(msg), goto='./')
Пример #12
0
class TransferPayment_Configure(PaymentWay_Configure):

    title = MSG(u'Configure')
    access = 'is_admin'

    schema = merge_dicts(PaymentWay_Configure.schema,
                         RIB=RIB(mandatory=True),
                         IBAN=IBAN(mandatory=True))

    widgets = PaymentWay_Configure.widgets + [
        TextWidget('RIB', title=MSG(u'RIB')),
        TextWidget('IBAN', title=MSG(u'IBAN'))
    ]
Пример #13
0
class EnumerateTableColor(EnumerateTable):

    class_id = 'enumerate-table-color'
    class_title = MSG(u'Enumerate Table Color')
    class_handler = EnumerateTableColor_Handler

    widget_cls = SelectRadioColor
    additional_enumerate_keys = ['color']

    form = [
        HiddenWidget('name', None),
        TextWidget('title', title=MSG(u'Title')),
        TextWidget('color', title=MSG(u'Color')),
    ]
Пример #14
0
class ShopModule_GoogleAnalytics(ShopModule):

    class_id = 'shop_module_google_analytics'
    class_title = MSG(u'Google analytics')
    class_views = ['edit']
    class_description = MSG(u'Google analytics tracker')

    item_schema = {'tracking_id': String, 'table_id': String}
    item_widgets = [
        TextWidget('tracking_id', title=MSG(u'Tracking id')),
        TextWidget('table_id', title=MSG(u'Table id'))
    ]

    def render(self, resource, context):
        return ShopModule_GoogleAnalytics_View().GET(self, context)
Пример #15
0
class Shippings_Configure(AutoForm):

    access = 'is_admin'
    title = MSG(u'Configure')
    context_menus = [EditLanguageMenu()]

    schema = shippings_schema

    widgets = [
        TextWidget('default_shipping_way_title',
                   title=MSG(u'Default shipping way title')),
        ImageSelectorWidget('default_shipping_way_logo',
                            title=MSG(u'Default shipping way logo')),
        MultilineWidget('default_shipping_way_description',
                        title=MSG(u'Default shipping way description')),
        RTEWidget('msg_if_no_shipping',
                  title=MSG(u'Message if no shipping available')),
    ]

    def get_value(self, resource, context, name, datatype):
        language = resource.get_content_language(context)
        return resource.get_property(name, language) or datatype.get_default()

    def action(self, resource, context, form):
        language = resource.get_content_language(context)
        for key, datatype in self.get_schema(resource, context).items():
            if getattr(datatype, 'multilingual', False):
                resource.set_property(key, form[key], language)
            else:
                resource.set_property(key, form[key])
        return context.come_back(messages.MSG_CHANGES_SAVED)
Пример #16
0
class CreditPayment_View(AutoForm):

    access = 'is_admin'
    title = MSG(u'Add a voucher')

    schema = {
        'user': Users_Enumerate,
        'amount': Decimal,
        'description': Unicode
    }

    widgets = [
        SelectWidget('user', title=MSG(u'User')),
        TextWidget('amount', title=MSG(u'Amount (€)')),
        MultilineWidget('description', title=MSG(u'Description'))
    ]

    def action(self, resource, context, form):
        users_credit = resource.get_resource('users-credit').handler
        users_credit.add_record({
            'user': form['user'],
            'amount': form['amount'],
            'description': form['description']
        })
        msg = MSG(u'Voucher has been added !')
        return context.come_back(msg, goto='../')
Пример #17
0
class Messages_TableResource(Table):

    class_id = 'shop-order-messages'
    class_title = MSG(u'Messages')
    class_handler = Messages_TableHandler
    class_version = '20091126'

    form = [TextWidget('author', title=MSG(u'Author')),
            MultilineWidget('message', title=MSG(u'Message')),
            BooleanCheckBox('private', title=MSG(u'Private ?')),
            BooleanCheckBox('seen', title=MSG(u'Seen ?'))]

    def get_namespace_messages(self, context):
        messages = []
        get_value = self.handler.get_record_value
        for record in self.handler.get_records():
            author = get_value(record, 'author')
            author = context.root.get_resource('/users/%s' % author)
            ts = get_value(record, 'ts')
            message = get_value(record, 'message').replace('\n', '<br/>')
            messages.append({'id': record.id,
                             'author': author.get_title(),
                             'message': XMLParser(message.encode('utf-8')),
                             'private': get_value(record, 'private'),
                             'seen': get_value(record, 'seen'),
                             'ts': format_datetime(ts, context.accept_language)})
        return messages
Пример #18
0
class CountriesZones(OrderedTable):

    class_id = 'countries-zones'
    class_title = MSG(u'Countries Zones')
    class_handler = BaseCountriesZones
    class_views = ['view', 'add_record']
    class_version = '20090923'

    view = CountriesZones_View()
    add_record = Table_AddRecord(title=MSG(u'Add a new zone'))

    form = [
        TextWidget('title', title=MSG(u'Country title')),
        BooleanRadio('has_tax', title=MSG(u'Has TAX ?'))
    ]

    @staticmethod
    def _make_resource(cls, folder, name, *args, **kw):
        OrderedTable._make_resource(cls, folder, name)
        table = BaseCountriesZones()
        zones = []
        csv = ro_database.get_handler(get_abspath('data/countries.csv'),
                                      CSVFile)
        for line in csv.get_rows():
            zone = unicode(line[1], 'utf-8')
            if zone not in zones:
                zones.append(zone)
                table.add_record({'title': Property(zone, language='fr')})
        folder.set_handler(name, table)
Пример #19
0
class PaymentWay_Configure(DBResource_Edit):

    access = 'is_admin'

    schema = {
        'title': Unicode(mandatory=True, multilingual=True),
        'logo': ImagePathDataType(mandatory=True, multilingual=True),
        'data': XHTMLBody(mandatory=True, multilingual=True),
        'only_this_groups': UserGroup_Enumerate(multiple=True),
        'enabled': Boolean(mandatory=True)
    }

    widgets = [
        TextWidget('title', title=MSG(u'Title')),
        ImageSelectorWidget('logo', title=MSG(u'Logo')),
        BooleanRadio('enabled', title=MSG(u'Enabled ?')),
        RTEWidget('data', title=MSG(u"Description")),
        SelectWidget('only_this_groups', title=MSG(u"Only for this groups"))
    ]

    submit_value = MSG(u'Edit configuration')

    def get_value(self, resource, context, name, datatype):
        language = resource.get_content_language(context)
        return resource.get_property(name, language=language)

    def action(self, resource, context, form):
        language = resource.get_content_language(context)
        for key, datatype in self.schema.items():
            if getattr(datatype, 'multilingual', False):
                resource.set_property(key, form[key], language=language)
            else:
                resource.set_property(key, form[key])
        return context.come_back(messages.MSG_CHANGES_SAVED, goto='./')
Пример #20
0
class ProductModel_Configure(AutoForm):

    access = 'is_allowed_to_edit'

    title = MSG(u'Configure')

    schema = {
        'title': Unicode,
        'declinations_enumerates': Enumerate_ListEnumerateTable(multiple=True)
    }

    widgets = [
        TextWidget('title', title=MSG(u'Title')),
        DualSelectWidget('declinations_enumerates',
                         title=MSG(u'Declinations activated'))
    ]

    def get_value(self, resource, context, name, datatype):
        return resource.get_property(name)

    def action(self, resource, context, form):
        language = resource.get_content_language(context)
        language = None  # XXX Sylvain
        for key in self.schema:
            resource.set_property(key, form[key], language=language)
        context.message = messages.MSG_CHANGES_SAVED
Пример #21
0
class ColissimoTable(ShippingWayTable):

    class_id = 'colissimo-table'
    class_title = MSG(u'Colissimo')
    class_handler = ColissimoBaseTable

    form = ShippingWayTable.form + [
        TextWidget('num_colissimo', title=MSG(u'Numéro de colissimo')) ]
Пример #22
0
class ShopModule_Opengraph(ShopModule):

    class_id = 'shop_module_opengraph'
    class_title = MSG(u'OpenGraph')
    class_views = ['edit']
    class_description = MSG(u'OpenGraph')

    item_schema = {'website_title': Unicode, 'fb_admins': String}

    item_widgets = [
        TextWidget('website_title', title=MSG(u'Website title')),
        TextWidget('fb_admins', title=MSG(u'FB admis id'))
    ]

    def render(self, resource, context):
        # Url
        url = context.view.get_canonical_uri(context)
        # Thumbnail
        thumb = None
        if hasattr(context.resource, 'get_preview_thumbnail'):
            thumb = context.resource.get_preview_thumbnail()
            if thumb:
                thumb = '%s%s/;download' % (context.uri.resolve('/'),
                                            context.get_link(thumb))
        return [{
            'property': 'og:title',
            'content': resource.get_title()
        }, {
            'property': 'og:description',
            'content': resource.get_property('description')
        }, {
            'property': 'og:image',
            'content': thumb
        }, {
            'property': 'og:type',
            'content': 'product'
        }, {
            'property': 'og:url',
            'content': url
        }, {
            'property': 'og:site_name',
            'content': self.get_property('website_title')
        }, {
            'property': 'fb:admins',
            'content': self.get_property('fb_admins')
        }]
Пример #23
0
class PaymentWayTable(Table):

    class_id = 'payment-table'
    class_handler = PaymentWayBaseTable
    class_views = ['view']

    form = [
        TextWidget('ref', title=MSG(u'Payment number')),
        TextWidget('user', title=MSG(u'User id')),
        BooleanCheckBox('state', title=MSG(u'State')),
        TextWidget('amount', title=MSG(u'Amount')),
        TextWidget('resource_validator', title=MSG(u'Resource validator')),
        TextWidget('description', title=MSG(u'Description'))]

    # Views
    add_record = None
    edit_record = None


    def get_record_namespace(self, context, record):
        get_value = self.handler.get_record_value
        namespace = {'id': record.id,
                     'complete_id': '%s-%s' % (self.parent.name, record.id),
                     'payment_mode': self.parent.name}
        # Base namespace
        for key in self.handler.record_properties.keys():
            namespace[key] = get_value(record, key)
        # Amount
        amount = get_value(record, 'amount')
        namespace['amount'] = format_price(amount)
        # User
        users = context.root.get_resource('users')
        username = get_value(record, 'user') or '0'
        user = users.get_resource(username)
        namespace['username'] = username
        namespace['user_title'] = user.get_title()
        namespace['user_email'] = user.get_property('email')
        # State
        namespace['advance_state'] = None
        # Timestamp
        accept = context.accept_language
        value = self.handler.get_record_value(record, 'ts')
        namespace['ts'] = format_datetime(value,  accept)
        return namespace
Пример #24
0
class Paybox_Configure(PaymentWay_Configure):

    title = MSG(u'Configure Paybox')

    schema = merge_dicts(PaymentWay_Configure.schema,
                         PBX_SITE=StringFixSize(size=7),
                         PBX_RANG=StringFixSize(size=2),
                         PBX_IDENTIFIANT=String,
                         PBX_DIFF=StringFixSize(size=2),
                         real_mode=Boolean)


    widgets = PaymentWay_Configure.widgets + [
        TextWidget('PBX_SITE', title=MSG(u'Paybox Site')),
        TextWidget('PBX_RANG', title=MSG(u'Paybox Rang')),
        TextWidget('PBX_IDENTIFIANT', title=MSG(u'Paybox Identifiant')),
        TextWidget('PBX_DIFF', title=MSG(u'Diff days (On two digits ex: 04)'),
                   size=2),
        BooleanRadio('real_mode', title=MSG(u'Payments in real mode'))]
Пример #25
0
class ShopForm(OrderedTable):

    class_id = 'shop-form'
    class_title = MSG(u'Shop form')
    class_version = '20090609'
    class_handler = ShopFormTable
    class_views = ['display', 'edit', 'view', 'add_record']

    display = ShopForm_Display()
    view = OrderedTable_View(search_template=None, access='is_admin')
    edit = AutomaticEditView()

    add_product = AddProduct_View()

    form = [
        TextWidget('name', title=MSG(u'Name')),
        TextWidget('title', title=MSG(u'Title')),
        BooleanCheckBox('mandatory', title=MSG(u'Mandatory')),
        BooleanCheckBox('multiple', title=MSG(u'Multiple')),
        SelectWidget('datatype', title=MSG(u'Data Type')),
        SelectWidget('widget', title=MSG(u'Widget')),
    ]

    edit_widgets = [
        TextWidget('submit_value', title=MSG(u'Submit value')),
        TextWidget('to_addr', title=MSG(u'To addr')),
        RTEWidget('introduction', title=MSG(u'Introduction')),
        RTEWidget('final_message', title=MSG(u'Final message')),
        BooleanRadio('must_be_authentificated',
                     title=MSG(u'Must be authentificated to see form'))
    ]

    edit_schema = {
        'submit_value': Unicode(multilingual=True, mandatory=True),
        'to_addr': Email(mandatory=True),
        'introduction': XHTMLBody(multilingual=True),
        'final_message': XHTMLBody(multilingual=True),
        'must_be_authentificated': Boolean
    }

    @classmethod
    def get_metadata_schema(cls):
        return merge_dicts(OrderedTable.get_metadata_schema(), cls.edit_schema)
Пример #26
0
class Shop_UserSendConfirmation(ImproveAutoForm):

    access = True
    title = MSG(u'Request your registration key')

    actions = [Button(access='is_allowed_to_edit',
                      name='send_registration_key',
                      title=MSG(u'Receive your key'))]
    schema = {'email': Email(mandatory=True)}
    widgets = [TextWidget('email', title=MSG(u'Your email address'))]

    def _get_user(self, resource, context, email):
        results = context.root.search(username=email)
        if len(results) == 0:
            return None
        user = results.get_documents()[0]
        user = resource.get_resource('/users/%s' % user.name)
        return user


    def get_namespace(self, resource, context):
        proxy = super(Shop_UserSendConfirmation, self)
        namespace = proxy.get_namespace(resource, context)

        confirm_msg = MSG(u"""Fill this form to receive a mail with the link
                              to activate your account""")
        namespace['required_msg'] = (list(XMLParser(confirm_msg.gettext().encode('utf8'))) +
                                     list(XMLParser('<br/>')) +
                                     list(namespace['required_msg']))
        return namespace


    def action_send_registration_key(self, resource, context, form):
        email = form['email']
        # Get the user with the given login name
        user = self._get_user(resource, context, email)
        if user is None:
            message = ERROR(u'There is no user identified as "{username}"',
                      username=email)
            return context.come_back(message,
                                     goto='./;confirm_registration')

        # Resend confirmation
        must_confirm = user.get_property('user_must_confirm')
        if not must_confirm:
            # Already confirmed
            message = ERROR(u'Your account has already been confirmed')
            return context.come_back(message, goto='/')

        # Ok
        user.send_confirmation(context, email)
        message = MSG(u'Your activation key has been sent to your mailbox')
        return context.come_back(message,
                                 goto='./;confirm_registration')
Пример #27
0
class ProductModelSchema(OrderedTable):

    class_id = 'product-model-schema'
    class_title = MSG(u'Model Schema')
    class_version = '20090609'
    class_handler = ProductTypeTable
    class_views = ['view', 'add_record']

    view = ProductModelSchema_View()
    add_record = ProductModelSchema_AddRecord()
    edit_record = ProductModelSchema_EditRecord()

    form = [
        TextWidget('name', title=MSG(u'Name')),
        TextWidget('title', title=MSG(u'Title')),
        BooleanCheckBox('mandatory', title=MSG(u'Mandatory')),
        BooleanCheckBox('multiple', title=MSG(u'Multiple')),
        BooleanCheckBox('multilingual', title=MSG(u'Multilingual')),
        BooleanCheckBox('visible', title=MSG(u'Visible')),
        SelectWidget('datatype', title=MSG(u'Data Type')),
    ]
Пример #28
0
class CheckPayment_Configure(PaymentWay_Configure):

    title = MSG(u'Configure checkpayment module')

    schema = merge_dicts(PaymentWay_Configure.schema,
                         to=Unicode(mandatory=True),
                         address=Unicode(mandatory=True))

    widgets = PaymentWay_Configure.widgets + [
        TextWidget('to', title=MSG(u"A l'ordre de")),
        MultilineWidget('address', title=MSG(u'Address'))
    ]
Пример #29
0
class CartBox(Box):

    class_id = 'vertical-item-cart-box'
    class_title = MSG(u'Boîte panier')
    view = CartBox_View()


    edit_schema = {'order_title': Unicode(multilingual=True),
                   'show_if_empty': Boolean}

    edit_widgets = [TextWidget('order_title', title=MSG(u'Order title')),
                    BooleanRadio('show_if_empty',
                                 title=MSG(u'Show cart if empty ?'))]
Пример #30
0
class ShippingPrices(Table):

    class_id = 'shipping-prices'
    class_title = MSG(u'Shipping Prices')
    class_handler = ShippingPricesTable

    class_views = ['view', 'add_record']

    form = [
        SelectWidget('zone', title=MSG(u'Zone')),
        TextWidget('price', title=MSG(u'Price'))]

    quantity_widget = TextWidget('max-quantity', title=MSG(u'Max quantity'))
    weight_widget = TextWidget('max-weight', title=MSG(u'Max Weight (Kg)'))

    def get_form(self):
        if self.parent.get_property('mode') == 'quantity':
            return self.form + [self.quantity_widget]
        return self.form + [self.weight_widget]

    view = SearchTable_View(search_widgets=[SelectWidget('zone', title=MSG(u'Zone'))],
                            search_schema={'zone': CountriesZonesEnumerate})