Exemplo n.º 1
0
def get_manage_links(item):
    ret = '<a href="/' + item['path'] + '/navigation/edit" class="edit" title="Edit">Edit</a><a href="/' + item['path'] + '/navigation/create" class="subsection" title="Create subsection">, Create subsection</a>'
    if len(section.get_siblings(item['path'])) > 1:
        ret += '<a href="/' + item['path'] + '/navigation/reorder" class="reorder" title="Reorder">, Reorder</a>'
    else:
        ret += '<span class="reorder-disabled" title="Not reorderable, has no siblings">, Not reorderable</span>'
    if not item['is_default'] and not section.get_children(item['path']):
        ret += '<a href="/' + item['path'] + '/navigation/delete" class="delete" title="Delete">, Delete]</a>'
    else:
        ret += '<span class="delete-disabled" title="Not deletable, either default or has children">, Not deletable]</span>'
    return ret
Exemplo n.º 2
0
def get_manage_links(item):
    ret = '<a href="/' + item['path'] + '/navigation/edit" class="edit" title="Edit">Edit</a><a href="/' + item['path'] + '/navigation/create" class="subsection" title="Create subsection">, Create subsection</a>'
    if len(section.get_siblings(item['path'])) > 1:
        ret += '<a href="/' + item['path'] + '/navigation/reorder" class="reorder" title="Reorder">, Reorder</a>'
    else:
        ret += '<span class="reorder-disabled" title="Not reorderable, has no siblings">, Not reorderable</span>'
    if not item['is_default'] and not section.get_children(item['path']):
        ret += '<a href="/' + item['path'] + '/navigation/delete" class="delete" title="Delete">, Delete]</a>'
    else:
        ret += '<span class="delete-disabled" title="Not deletable, either default or has children">, Not deletable]</span>'
    return ret
Exemplo n.º 3
0
 def action_reorder(self):
     siblings = section.get_siblings(self.section.path)
     if not len(siblings) > 1: raise Exception('BadRequest')
     if self.section.handler.request.get('submit'):
         new_rank = int(self.section.handler.request.get('rank'))
         if self.section.rank != new_rank:
             section.update_section_rank(self.section, new_rank)
         raise Exception('Redirect', self.section.action_redirect_path)
     f = form(self.section, self.section.full_path)
     items = [[0, 'At the top']]
     adder = 1
     for item, _ in siblings:
         if self.section.rank != item['rank']:
             items.append([item['rank'] + adder, 'After ' + item['path']])
         else:
             adder = 0
     f.add_control(selectcontrol(self.section, 'rank', items, self.section.rank, 'Position'))
     f.add_control(control(self.section, 'submit', 'submit'))
     return '<h2>Reorder section "%s"</h2>%s' % (self.section.path, unicode(f))
Exemplo n.º 4
0
 def action_reorder(self):
     siblings = section.get_siblings(self.section.path)
     if not len(siblings) > 1: raise Exception('BadRequest')
     if self.section.handler.request.get('submit'):
         new_rank = int(self.section.handler.request.get('rank'))
         if self.section.rank != new_rank:
             section.update_section_rank(self.section, new_rank)
         raise Exception('Redirect', self.section.action_redirect_path)
     f = form(self.section, self.section.full_path)
     items = [[0, 'At the top']]
     adder = 1
     for item, _ in siblings:
         if self.section.rank != item['rank']:
             items.append([item['rank'] + adder, 'After ' + item['path']])
         else:
             adder = 0
     f.add_control(selectcontrol(self.section, 'rank', items, self.section.rank, 'Position'))
     f.add_control(control(self.section, 'submit', 'submit'))
     return '<h2>Reorder section "%s"</h2>%s' % (self.section.path, unicode(f))