Exemplo n.º 1
0
 def _init_all_metadata(self):
     """Init new metadata (to avoid 'field is not indexed' warning)
     """
     has_changes = False
     metadata = self._metadata
     for name, field_cls in self._fields.items():
         if name not in metadata:
             print('[Catalog] New field registered: {0}'.format(name))
             has_changes = True
             metadata[name] = self._get_info(field_cls, name)
         else:
             # If the field was in the catalog but is newly stored
             if (not metadata[name].has_key('value') and
                 getattr(field_cls, 'stored', False)):
                 print('[Catalog] Indexed field is now stored: {0}'.format(name))
                 has_changes = True
                 metadata[name] = merge_dicts(
                     metadata[name],
                     self._get_info_stored())
             # If the field was stored in the catalog but is newly indexed
             if (not metadata[name].has_key('prefix') and
                 getattr(field_cls, 'indexed', False)):
                 print('[Catalog] Stored field is now indexed: {0}'.format(name))
                 has_changes = True
                 metadata[name] = merge_dicts(
                     metadata[name],
                     self._get_info_indexed())
     if has_changes:
         self._db.set_metadata('metadata', dumps(metadata))
         self._db.commit_transaction()
         self._db.begin_transaction(self.commit_each_transaction)
Exemplo n.º 2
0
class EnumerateTable_Details(BrowseForm):

    access = 'is_admin'

    query_schema = merge_dicts(BrowseForm.query_schema, {
        'option_name': String,
        'option_value': String
    })

    table_columns = [('title', MSG(u'Product that use that value'))]

    def get_items(self, resource, context, query=[]):
        option_name = context.query['option_name']
        option_value = context.query['option_value']
        query = OrQuery(
            PhraseQuery('DFT-%s' % option_name, option_value),
            PhraseQuery('DFT-DECL-%s' % option_name, option_value),
        )
        results = context.root.search(query)
        sort_by = context.query['sort_by']
        reverse = context.query['reverse']
        return results.get_documents(sort_by=sort_by, reverse=reverse)

    def sort_and_batch(self, resource, context, items):
        return items

    def get_item_value(self, resource, context, item, column):
        if column == 'title':
            r = context.root.get_resource(item.abspath)
            title = r.get_title()
            if r.class_id != 'product':
                title = u"%s »» %s" % (r.parent.get_title(), title)
            return title, context.get_link(r)
Exemplo n.º 3
0
class Deposit_Configure(PaymentWay_Configure):

    title = MSG(u'Configure deposite module')

    schema = merge_dicts(PaymentWay_Configure.schema, deposit_schema)

    widgets = PaymentWay_Configure.widgets + deposit_widgets
Exemplo n.º 4
0
 def _get_catalog_values(self):
     # Get the languages
     site_root = self.get_site_root()
     languages = site_root.get_property('website_languages')
     # Titles
     m_title = {}
     m_breadcrumb_title = {}
     for language in languages:
         value = self.get_property('title', language=language)
         if value:
             m_title[language] = value
         value = self.get_property('breadcrumb_title', language=language)
         if value:
             m_breadcrumb_title[language] = value
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     return merge_dicts(
         super(Category, self)._get_catalog_values(),
         data=data,
         # XXX Hack to be on sitemap
         workflow_state='public',
         m_title=m_title,
         m_breadcrumb_title=m_breadcrumb_title)
Exemplo n.º 5
0
class Paybox_End(PaymentWay_EndView):
    """The customer is redirect on this page after payment"""

    access = "is_authenticated"

    query_schema = merge_dicts(PaymentWay_EndView.query_schema,
                               state=Integer,
                               NUMERR=String)

    template = '/ui/backoffice/payments/paybox/end.xml'

    def get_namespace(self, resource, context):
        namespace = PaymentWay_EndView.get_namespace(self, resource, context)
        erreur = context.query['NUMERR']
        if erreur:
            # Send mail
            root = context.root
            server = context.server
            from_addr = server.smtp_from
            subject = u'Paybox problem'
            body = 'Paybox error: %s' % PayboxCGIErrors.get_value(erreur)
            root.send_email(from_addr, subject, from_addr, body)
        state = PBXState.get_value(context.query['state'])
        namespace['state'] = state.gettext()
        return namespace
