Example #1
0
    def _filterFields(fields):
        fields['name'] = removeSpecialChars( fields.get('name', '') )

        if 'segment' in fields:
            fields['segment'] = translit( fields['segment'] )
        else:
            fields['segment'] = translit( fields['name'] )

        fields['title'] = fields.get('title', '')
        fields['title'] = removeSpecialChars( fields['title'] ) if fields['title'] else fields['name']
        fields['pid'] = fields.get('pid', None)
    
        return fields
Example #2
0
def update(id):
    fields = request.get_json()

    node = _read(id)
    if 'name' in fields:
        node.name = removeSpecialChars( fields['name'] )
    if 'title' in fields:
        node.title = removeSpecialChars( fields['title'] )
    if 'segment' in fields:
        node.segment = translit( fields['segment'] )
    dbsess.add(node)
    dbsess.commit()

    return node