Beispiel #1
0
def save_content_block(form):
    cb = ContentBlock()
    for b in json.loads(form):
        if b.get('name') == 'cid':
            cb.cid = int(b.get('value'))
        elif b.get('name') == 'title':
            cb.title = b.get('value')
        elif b.get('name') == 'weight':
            cb.weight = int(b.get('value'))
        elif b.get('name') == 'category':
            cb.category = b.get('value')
        elif b.get('name') == 'content':
            cb.content = b.get('value')
    return cb.save()
Beispiel #2
0
def management_section_edit(section_id, args):
    curr_user = auth.current_user.username
    if int(section_id) > 0:
        cb = ContentBlock.get_by_id(int(section_id))
    else:
        cb = ContentBlock()
        cb.cid = 0
        cb.title = 'New block'
        cb.content = ''
        cb.category = args if args else 'block'
        cb.weight = 1
    return bottle.template('./templates/admin_content_detail',
        username=curr_user,
        pathname=bottle.request.path,
        block = cb
    )