Exemplo n.º 6
0
 def get_metadata_schema(cls):
     return merge_dicts(
         ShopFolder.get_metadata_schema(),
         data=XHTMLBody(multilingual=True),
         breadcrumb_title=Unicode(multilingual=True),
         image_category=ImagePathDataType(multilingual=True),
         default_product_cover=ImagePathDataType(multilingual=True))
Exemplo n.º 7
0
 def get_metadata_schema(cls):
     return merge_dicts(ShopFolder.get_metadata_schema(),
                        data=XHTMLBody(multilingual=True),
                        title=Unicode(multilingual=True),
                        enabled=Boolean(default=True),
                        only_this_groups=UserGroup_Enumerate(multiple=True),
                        logo=ImagePathDataType(multilingual=True))
Exemplo n.º 8
0
 def _get_catalog_values(self):
     # Get the languages
     site_root = self.get_site_root()
     languages = site_root.get_property('website_languages')
     # Titles
     m_title = {}
     m_breadcrumb_title = {}
     for language in languages:
         value = self.get_property('title', language=language)
         if value:
             m_title[language] = value
         value = self.get_property('breadcrumb_title', language=language)
         if value:
             m_breadcrumb_title[language] = value
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     return merge_dicts(
         super(Category, self)._get_catalog_values(),
         data=data,
         # XXX Hack to be on sitemap
         workflow_state='public',
         m_title=m_title,
         m_breadcrumb_title=m_breadcrumb_title)
Exemplo n.º 9
0
 def get_metadata_schema(cls):
     return merge_dicts(Diaporama.get_metadata_schema(),
         {'width': Integer(default=256),
         'height': Integer(default=256),
         'border': Unicode(default="#FF0000"),
         'show_border': Boolean(default=True),
         'show_title': Boolean(default=True),
         ## slideViewerPro options (defaults)
         # The border width around the main images 
         'galBorderWidth': Integer(default=6),
         # The distance that separates the thumbnails
         # and the buttons from the main images 
         'thumbsTopMargin': Integer(default=3),
         # The distance of each thumnail respect to the next one 
         'thumbsRightMargin': Integer(default=3),            
         # The border width of each thumbnail.
         # Note that the border in reality is above, not around 
         'thumbsBorderWidth': Integer(default=3),            
         # The width of the prev/next buttons that commands the thumbnails 
         'buttonsWidth': Integer(default=20),            
         # The border color around the main
         'galBorderColor': Unicode(default="#ff0000"),
         # The border color of the thumbnails but not the current one 
         'images thumbsBorderColor': Unicode(default="#d8d8d8"),
         # The border color of the current thumbnail 
         'thumbsActiveBorderColor': Unicode(default="#ff0000"),
         # The color of the optional text in leftButtonInner/rightButtonInner 
         'buttonsTextColor': Unicode(default="#ff0000"),
         # Could be 0, 0.1 up to 1.0
         'thumbsBorderOpacity': Decimal(default=1.0),
         # Could be 0, 0.1 up to 1.0 
         'thumbsActiveBorderOpacity': Decimal(default=1.0),
         # The time it takes a slide to move to its position 
         'easeTime': Integer(default=750),
         # If autoslide is true, this is the interval between each slide 
         'asTimer': Integer(default=4000),            
         # The number of visible thumbnails
         'thumbs': Integer(default=5),     
         # The percentual reduction of the thumbnails in relation to the original 
         'thumbsPercentReduction': Integer(default=12),
         # With this option set to false,
         # the whole UI (thumbs and buttons) are not visible
         'thumbsVis': Boolean(default=True),            
         # Could be an image "<img src='images/larw.gif' />" or an escaped
         # char as "&larr;" 
         'leftButtonInner': Unicode(default="-"),             
         # could be an image or an escaped char as "&rarr;"
         'rightButtonInner': Unicode(default="+"),            
         # By default the slider do not slides automatically.
         # When set to true REQUIRES the jquery.timers plugin 
         'autoslide': Boolean(default=False),
         # The typographic info of each slide.
         # When set to true, the ALT tag content is displayed 
         'typo': Boolean(default=False),             
         # The opacity for typographic info. 1 means fully visible. 
         'typoFullOpacity': Decimal(default=0.9),
         # The LI items can be shuffled (randomly mixed) when shuffle is true 
         'shuffle': Boolean(default=False)
         })
