def get_namespace(self, resource, context): # Modules shop_module = ModuleLoader() shop_module.context = context shop_module.here = context.resource # Return namespace return {'news': self.get_rss_news(context), 'announce': self.get_announce(context), 'module': shop_module, # Last resources created 'products': self.get_last_resources(context, 'product', 13), 'issues': self.get_last_resources(context,'itws-issue', 13), 'orders': self.get_last_resources(context, 'order')}
def build_namespace(self, context): here = context.resource shop = context.site_root.get_resource('shop') site_root = context.site_root namespace = NeutralSkin.build_namespace(self, context) # Title # Menu XXX Done in ikaaro nav namespace['menu'] = get_menu_namespace(context, self.menu_level, src='menu') # Search namespace['product_search_text'] = context.get_query_value( 'product_search_text') # XXX Page id css (see itws) class_id = getattr(here, 'class_id', None) if class_id: view_name = context.view_name or here.get_default_view_name() page_css_id = 'page-%s-%s' % (class_id, view_name) page_css_id = page_css_id.replace('_', '-') namespace['page_css_id'] = page_css_id.lower() else: namespace['page_css_id'] = None # Cart preview cart_preview = site_root.cart_preview_class().GET(shop, context) namespace['cart_preview'] = cart_preview # Page title namespace['page_title'] = context.resource.get_title() # Current view type namespace['is_on_view_product'] = isinstance(context.resource, Product) # Dynamic property dynamic_property = ShopSkinDynamicProperty() dynamic_property.context = context dynamic_property.resource = self namespace['dynamic_property'] = dynamic_property # Canonical uri XXX (see bug #1144) if site_root != here: namespace['canonical_uri'].path.endswith_slash = True # Get admin bar site_root_ac = site_root.get_access_control() if site_root_ac.is_allowed_to_edit(context.user, site_root): namespace['admin_bar'] = AdminBarTemplate(context=context) else: namespace['admin_bar'] = None # Modules shop_module = ModuleLoader() shop_module.context = context shop_module.here = context.resource namespace['module'] = shop_module return namespace
def get_namespace(self, resource, context): batch = None # Batch items = self.get_items(resource, context) if self.batch_template is not None: template = resource.get_resource(self.batch_template) namespace = self.get_batch_namespace(resource, context, items) batch = stl(template, namespace) items = self.sort_and_batch(resource, context, items) # Shop modules shop_module = ModuleLoader() shop_module.context = context shop_module.here = self # Lazy lazy = LazyDict() lazy.cache = {} lazy.context = context lazy.resource = resource lazy.s = self # Build namespace namespace = { 'batch': list(batch), 'title': resource.get_title(), 'breadcrumb_title': resource.get_property('breadcrumb_title'), 'lazy': lazy, 'module': shop_module, 'products': [], 'description': None} # Photo img = resource.get_property('image_category') if img: img = resource.get_resource(img, soft=True) if img: namespace['photo'] = context.get_link(img) else: namespace['photo'] = None # Get products view box for item_resource in items: # XXX Hack for cross selling # Cross selling return only resource not brain if type(item_resource) is tuple: item_brain, item_resource = item_resource viewbox = item_resource.viewbox namespace['products'].append({'name': item_resource.name, 'abspath': str(item_resource.get_abspath()), 'box': viewbox.GET(item_resource, context)}) # Categorie description (not for categories folder) namespace['description'] = resource.get_property('data') return namespace
def get_namespace(self, resource, context): # Modules shop_module = ModuleLoader() shop_module.context = context shop_module.here = context.resource # Return namespace return { 'news': self.get_rss_news(context), 'announce': self.get_announce(context), 'module': shop_module, # Last resources created 'products': self.get_last_resources(context, 'product', 13), 'issues': self.get_last_resources(context, 'itws-issue', 13), 'orders': self.get_last_resources(context, 'order') }
def get_namespace(self, context): root = context.root # Get dynamic user values dynamic_user_value = ResourceDynamicProperty() dynamic_user_value.schema = self.get_dynamic_schema() dynamic_user_value.resource = self # Module shop_module = ModuleLoader() shop_module.context = context shop_module.here = self # Get modules items modules_items = [] search = context.root.search(is_shop_user_module=True) for brain in search.get_documents(): shop_user_module = root.get_resource(brain.abspath) modules_items.append({ 'name': shop_user_module.element_name, 'title': shop_user_module.element_title, 'href': shop_user_module.element_name, 'img': shop_user_module.class_icon48 }) # Ctime ctime = self.get_property('ctime') accept = context.accept_language # ACLS ac = self.get_access_control() is_authenticated = ac.is_authenticated(context.user, self) is_owner = context.user is not None and context.user.name == self.name # Build namespace return { 'name': self.name, 'link': context.get_link(self), 'module': shop_module, 'dynamic_user_value': dynamic_user_value, 'is_owner': is_owner, 'is_authenticated': is_authenticated, 'ctime': format_datetime(ctime, accept) if ctime else None, # XXX Why ? 'items': self.base_items + modules_items }
def get_namespace(self, context): root = context.root # Get dynamic user values dynamic_user_value = ResourceDynamicProperty() dynamic_user_value.schema = self.get_dynamic_schema() dynamic_user_value.resource = self # Module shop_module = ModuleLoader() shop_module.context = context shop_module.here = self # Get modules items modules_items = [] search = context.root.search(is_shop_user_module=True) for brain in search.get_documents(): shop_user_module = root.get_resource(brain.abspath) modules_items.append( {'name': shop_user_module.element_name, 'title': shop_user_module.element_title, 'href': shop_user_module.element_name, 'img': shop_user_module.class_icon48}) # Ctime ctime = self.get_property('ctime') accept = context.accept_language # ACLS ac = self.get_access_control() is_authenticated = ac.is_authenticated(context.user, self) is_owner = context.user is not None and context.user.name == self.name # Build namespace return {'name': self.name, 'link': context.get_link(self), 'module': shop_module, 'dynamic_user_value': dynamic_user_value, 'is_owner': is_owner, 'is_authenticated': is_authenticated, 'ctime': format_datetime(ctime, accept) if ctime else None, # XXX Why ? 'items': self.base_items + modules_items}