Пример #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()