Exemplo n.º 10
0
 def _get_schema(self, resource, context):
     base_schema = DBResource_Edit._get_schema(self, resource, context)
     return freeze(merge_dicts(base_schema,
         display_title=Boolean, render=OpenLayerRender(mandatory=True),
         width=Integer, height=Integer, address=Unicode,
         latitude=Decimal, longitude=Decimal, zoom=Integer,
         # Hack
         gps=String))
Exemplo n.º 11
0
 def get_schema(self):
     record_properties = self.handler.record_properties
     # Hook html_content datatype
     datatype = record_properties.get("html_content", None)
     if datatype:
         sanitize = self.get_property("sanitize")
         return merge_dicts(record_properties, html_content=datatype(sanitize_html=sanitize))
     return record_properties
Exemplo n.º 12
0
 def _get_schema(self, resource, context):
     return merge_dicts(
         BaseTheme_Edit._get_schema(self, resource, context),
         custom_data=String,
         banner_title=Multilingual,
         banner_path=PathDataType(multilingual=True, parameters_schema={"lang": String}),
         class_skin=NeutralClassSkin(mandatory=True),
     )
Exemplo n.º 13
0
 def get_schema(self, resource, context):
     proxy = super(EasyNewInstance_WithOrderer, self)
     class_id = MyAuthorized_Classid(view=self, resource=resource,
                                     context=context, mandatory=True)
     return merge_dicts(proxy.get_schema(resource, context),
             class_id=class_id,
             order=OrderBoxEnumerate(default='order-bottom'),
             state=StaticStateEnumerate(default='public'))
Exemplo n.º 14
0
class CheckPaymentBaseTable(PaymentWayBaseTable):

    record_properties = merge_dicts(
        PaymentWayBaseTable.record_properties,
        check_number=Integer(title=MSG(u'Check number')),
        bank=Unicode(title=MSG(u'Bank')),
        account_holder=Unicode(title=MSG(u'Account holder')),
        advance_state=CheckStates(title=MSG(u'Advance State')))
Exemplo n.º 15
0
 def get_namespace(self, resource, context):
     context.scripts.append('/ui/shop/js/declinations.js')
     declinations = list(resource.search_resources(cls=Declination))
     javascript_products = resource.get_javascript_namespace(declinations)
     purchase_options = resource.get_purchase_options_namespace(declinations)
     return merge_dicts(resource.get_namespace(context),
                        javascript_products=javascript_products,
                        purchase_options=purchase_options)
Exemplo n.º 16
0
 def get_query_schema(self):
     # Define a huge batch limit, and the image size parameter
     schema = super(Folder_PreviewContent, self).get_query_schema()
     return merge_dicts(schema,
                        batch_size=Integer(default=0),
                        size=Integer(default=128),
                        width=String,
                        height=String)
Exemplo n.º 17
0
 def get_query_schema(self):
     """ We allow to define 2 variable (sort_by and batch_size)"""
     return merge_dicts(
         Folder_BrowseContent.get_query_schema(self),
         batch_size=Integer(default=self.batch_size),
         sort_by=String(default=self.sort_by),
         reverse=Boolean(default=self.reverse),
     )
Exemplo n.º 18
0
 def get_query_schema(self):
     # Define a huge batch limit, and the image size parameter
     schema = super(Folder_PreviewContent, self).get_query_schema()
     return merge_dicts(schema,
                        batch_size=Integer(default=0),
                        size=Integer(default=128),
                        width=String,
                        height=String)
Exemplo n.º 19
0
 def get_namespace(self, datatype, value):
     context = get_context()
     product = context.resource
     shop = get_shop(product)
     return merge_dicts(
         Widget.get_namespace(self, datatype, value),
         shop_uri=product.get_pathto(shop),
         show_barcode=shop.get_property('barcode_format') != None,
         reference=product.get_property('reference'))
