def code_new(category_id, cat_type): lang = 'en' code = Code(lang=lang) code.status = 'edit' code.category_id = category_id db.session.add(code) db.session.commit() return redirect(url_for_admin('code_edit', id=code.code_id, cat_type=cat_type))
def code_trans(id, cat_type): lang = get_admin_lang() code = Code.query.filter_by(code_id=id, lang='en').first() if not code: abort(404) exists = Code.query.filter_by(code_id=code.code_id, lang=lang).first() if exists: abort(403) trans = Code(lang=lang) trans.status = 'edit' trans.code_id = id trans.category_id = code.category_id db.session.add(trans) db.session.commit() return redirect(url_for_admin('code_edit', id=id, cat_type=cat_type))