コード例 #1
0
ファイル: addresses.py プロジェクト: nicolasderam/shop
class Addresses(Table):

    class_id = 'addresses'
    class_title = MSG(u'Adresse')
    class_handler = BaseAddresses
    class_views = ['addresses_book', 'search']

    @property
    def class_views(self):
        context = get_context()
        # Back-Office
        hostname = context.uri.authority
        if hostname[:6] == 'admin.':
            return ['search']
        return ['addresses_book']

    # Views
    addresses_book = Addresses_Book()
    add_address = Addresses_AddAddress()
    edit_address = Addresses_EditAddress()
    search = Addresses_Search()

    view = Table_View(access='is_admin')
    last_changes = None
    add_record = None

    address_title = MSG(u"""
      Please give a name to your address.
      """)

    address_tip = MSG(u"(Example: Home, Office)")

    form = [
        SelectRadio('gender', title=MSG(u'Genre')),
        TextWidget('firstname', title=MSG(u'Firstname')),
        TextWidget('lastname', title=MSG(u'Lastname')),
        TextWidget('address_1', title=MSG(u'Address')),
        TextWidget('address_2', title=MSG(u'Address (next)')),
        TextWidget('zipcode', title=MSG(u'Zip Code')),
        TextWidget('town', title=MSG(u'Town')),
        SelectWidget('country', title=MSG(u'Country')),
        TextWidget('title', title=address_title, tip=address_tip),
    ]
コード例 #2
0
 def get_item_value(self, resource, context, item, column):
     if column == 'img_path':
         img_path = resource.handler.get_record_value(item, column)
         # NOTE img_path is unicode multiple -> multilingual
         image = resource.get_resource(str(img_path), soft=True)
         if not image:
             return None
         return get_resource_preview(image, 128, 64, 0, context)
     elif column == 'img_link':
         img_link = resource.handler.get_record_value(item, column)
         reference = get_reference(img_link)
         if reference.scheme:
             # Encode the reference '&' to avoid XMLError
             reference = XMLContent.encode(str(reference))
             return XMLParser('<a href="%s">%s</a>' % (reference, reference))
         # Split path/view
         reference_path = str(reference.path)
         view = None
         if reference_path.count(';'):
             reference_path, view = reference_path.split('/;' ,1)
         item_resource = resource.get_resource(reference_path, soft=True)
         if not item_resource:
             # Not found, just return the reference
             # Encode the reference '&' to avoid XMLError
             return XMLContent.encode(str(reference))
         # Build the new reference with the right path
         reference2 = deepcopy(reference)
         reference2.path = context.get_link(item_resource)
         if view:
             # Append the view
             reference2.path = '%s/;%s' % (reference2.path, view)
         # Encode the reference '&' to avoid XMLError
         # Reference : the reference used for the a content
         reference = XMLContent.encode(str(reference))
         # Reference2 : the reference used for href attribute
         reference2 = XMLContent.encode(str(reference2))
         return XMLParser('<a href="%s">%s</a>' % (reference2, reference))
     return Table_View.get_item_value(self, resource, context, item, column)
コード例 #3
0
 def get_query_schema(self):
     return merge_dicts(Table_View.get_query_schema(self),
                        reverse=Boolean(default=True),
                        sort_by=String(default='ts'))
コード例 #4
0
ファイル: paybox_views.py プロジェクト: nicolasderam/shop
 def get_items(self, resource, context):
     items = []
     for item in Table_View.get_items(self, resource, context):
         ns = resource.get_record_namespace(context, item)
         items.append(ns)
     return items