Exemplo n.º 20
0
 def get_search_schema(self):
     schema = {}
     for key, datatype in get_product_filters().items():
         if getattr(datatype, 'is_range', False):
             datatype = IntegerRange
         schema['DFT-%s' % key] = datatype
     return merge_dicts({'stored_price': IntegerRange,
                         'stored_weight': IntegerRange},
                        schema)
Exemplo n.º 21
0
 def get_namespace(self, datatype, value):
     context = get_context()
     product = context.resource
     shop = get_shop(product)
     return merge_dicts(
         Widget.get_namespace(self, datatype, value),
         shop_uri=product.get_pathto(shop),
         show_barcode=shop.get_property('barcode_format') != None,
         reference=product.get_property('reference'))
Exemplo n.º 22
0
Arquivo: views.py Projeto: hforge/itws
    def _get_schema(self, resource, context):
        schema = {'timestamp': DateTime(readonly=True)}
        # Add edit_schema items
        schema = merge_dicts(schema, self.edit_schema)
        # If WorkflowAware we add state
        if 'state' not in schema and isinstance(resource, WorkflowAware):
            schema['state'] = StaticStateEnumerate(workflow=resource.workflow)

        return freeze(schema)
Exemplo n.º 23
0
 def _get_schema(self, resource, context):
     tags_schema = TagsAware_Edit._get_schema(self, resource, context)
     return freeze(merge_dicts(
         contact_schema,
         # crm_p_lastname and crm_p_status are mandatory
         crm_p_lastname=contact_schema['crm_p_lastname'](
             mandatory=True),
         crm_p_status=contact_schema['crm_p_status'](mandatory=True),
         # Tags
         tags=tags_schema['tags']))
Exemplo n.º 24
0
class CashPayment_Configure(PaymentWay_Configure):

    title = MSG(u'Configure checkpayment module')

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


    widgets = PaymentWay_Configure.widgets + [
        MultilineWidget('address', title=MSG(u'Address'))]
Exemplo n.º 25
0
 def _get_schema(self, resource, context):
     schema = {}
     if getattr(resource, 'edit_show_meta', False) is True:
         schema['description'] = Unicode(multilingual=True)
         schema['subject'] = Unicode(multilingual=True)
     schema = merge_dicts(self.base_schema, schema, resource.edit_schema)
     # FIXME Hide/Show title
     if getattr(resource, 'display_title', True) is False:
         del schema['title']
     return freeze(schema)
Exemplo n.º 26
0
 def get_metadata_schema(cls):
     return merge_dicts(Folder.get_metadata_schema(),
                        WorkflowAware.get_metadata_schema(),
                        ctime=DateTime,
                        note=Integer(default=0),
                        remote_ip=String,
                        author=String,
                        advantages=Unicode,
                        disadvantages=Unicode,
                        images=String,
                        recommended=RecommandationEnumerate)
Exemplo n.º 27
0
 def reset(self):
     self.properties = None
     self.records = []
     self.added_properties = []
     self.added_records = []
     self.removed_records = []
     # The catalog (for index and search)
     fields = merge_dicts(
         self.record_properties,
         __id__=Integer(is_key_field=True, is_stored=True, is_indexed=True))
     self.catalog = make_catalog(None, fields)
Exemplo n.º 28
0
Arquivo: html.py Projeto: hforge/itws
    def _get_schema(self, resource, context):
        schema = merge_dicts(
                HTMLEditView._get_schema(self, resource, context),
                # other
                title_link_schema,
                display_title=Boolean)
        # Delete unused description/subject(keywords)
        del schema['description']
        del schema['subject']

        return freeze(schema)
