예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 def action_manage(self):
     themes = [
         self.get_theme(namespace) for namespace in self.theme_namespaces
     ]
     return template.snippet('themes-manage', {
         'content': self,
         'themes': themes
     })
예제 #5
0
 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])
예제 #6
0
 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) })
예제 #7
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 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])
예제 #8
0
 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])
예제 #9
0
 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)
     })
예제 #10
0
 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)
예제 #11
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 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)
예제 #12
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 def view_menu(self, params=None):
     return template.snippet('files-menu', { 'content': self })
예제 #13
0
 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 ''
예제 #14
0
 def view_menu(self, params=None):
     return template.snippet('files-menu', {'content': self})
예제 #15
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 def action_manage(self):
     return template.snippet('files-manage', { 'content': self })
예제 #16
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 def view_menu(self, params=None):
     return template.snippet('configuration-menu', { 'content': self })
예제 #17
0
 def action_manage(self):
     return template.snippet('files-manage', {'content': self})
예제 #18
0
 def view_menu(self, params=None):
     return template.snippet('navigation-menu', { 'content': self, 'is_admin': permission.is_admin(self.section.path) })
예제 #19
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 def view_menu(self, params=None):
     return template.snippet('navigation-menu', { 'content': self, 'is_admin': permission.is_admin(self.section.path) })
예제 #20
0
 def view_menu(self, params=None):
     return template.snippet('configuration-menu', {'content': self})
예제 #21
0
파일: __init__.py 프로젝트: fedex1/gae-cms
 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 ""
예제 #22
0
 def action_manage(self):
     themes = [self.get_theme(namespace) for namespace in self.theme_namespaces]
     return template.snippet('themes-manage', { 'content': self, 'themes': themes })