def template_rename_post(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') name = request.form['name'].strip() parent_id = request.form.get('parent_id', '') if not parent_id: parent_id = 0 Template.update_dict({'tpl_name': name, 'parent_id': parent_id}, 'id=%s', [tpl_id]) return jsonify(msg='')
def template_rename_post(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') name = request.form['name'].strip() parent_id = request.form.get('parent_id', '') if not parent_id: parent_id = 0 Template.update_dict({ 'tpl_name': name, 'parent_id': parent_id }, 'id=%s', [tpl_id]) return jsonify(msg='')
def template_action_update_post(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') uic = request.form['uic'].strip() url = request.form['url'].strip() callback = request.form['callback'].strip() before_callback_sms = request.form['before_callback_sms'].strip() before_callback_mail = request.form['before_callback_mail'].strip() after_callback_sms = request.form['after_callback_sms'].strip() after_callback_mail = request.form['after_callback_mail'].strip() if t.action_id > 0: # update Action.update_dict( { 'uic': uic, 'url': url, 'callback': callback, 'before_callback_sms': before_callback_sms, 'before_callback_mail': before_callback_mail, 'after_callback_sms': after_callback_sms, 'after_callback_mail': after_callback_mail }, 'id=%s', [t.action_id] ) else: # insert action_id = Action.insert({ 'uic': uic, 'url': url, 'callback': callback, 'before_callback_sms': before_callback_sms, 'before_callback_mail': before_callback_mail, 'after_callback_sms': after_callback_sms, 'after_callback_mail': after_callback_mail }) if action_id <= 0: return jsonify(msg='insert action fail') Template.update_dict({'action_id': action_id}, 'id=%s', [t.id]) return jsonify(msg='')
def template_action_update_post(tpl_id): tpl_id = int(tpl_id) t = Template.get(tpl_id) if not t: return jsonify(msg='no such template') uic = request.form['uic'].strip() url = request.form['url'].strip() callback = request.form['callback'].strip() before_callback_sms = request.form['before_callback_sms'].strip() before_callback_mail = request.form['before_callback_mail'].strip() after_callback_sms = request.form['after_callback_sms'].strip() after_callback_mail = request.form['after_callback_mail'].strip() if t.action_id > 0: # update Action.update_dict( { 'uic': uic, 'url': url, 'callback': callback, 'before_callback_sms': before_callback_sms, 'before_callback_mail': before_callback_mail, 'after_callback_sms': after_callback_sms, 'after_callback_mail': after_callback_mail }, 'id=%s', [t.action_id]) else: # insert action_id = Action.insert({ 'uic': uic, 'url': url, 'callback': callback, 'before_callback_sms': before_callback_sms, 'before_callback_mail': before_callback_mail, 'after_callback_sms': after_callback_sms, 'after_callback_mail': after_callback_mail }) if action_id <= 0: return jsonify(msg='insert action fail') Template.update_dict({'action_id': action_id}, 'id=%s', [t.id]) return jsonify(msg='')