Exemplo n.º 29
0
class DBResource_AddLink(DBResource_AddBase):

    element_to_add = 'link'
    browse_content_class = AddBase_BrowseContent

    action_add_resource_schema = merge_dicts(DBResource_AddBase.schema,
                                             title=Unicode(mandatory=True))

    text_values = {'title': MSG(u'Insert link'),
       'browse': MSG(u'Browse and link to a File from the workspace'),
       'extern': MSG(u'Type the URL of an external resource'),
       'insert': MSG(u'Create a new page and link to it:'),
       'upload': MSG(u'Upload a file to the current folder and link to it:'),
       'method': ';add_link'}


    def get_configuration(self):
        return {
            'show_browse': True,
            'show_external': True,
            'show_insert': True,
            'show_upload': True}


    def action_add_resource(self, resource, context, form):
        mode = form['mode']
        name = checkid(form['title'])
        # Check name validity
        if name is None:
            context.message = MSG(u"Invalid title.")
            return
        # Get the container
        root = context.root
        container = root.get_resource(context.get_form_value('target_path'))
        # Check the name is free
        if container.get_resource(name, soft=True) is not None:
            context.message = messages.MSG_NAME_CLASH
            return
        # Get the type of resource to add
        cls = self.get_page_type(mode)
        # Create the resource
        child = container.make_resource(name, cls)
        scripts = self.get_scripts(context)
        context.add_script(*scripts)
        return self.get_javascript_return(context, child.abspath)


    def get_page_type(self, mode):
        """Return the type of page to add corresponding to the mode
        """
        if mode == 'tiny_mce':
            from webpage import WebPage
            return WebPage
        raise ValueError, 'Incorrect mode %s' % mode
Exemplo n.º 30
0
 def _get_schema(self, resource, context):
     tags_schema = TagsAware_Edit._get_schema(self, resource, context)
     return freeze(
         merge_dicts(
             company_schema,
             # title is mandatory
             title=company_schema["title"](mandatory=True),
             # Tags
             tags=tags_schema["tags"],
         )
     )
Exemplo n.º 31
0
 def get_metadata_schema(cls):
     return merge_dicts(Folder.get_metadata_schema(),
                        WorkflowAware.get_metadata_schema(),
                        ctime=DateTime,
                        note=Integer(default=0),
                        remote_ip=String,
                        author=String,
                        advantages=Unicode,
                        disadvantages=Unicode,
                        images=String,
                        recommended=RecommandationEnumerate)
Exemplo n.º 32
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'))
    ]
Exemplo n.º 33
0
 def get_query_schema(self):
     proxy = super(Mission_AddContacts, self)
     schema = proxy.get_query_schema()
     context = get_context()
     company = self.get_default_company(context.resource, context)
     if company is None:
         return schema
     # Just a search term, not hard coded to search contacts from another
     # company
     return freeze(merge_dicts(
         schema,
         search_term=Unicode(default=company.get_property('title'))))
Exemplo n.º 34
0
 def reset(self):
     self.properties = None
     self.records = []
     self.added_properties = []
     self.added_records = []
     self.removed_records = []
     # The catalog (for index and search)
     fields = merge_dicts(self.record_properties,
                          __id__=Integer(is_key_field=True,
                                         is_stored=True,
                                         is_indexed=True))
     self.catalog = make_catalog(None, fields)
Exemplo n.º 35
0
 def _get_schema(self, resource, context):
     tags_schema = TagsAware_Edit._get_schema(self, resource, context)
     return freeze(merge_dicts(
         mission_schema,
         # title and crm_m_status are mandatory
         title=mission_schema['title'](mandatory=True),
         crm_m_status=mission_schema['crm_m_status'](mandatory=True),
         # resource needed
         crm_m_assigned=mission_schema['crm_m_assigned'](
             resource=resource),
         crm_m_cc=mission_schema['crm_m_cc'](resource=resource),
         # Tags
         tags=tags_schema['tags']))
Exemplo n.º 36
0
class ShopWebSite_View(NeutralWS_View):

    title = MSG(u'View')
    access = 'is_allowed_to_view'

    subviews = merge_dicts(NeutralWS_View.subviews, vertical_items_view=None)

    def GET(self, resource, context):
        # Back-Office
        hostname = context.uri.authority
        if hostname[:6] == 'admin.':
            return context.uri.resolve('/shop/;administration')
        return NeutralWS_View.GET(self, resource, context)
Exemplo n.º 37
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'))
    ]
