def get_item_value(self, resource, context, item, column): gallery = resource.parent if column in ['image', 'title', 'edit']: image = resource.get_resource(item.name, soft=True) if image is None: # XXX Why ? image = gallery.get_resource(item.name, soft=True) if image is None: return None link = context.get_link(image) if column == 'image': src = '%s/;thumb?width=%s&height=%s' % (link, 250, 250) preview = '<img src="%s"/>' % src return XMLParser(preview.encode('utf-8')) elif column == 'title': return image.get_title() elif column == 'edit': edit = (""" <a href="%s/;edit" title="Edit image"> <img src="/ui/icons/16x16/edit.png"/> </a> """ % link) return XMLParser(edit) return OrderedTable_View.get_item_value(self, resource, context, item, column)
def get_item_value(self, resource, context, item, column): gallery = resource.parent if column in ['image', 'title', 'edit']: image = resource.get_resource(item.name, soft=True) if image is None: # XXX Why ? image = gallery.get_resource(item.name, soft=True) if image is None: return None link = context.get_link(image) if column == 'image': src = '%s/;thumb?width=%s&height=%s' % (link, 250, 250) preview = '<img src="%s"/>' % src return XMLParser(preview.encode('utf-8')) elif column == 'title': return image.get_title() elif column == 'edit': edit = (""" <a href="%s/;edit" title="Edit image"> <img src="/ui/icons/16x16/edit.png"/> </a> """ % link) return XMLParser(edit) return OrderedTable_View.get_item_value(self, resource, context, item, column)
def get_table_columns(self, resource, context): columns = OrderedTable_View.get_table_columns(self, resource, context) columns = columns[:2] columns.append(('title', MSG(u'Title'))) columns.append(('image', MSG(u'Image'))) columns.append(('order', MSG(u'Order'))) columns.append(('edit', MSG(u'Edit'))) return columns
def get_table_columns(self, resource, context): columns = OrderedTable_View.get_table_columns(self, resource, context) columns = columns[:2] columns.append(('title', MSG(u'Title'))) columns.append(('image', MSG(u'Image'))) columns.append(('order', MSG(u'Order'))) columns.append(('edit', MSG(u'Edit'))) return columns
class Taxes_TableResource(OrderedTable): class_id = 'shop-taxes' class_title = MSG(u'Taxes') class_handler = Taxes_TableHandler table_actions = [ OrderUpButton, OrderDownButton, OrderTopButton, OrderBottomButton ] view = OrderedTable_View(table_actions=table_actions)
def get_item_value(self, resource, context, item, column): if column == "title": get_value = resource.handler.get_record_value return (get_value(item, "title"), ";edit_record?id=%s" % item.id) elif column == "count": quantity = self.get_quantity(resource, context, item) option_name = resource.name option_value = resource.handler.get_record_value(item, "name") uri = "./;details?option_name=%s&option_value=%s" return quantity, uri % (option_name, option_value) return OrderedTable_View.get_item_value(self, resource, context, item, column)
def get_item_value(self, resource, context, item, column): if column == 'title': get_value = resource.handler.get_record_value return (get_value(item, 'title'), ';edit_record?id=%s' % item.id) elif column == 'count': quantity = self.get_quantity(resource, context, item) option_name = resource.name option_value = resource.handler.get_record_value(item, 'name') uri = './;details?option_name=%s&option_value=%s' return quantity, uri % (option_name, option_value) return OrderedTable_View.get_item_value(self, resource, context, item, column)
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)
def get_item_value(self, resource, context, item, column): if column == 'img_path': img_path = resource.handler.get_record_value(item, column) 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 isinstance(reference, EmptyReference): return None if reference.scheme: # Encode the reference '&' to avoid XMLError ref = XMLContent.encode(str(reference)) return XMLParser('<a href="{ref}">{ref}</a>'.format(ref=ref)) # Split path/view reference_path, view = get_path_and_view(reference.path) 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 OrderedTable_View.get_item_value(self, resource, context, item, column)