Пример #1
0
    def display_page_item(self, node_token, result, data, session):
        # TD doc string

        # check permissions etc
        if not self.permissions or authenticate.check_permission(self.permissions):
            # FIXME result.results[0] is horrible
            self.custom_control_display(node_token, result, data, session)
Пример #2
0
    def save_page_item(self, node_token, save_set, data, session):
        # TD doc string

        # check we are allowed to save this item
        # TD what about invisibles?
        if not self.permissions or authenticate.check_permission(self.permissions):
            self.custom_control_save(node_token, save_set, data, session)
Пример #3
0
 def build_items(items):
     # checks the permissions
     output = []
     for item in items:
         if not authenticate.check_permission(item.get('permissions')):
             continue
         menu_item = {}
         if 'title' in item:
             menu_item['title'] = item['title']
         if 'node' in item:
             menu_item['node'] = item['node']
         if 'function' in item:
             menu_item['function'] = item['function']
         if 'sub' in item:
             sub_items = build_items(item['sub'])
             if sub_items:
                 menu_item['sub'] = sub_items
         output.append(menu_item)
     return output
Пример #4
0
    def call(self, node_token):
        """called when the node is used.  Checks to see if there
        is a function to call for the given command"""

        # first check if the command is available
        command_info = self.commands.get(node_token.command)
        if not command_info:
            return
        # check we have the needed permissions
        if command_info.get('permissions'):
            if not authenticate.check_permission(command_info.get('permissions')):
                node_token.forbidden()
                print 'forbidden'
                return

        command = command_info.get('command')

        if command:
            command = getattr(self, command)
            command(node_token)
        else:
            error = "Command '%s' in node '%s' not known" % (node_token.command, self.name)
            node_token.general_error(error)
Пример #5
0
    def get_page_item_structure(self, node_token, data):

        if not self.permissions or authenticate.check_permission(self.permissions):
            return self.custom_page_item_structure(node_token, data)
Пример #6
0
 def delete_page_item(self, node_token, object, data, session):
     # TD doc string
     # FIXME Not called from anywhere AFAIK
     # check permissions etc
     if not self.permissions or authenticate.check_permission(self.permissions):
         self.custom_control_delete(node_token, object, data, session)
Пример #7
0
 def check_permissions(self):
     return authenticate.check_permission(self.permissions)