def get_manage_links(self, view, container_namespace=None, rank=None, total_ranks=None): allowed = [] for action in self.actions: if action[2] and permission.perform_action(self, self.section.path, action[0]): allowed.append(action) if permission.is_admin(self.section.path) and container_namespace: pass elif len(allowed) == 0: return '' for v in self.views: if v[0] == view: view = v[1] break params = { 'content': self, 'view': view, 'can_manage': permission.is_admin(self.section.path), 'container_namespace': container_namespace, 'rank': rank, 'total_ranks': total_ranks, 'allowed_actions': allowed, } return template.snippet('content-permissions', params)
def view_slingbar(self, params): params = { 'content': self, 'user': users.get_current_user(), 'is_admin': permission.is_admin(self.section.path), } return template.snippet('user-slingbar', params)
def action_manage(self): themes = [ self.get_theme(namespace) for namespace in self.theme_namespaces ] return template.snippet('themes-manage', { 'content': self, 'themes': themes })
def action_edit(self): if not self.titles: return self.action_add() rank = int(self.section.path_params[0]) if self.section.path_params else 0 if rank > len(self.titles) - 1 or rank < 0: raise Exception('BadRequest', 'Text item out of range') elif self.section.handler.request.get('submit'): self.titles[rank] = self.section.handler.request.get('title') self.bodies[rank] = self.section.handler.request.get('body') self.update() raise Exception('Redirect', self.section.action_redirect_path) elif not self.section.path_params and self.titles: self.items = [] for i in range(len(self.titles)): self.items.append([self.titles[i], self.bodies[i]]) return template.snippet('text-edit-multiple', { 'content': self }) return '<h2>Edit text</h2>' + get_form(self.section, self.titles[rank], self.bodies[rank])
def action_browse(self): message = '' if self.section.handler.request.get('submit'): try: data = urllib2.urlopen(self.section.handler.request.get('url')).read() self.import_compressed_theme_data(data) except Exception as inst: error = '<div class="status error">%s</div>' message = inst[0] if not isinstance(inst[0], types.ListType) else '<br>'.join(inst[0]) message = error % message else: raise Exception('Redirect', self.section.action_redirect_path) f = form(self.section, self.section.full_path) f.add_control(control(self.section, 'text', 'url', '', 'URL', 80)) f.add_control(control(self.section, 'submit', 'submit', 'Install')) return message + template.snippet('themes-browse', { 'content': self, 'form': unicode(f) })
def action_edit(self): if not self.titles: return self.action_add() rank = int(self.section.path_params[0]) if self.section.path_params else 0 if rank > len(self.titles) - 1 or rank < 0: raise Exception("BadRequest", "Text item out of range") elif self.section.handler.request.get("submit"): self.titles[rank] = self.section.handler.request.get("title") self.bodies[rank] = db.Text(self.section.handler.request.get("body")) self.update() raise Exception("Redirect", self.section.action_redirect_path) elif not self.section.path_params and self.titles: self.items = [] for i in range(len(self.titles)): self.items.append([self.titles[i], self.bodies[i]]) return template.snippet("text-edit-multiple", {"content": self}) return "<h2>Edit text</h2>" + get_form(self.section, self.titles[rank], self.bodies[rank])
def action_edit(self): if not self.titles: return self.action_add() rank = int( self.section.path_params[0]) if self.section.path_params else 0 if rank > len(self.titles) - 1 or rank < 0: raise Exception('BadRequest', 'Text item out of range') elif self.section.handler.request.get('submit'): self.titles[rank] = self.section.handler.request.get('title') self.bodies[rank] = self.section.handler.request.get('body') self.update() raise Exception('Redirect', self.section.action_redirect_path) elif not self.section.path_params and self.titles: self.items = [] for i in range(len(self.titles)): self.items.append([self.titles[i], self.bodies[i]]) return template.snippet('text-edit-multiple', {'content': self}) return '<h2>Edit text</h2>' + get_form(self.section, self.titles[rank], self.bodies[rank])
def action_browse(self): message = '' if self.section.handler.request.get('submit'): try: data = urllib2.urlopen( self.section.handler.request.get('url')).read() self.import_compressed_theme_data(data) except Exception as inst: error = '<div class="status error">%s</div>' message = inst[0] if not isinstance( inst[0], types.ListType) else '<br>'.join(inst[0]) message = error % message else: raise Exception('Redirect', self.section.action_redirect_path) f = form(self.section, self.section.full_path) f.add_control(control(self.section, 'text', 'url', '', 'URL', 80)) f.add_control(control(self.section, 'submit', 'submit', 'Install')) return message + template.snippet('themes-browse', { 'content': self, 'form': unicode(f) })
def get_manage_links(self, view, container_namespace=None, rank=None, total_ranks=None): allowed = [] for action in self.actions: if action[2] and permission.perform_action(self, self.section.path, action[0]): allowed.append(action) if permission.is_admin(self.section.path) and container_namespace: pass elif len(allowed) == 0: return "" for v in self.views: if v[0] == view: view = v[1] break params = { "content": self, "view": view, "can_manage": permission.is_admin(self.section.path), "container_namespace": container_namespace, "rank": rank, "total_ranks": total_ranks, "allowed_actions": allowed, } return template.snippet("content-permissions", params)
def view_menu(self, params=None): return template.snippet('files-menu', { 'content': self })
def view_default(self, params): self.items = [] for i in range(len(self.titles)): self.items.append([self.titles[i], self.bodies[i]]) return template.snippet('text-default', {'content': self}) if self.items else ''
def view_menu(self, params=None): return template.snippet('files-menu', {'content': self})
def action_manage(self): return template.snippet('files-manage', { 'content': self })
def view_menu(self, params=None): return template.snippet('configuration-menu', { 'content': self })
def action_manage(self): return template.snippet('files-manage', {'content': self})
def view_menu(self, params=None): return template.snippet('navigation-menu', { 'content': self, 'is_admin': permission.is_admin(self.section.path) })
def view_menu(self, params=None): return template.snippet('configuration-menu', {'content': self})
def view_default(self, params): self.items = [] for i in range(len(self.titles)): self.items.append([self.titles[i], self.bodies[i]]) return template.snippet("text-default", {"content": self}) if self.items else ""
def action_manage(self): themes = [self.get_theme(namespace) for namespace in self.theme_namespaces] return template.snippet('themes-manage', { 'content': self, 'themes': themes })