Exemplo n.º 38
0
    def get_namespace(self, resource, context):
        show_if_empty = resource.get_property('show_if_empty')
        cart = ProductCart(context)
        if (self.is_admin(resource, context) is False and
            cart.get_nb_products() == 0 and
            show_if_empty is False):
            self.set_view_is_empty(True)

        default_order_title = MSG(u'Commander')
        return merge_dicts(
            cart.get_namespace(resource),
            order_title=resource.get_property('order_title') or default_order_title,
            title=resource.get_title())
Exemplo n.º 39
0
 def _get_catalog_values(self):
     return merge_dicts(
         DynamicFolder._get_catalog_values(self),
         self._get_dynamic_catalog_values(),
         reference=self.get_property('reference'),
         declination_title=self.get_declination_title(),
         manufacturer=str(self.parent.get_property('manufacturer')),
         supplier=str(self.parent.get_property('supplier')),
         ht_price=self.parent.get_price_without_tax(id_declination=self.name, pretty=False),
         ttc_price=self.parent.get_price_with_tax(id_declination=self.name, pretty=False),
         # XXX Declination must be workflowaware
         is_default=self.get_property('is_default'),
         workflow_state=self.parent.get_workflow_state(),
         stock_quantity=self.get_property('stock-quantity'))
Exemplo n.º 40
0
    def _get_schema(self, resource, context):
        schema = merge_dicts(
                HTMLEditView._get_schema(self, resource, context),
                # BoxAware API
                resource.edit_schema,
                # other
                title_link=String,
                title_link_target=Target,
                display_title=Boolean)
        # Delete unused description/subject(keywords)
        del schema['description']
        del schema['subject']

        return schema
Exemplo n.º 41
0
 def get_schema(self, resource, context):
     product_model = resource.get_product_model()
     site_root = resource.get_site_root()
     shop = get_shop(site_root)
     # Cover is mandatory
     mandatory = shop.get_property('product_cover_is_mandatory')
     product_schema['cover'].mandatory = mandatory
     # Return schema
     return merge_dicts(
               product_schema,
               (product_model.get_model_schema() if product_model else {}),
               data=XHTMLBody(multilingual=True),
               category=CategoriesEnumerate,
               not_buyable_by_groups=UserGroup_Enumerate(multiple=True),
               tags=TagsList(site_root=site_root, multiple=True))
Exemplo n.º 42
0
    def get_query_schema(self):
        """We allow to define 2 variable (sort_by and batch_size)"""
        d = merge_dicts(Folder_BrowseContent.get_query_schema(self),
                batch_size=Integer(default=self.batch_size),
                sort_by=String(default=self.sort_by),
                reverse=Boolean(default=self.reverse))

        query_suffix = self._get_query_suffix()
        if query_suffix is None:
            return d

        prefixed_d = {}
        for key, value in d.iteritems():
            prefixed_d['%s_%s' % (key, query_suffix)] = value
        return prefixed_d
Exemplo n.º 43
0
    def get_schema(self, resource, context):
        schema = merge_dicts(resource.base_schema,
                             resource.get_dynamic_schema())

        group = resource.get_group(context)
        # Lastname mandatory ?
        l_mandatory = group.get_property('lastname_is_mandatory_on_registration')
        schema['lastname'] = Unicode(mandatory=l_mandatory)
        # Phone mandatory ?
        p_mandatory = group.get_property('phone_is_mandatory_on_registration')
        schema['phone1'] = String(mandatory=p_mandatory)

        del schema['password']
        del schema['user_must_confirm']
        return schema
Exemplo n.º 44
0
Arquivo: views.py Projeto: TZM/zmgc
    def get_namespace(self, resource, context):
        tabs = TabsTemplate(context)
        user = context.user
        if user is None:
            info = None
        else:
            home = '/users/%s' % user.name
            info = {'name': user.name,
                'title': user.get_title(),
                'home': home}
        batch = None
        table = None
        # Batch
        chapters = self.get_items_namespace(resource, context)

        return merge_dicts(chapters, {'batch': batch, 'info': info, 'tabs': tabs})
