def view_default(self, params): ret = '' add_action = self.actions[0] can_add = permission.perform_action(self, self.section.path, add_action[0]) if can_add: self.section.css.append('container.css') add_link = '<a class="container add" href="/' + self.section.path + '/' + self.namespace + '/' + add_action[ 0] + '/%d">' + add_action[1] + '</a>' for i in range(len(self.content_namespaces)): if can_add: ret += add_link % i item = content.get( self.content_types[i], self.content_paths[i] if self.content_paths[i] else None, self.content_namespaces[i]) if not item: ret += self.get_manage_links( self.content_views[i], self.namespace, i ) + '<div class="status error">Content for this view was deleted</div>' else: ret += item.init(self.section).view( self.content_views[i], params=None, container_namespace=self.namespace, rank=i, total_ranks=len(self.content_namespaces)) if can_add: ret += add_link % len(self.content_namespaces) return ret
def action_delete(self): rank = int(self.section.path_params[0]) item = content.get( self.content_types[rank], self.content_paths[rank] if self.content_paths[rank] else None, self.content_namespaces[rank]) is_original_content = item and item.container_namespace == self.namespace and item.section_path == self.section_path and self.content_namespaces.count( item.namespace) == 1 if item: item = item.init(self.section) if self.section.handler.request.get('submit'): if is_original_content: item.remove() self.content_types.pop(rank) self.content_paths.pop(rank) self.content_namespaces.pop(rank) self.content_views.pop(rank) self.update() raise Exception('Redirect', self.section.action_redirect_path) if is_original_content: message = '<div class="status warning">Are you sure you wish to delete content "%s" and all associated data?</div>' % self.content_namespaces[ rank] else: message = '<div class="status warning">Are you sure you wish to delete this view for content "%s"?</div>' % self.content_namespaces[ rank] f = form(self.section, self.section.full_path) f.add_control(control(self.section, 'submit', 'submit', 'Confirm')) return '<h2>Delete content</h2>%s%s' % (message, unicode(f))
def view_default(self, params): ret = '' add_action = self.actions[0] can_add = permission.perform_action(self, self.section.path, add_action[0]) if can_add: self.section.css.append('container.css') add_link = '<a class="container add" href="/' + self.section.path + '/' + self.namespace + '/' + add_action[0] + '/%d">' + add_action[1] + '</a>' for i in range(len(self.content_namespaces)): if can_add: ret += add_link % i item = content.get(self.content_types[i], self.content_paths[i] if self.content_paths[i] else None, self.content_namespaces[i]) if not item: ret += self.get_manage_links(self.content_views[i], self.namespace, i) + '<div class="status error">Content for this view was deleted</div>' else: ret += item.init(self.section).view(self.content_views[i], params=None, container_namespace=self.namespace, rank=i, total_ranks=len(self.content_namespaces)) if can_add: ret += add_link % len(self.content_namespaces) return ret
def action_delete(self): rank = int(self.section.path_params[0]) item = content.get(self.content_types[rank], self.content_paths[rank] if self.content_paths[rank] else None, self.content_namespaces[rank]) is_original_content = item and item.container_namespace == self.namespace and item.section_path == self.section_path and self.content_namespaces.count(item.namespace) == 1 if item: item = item.init(self.section) if self.section.handler.request.get('submit'): if is_original_content: item.remove() self.content_types.pop(rank) self.content_paths.pop(rank) self.content_namespaces.pop(rank) self.content_views.pop(rank) self.update() raise Exception('Redirect', self.section.action_redirect_path) if is_original_content: message = '<div class="status warning">Are you sure you wish to delete content "%s" and all associated data?</div>' % self.content_namespaces[rank] else: message = '<div class="status warning">Are you sure you wish to delete this view for content "%s"?</div>' % self.content_namespaces[rank] f = form(self.section, self.section.full_path) f.add_control(control(self.section, 'submit', 'submit', 'Confirm')) return '<h2>Delete content</h2>%s%s' % (message, unicode(f))