예제 #1
0
파일: views.py 프로젝트: Ruxton92/Leggera
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()
예제 #2
0
파일: views.py 프로젝트: Ruxton92/Leggera
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
    )