Exemplo n.º 45
0
 def get_namespace(self, resource, context):
     set_print(context)
     context.bad_types = set()
     forms = []
     for page_number in resource.get_page_numbers():
         formpage = resource.get_formpage(page_number)
         view = getattr(resource, 'page%s' % page_number)
         ns = merge_dicts(formpage.get_namespace(resource,
                                                 view,
                                                 context,
                                                 skip_print=True),
                          title=formpage.get_title())
         forms.append(ns)
     namespace = {}
     namespace['forms'] = forms
     return namespace
Exemplo n.º 46
0
 def _get_catalog_values(self):
     return merge_dicts(
         DynamicFolder._get_catalog_values(self),
         self._get_dynamic_catalog_values(),
         reference=self.get_property('reference'),
         declination_title=self.get_declination_title(),
         manufacturer=str(self.parent.get_property('manufacturer')),
         supplier=str(self.parent.get_property('supplier')),
         ht_price=self.parent.get_price_without_tax(
             id_declination=self.name, pretty=False),
         ttc_price=self.parent.get_price_with_tax(id_declination=self.name,
                                                  pretty=False),
         # XXX Declination must be workflowaware
         is_default=self.get_property('is_default'),
         workflow_state=self.parent.get_workflow_state(),
         stock_quantity=self.get_property('stock-quantity'))
Exemplo n.º 47
0
 def reset(self):
     self.lines = []
     self.n_lines = 0
     # Initialize the catalog if needed (Index&Search)
     # (we look if we have at least one indexed field in schema/columns)
     self.catalog = None
     schema = self.schema
     if schema is not None:
         for name in self.columns:
             field_cls = schema[name]
             if getattr(field_cls, 'is_indexed', False):
                 fields = merge_dicts(schema,
                                      __number__=Integer(is_key_field=True,
                                                         is_stored=True,
                                                         is_indexed=True))
                 self.catalog = make_catalog(None, fields)
                 break
Exemplo n.º 48
0
 def reset(self):
     self.lines = []
     self.n_lines = 0
     # Initialize the catalog if needed (Index&Search)
     # (we look if we have at least one indexed field in schema/columns)
     self.catalog = None
     schema = self.schema
     if schema is not None:
         for name in self.columns:
             field_cls = schema[name]
             if getattr(field_cls, 'is_indexed', False):
                 fields = merge_dicts(schema,
                                      __number__=Integer(is_key_field=True,
                                                         is_stored=True,
                                                         is_indexed=True))
                 self.catalog = make_catalog(None, fields)
                 break
Exemplo n.º 49
0
 def _get_info(self, field_cls, name):
     # The key field ?
     if name == 'abspath':
         if not (issubclass(field_cls, String) and
                 field_cls.stored and
                 field_cls.indexed):
             raise ValueError, ('the abspath field must be declared as '
                                'String(stored=True, indexed=True)')
     # Stored ?
     info = {}
     if getattr(field_cls, 'stored', False):
         info = self._get_info_stored()
     # Indexed ?
     if getattr(field_cls, 'indexed', False):
         info = merge_dicts(info, self._get_info_indexed())
     # Ok
     return info
Exemplo n.º 50
0
    def get_schema(self, resource, context):
        group = self.get_group(context)
        base_schema = deepcopy(self.base_schema)
        # Inject address schema ?
        address_schema = {}
        if group.get_property('hide_address_on_registration') is False:
            address_schema = self.address_schema
        # Lastname mandatory ?
        l_mandatory = group.get_property(
            'lastname_is_mandatory_on_registration')
        base_schema['lastname'] = Unicode(mandatory=l_mandatory)
        # Phone mandatory ?
        p_mandatory = group.get_property('phone_is_mandatory_on_registration')
        base_schema['phone1'] = String(mandatory=p_mandatory)

        # Return schema
        return merge_dicts(base_schema, group.get_dynamic_schema(),
                           address_schema)
