コード例 #1
0
ファイル: __init__.py プロジェクト: apunj001/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)
コード例 #2
0
ファイル: __init__.py プロジェクト: fedex1/gae-cms
 def action_add(self):
     ret = '<h2>Add content</h2>'
     content_view = self.section.handler.request.get('content_view') if self.section.handler.request.get('content_view') else ''
     namespace = self.section.handler.request.get('namespace').replace('/', '-').replace(' ', '-').replace('.', '-').lower() if self.section.handler.request.get('namespace') else ''
     if namespace:
         existing_content = content.get_by_namespace(namespace)
         existing_content_type = existing_content.__class__.__name__ if existing_content else None
         # TODO: Ensure that the below actually exist
         rank = int(self.section.path_params[0])
         content_type, view = content_view.split('.')
     if self.section.handler.request.get('submit') and not content_view:
         ret += '<div class="status error">Content is required</div>'
     elif self.section.handler.request.get('submit') and not namespace:
         ret += '<div class="status error">Namespace is required</div>'
     elif self.section.handler.request.get('submit') and existing_content_type:
         if existing_content_type != content_type:
             ret += '<div class="status error">Selected namespace already exists for a different type of content</div>'
         else:
             if existing_content.section_path and not permission.is_admin(existing_content.section_path):
                 ret += '<div class="status error">Selected namespace already exists for content that you are not permitted to manage</div>'
             elif self.section.handler.request.get('confirm'):
                 self.content_types.insert(rank, existing_content.__class__.__name__)
                 self.content_paths.insert(rank, existing_content.section_path if existing_content.section_path else '')
                 self.content_namespaces.insert(rank, namespace)
                 self.content_views.insert(rank, view)
                 self.update()
                 ret += str(existing_content)
                 raise Exception('Redirect', self.section.action_redirect_path)
             else:
                 ret += '<div class="status progress">Selected namespace already exists, continue to add a view to this existing content</div>'
                 f = form(self.section, self.section.full_path)
                 f.add_control(control(self.section, 'hidden', 'content_view', content_view))
                 f.add_control(control(self.section, 'hidden', 'namespace', namespace))
                 f.add_control(control(self.section, 'hidden', 'confirm', '1'))
                 f.add_control(control(self.section, 'submit', 'submit', 'Confirm'))
                 ret += unicode(f)
                 return ret
     elif self.section.handler.request.get('submit'):
         content.get_else_create(self.section.path, content_type, namespace, self.namespace)
         self.content_types.insert(rank, content_type)
         self.content_paths.insert(rank, self.section_path if self.section_path else '')
         self.content_namespaces.insert(rank, namespace)
         self.content_views.insert(rank, view)
         self.update()
         raise Exception('Redirect', self.section.action_redirect_path)
     content_views = [['', '']]
     for content_type in content.get_all_content_types():
         m = importlib.import_module('framework.content.' + content_type.lower())
         views = []
         for v in getattr(m, content_type.title())().views:
             if v[2]:
                 views.append([content_type + '.' + v[0], v[1]])
         if views:
             content_views.append([content_type, views])
     f = form(self.section, self.section.full_path)
     f.add_control(selectcontrol(self.section, 'content_view', content_views, content_view, 'Content type'))
     f.add_control(control(self.section, 'text', 'namespace', namespace, 'Namespace'))
     f.add_control(control(self.section, 'submit', 'submit', 'Submit'))
     ret += unicode(f)
     return ret
コード例 #3
0
ファイル: __init__.py プロジェクト: apunj001/gae-cms
 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
ファイル: __init__.py プロジェクト: apunj001/gae-cms
 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)
コード例 #5
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)
コード例 #6
0
ファイル: __init__.py プロジェクト: apunj001/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)
コード例 #7
0
ファイル: __init__.py プロジェクト: apunj001/gae-cms
 def action_add(self):
     ret = '<h2>Add content</h2>'
     content_view = self.section.handler.request.get(
         'content_view') if self.section.handler.request.get(
             'content_view') else ''
     namespace = self.section.handler.request.get('namespace').replace(
         '/', '-').replace(' ', '-').replace('.', '-').lower(
         ) if self.section.handler.request.get('namespace') else ''
     if namespace:
         existing_content = content.get_by_namespace(namespace)
         existing_content_type = existing_content.__class__.__name__ if existing_content else None
         # TODO: Ensure that the below actually exist
         rank = int(self.section.path_params[0])
         content_type, view = content_view.split('.')
     if self.section.handler.request.get('submit') and not content_view:
         ret += '<div class="status error">Content is required</div>'
     elif self.section.handler.request.get('submit') and not namespace:
         ret += '<div class="status error">Namespace is required</div>'
     elif self.section.handler.request.get(
             'submit') and existing_content_type:
         if existing_content_type != content_type:
             ret += '<div class="status error">Selected namespace already exists for a different type of content</div>'
         else:
             if existing_content.section_path and not permission.is_admin(
                     existing_content.section_path):
                 ret += '<div class="status error">Selected namespace already exists for content that you are not permitted to manage</div>'
             elif self.section.handler.request.get('confirm'):
                 self.content_types.insert(
                     rank, existing_content.__class__.__name__)
                 self.content_paths.insert(
                     rank, existing_content.section_path
                     if existing_content.section_path else '')
                 self.content_namespaces.insert(rank, namespace)
                 self.content_views.insert(rank, view)
                 self.update()
                 ret += str(existing_content)
                 raise Exception('Redirect',
                                 self.section.action_redirect_path)
             else:
                 ret += '<div class="status progress">Selected namespace already exists, continue to add a view to this existing content</div>'
                 f = form(self.section, self.section.full_path)
                 f.add_control(
                     control(self.section, 'hidden', 'content_view',
                             content_view))
                 f.add_control(
                     control(self.section, 'hidden', 'namespace',
                             namespace))
                 f.add_control(
                     control(self.section, 'hidden', 'confirm', '1'))
                 f.add_control(
                     control(self.section, 'submit', 'submit', 'Confirm'))
                 ret += unicode(f)
                 return ret
     elif self.section.handler.request.get('submit'):
         content.get_else_create(self.section.path, content_type, namespace,
                                 self.namespace)
         self.content_types.insert(rank, content_type)
         self.content_paths.insert(
             rank, self.section_path if self.section_path else '')
         self.content_namespaces.insert(rank, namespace)
         self.content_views.insert(rank, view)
         self.update()
         raise Exception('Redirect', self.section.action_redirect_path)
     content_views = [['', '']]
     for content_type in content.get_all_content_types():
         m = importlib.import_module('framework.content.' +
                                     content_type.lower())
         views = []
         for v in getattr(m, content_type.title())().views:
             if v[2]:
                 views.append([content_type + '.' + v[0], v[1]])
         if views:
             content_views.append([content_type, views])
     f = form(self.section, self.section.full_path)
     f.add_control(
         selectcontrol(self.section, 'content_view', content_views,
                       content_view, 'Content type'))
     f.add_control(
         control(self.section, 'text', 'namespace', namespace, 'Namespace'))
     f.add_control(control(self.section, 'submit', 'submit', 'Submit'))
     ret += unicode(f)
     return ret
コード例 #8
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) })
コード例 #9
0
ファイル: __init__.py プロジェクト: apunj001/gae-cms
 def view_menu(self, params=None):
     return template.snippet('navigation-menu', { 'content': self, 'is_admin': permission.is_admin(self.section.path) })