Exemplo n.º 51
0
    def get_schema(self, resource, context):
        group = self.get_group(context)
        base_schema = deepcopy(self.base_schema)
        # Inject address schema ?
        address_schema = {}
        if group.get_property('hide_address_on_registration') is False:
            address_schema = self.address_schema
        # Lastname mandatory ?
        l_mandatory = group.get_property('lastname_is_mandatory_on_registration')
        base_schema['lastname'] = Unicode(mandatory=l_mandatory)
        # Phone mandatory ?
        p_mandatory = group.get_property('phone_is_mandatory_on_registration')
        base_schema['phone1'] = String(mandatory=p_mandatory)

        # Return schema
        return merge_dicts(base_schema,
                           group.get_dynamic_schema(),
                           address_schema)
Exemplo n.º 52
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'))]
Exemplo n.º 53
0
 def _get_catalog_values(self):
     values = merge_dicts(DynamicFolder._get_catalog_values(self),
                          TagsAware._get_catalog_values(self),
                          self._get_dynamic_catalog_values())
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     values['data'] = data
     # Reference
     values['reference'] = self.get_property('reference')
     # Manufacturer
     values['manufacturer'] = str(self.get_property('manufacturer'))
     # Supplier
     values['supplier'] = str(self.get_property('supplier'))
     # Stock quantity
     values['stock_quantity'] = self.get_property('stock-quantity')
     # Product models
     values['product_model'] = str(self.get_property('product_model'))
     # Images
     order = self.get_resource('order-photos', soft=True)
     if order:
         ordered_names = list(order.get_ordered_names())
         values['has_images'] = (len(ordered_names) != 0)
     else:
         values['has_images'] = False
     # Price # XXX We can't sort decimal, so transform to int
     values['stored_price'] = int(self.get_price_with_tax() * 100)
     values['stored_weight'] = int(self.get_weight() * 100)
     # Price
     values['ht_price'] = self.get_price_without_tax()
     values['ttc_price'] = self.get_price_with_tax()
     # Creation time
     values['ctime'] = self.get_property('ctime')
     # Publication date
     values['pub_datetime'] = self.get_property('pub_datetime')
     # Promotion
     values['has_reduction'] = self.get_property('has_reduction')
     # not_buyable_by_groups
     values['not_buyable_by_groups'] = self.get_property(
         'not_buyable_by_groups')
     return values
Exemplo n.º 54
0
class Folder_CSV_Export(CSV_Export):

    # Allow to export the whole list without checking any box
    action_csv_export_schema = freeze(
        merge_dicts(CSV_Export.csv_schema,
                    ids=String(multiple=True, mandatory=False)))

    def csv_write_row(self, resource, context, writer, item):
        row = []
        for column in self.csv_columns:
            value = self.get_item_value(resource, context, item, column.name)
            if type(value) is tuple:
                value = value[0]
            # TODO in 0.70 read datatype from class_schema
            row.append(value)
        writer.add_row(row)

    def get_csv_items(self, resource, context, form):
        results = self.get_items(resource, context)
        if not len(results):
            return
        # Filter by selected ids or all
        ids = form.get('ids')
        # XXX
        batch_start = context.query['batch_start']
        batch_size = context.query['batch_size']
        context.query['batch_start'] = context.query['batch_size'] = 0
        for item in self.sort_and_batch(resource, context, results):
            if ids:
                item_id = self.get_item_value(resource, context, item,
                                              'checkbox')
                if type(item_id) is tuple:
                    item_id = item_id[0]
                if item_id not in ids:
                    continue
            yield item
        context.query['batch_start'] = batch_start
        context.query['batch_size'] = batch_size
Exemplo n.º 55
0
class DBResource_Links(Folder_BrowseContent):
    """Links are the list of resources used by this resource."""

    access = 'is_allowed_to_view'
    title = MSG(u"Links")
    icon = 'rename.png'

    query_schema = merge_dicts(Folder_BrowseContent.query_schema,
                               batch_size=Integer(default=0))

    search_schema = {}
    search_widgets = []

    table_actions = []

    def get_table_columns(self, resource, context):
        proxy = super(DBResource_Links, self)
        cols = proxy.get_table_columns(resource, context)
        return [x for x in cols if x[0] != 'checkbox']

    def get_items(self, resource, context):
        links = resource.get_links()
        query = OrQuery(*[PhraseQuery('abspath', link) for link in links])
        return context.database.search(query)