def board_modify(): send_data = OrderedDict() data = dict() if request.method == "POST": data['uuid'] = request.form['uuid'] data['title'] = request.form['subject'] data['contents'] = request.form['content'] send_data['status'] = 'error' db = DB() rows = db.get_board(data['uuid']) if session: if session['id'] == rows['id']: if db.modify_board(data): send_data['status'] = 'ok' files = request.files.getlist('file') if files: error = f_upload(data['uuid'], files) if error: db.delete_board(data['uuid']) send_data['msg'] = error else: send_data['status'] = 'fail' else: send_data['status'] = 'permission error' return jsonify(send_data)
def create(category): return_data = dict() return_data['status'] = "error" return_data['msg'] = '' if request.method == "POST": if session: data = dict() if 'notice' in request.form.keys(): data['notice'] = True else: data['notice'] = False data['id'] = session['id'] data['title'] = request.form['subject'] data['contents'] = request.form['content'] data['category'] = category data['hits'] = 0 data['uuid'] = str(uuid.uuid4()) mydb = DB() if mydb.create_board(data): files = request.files.getlist('file') if files: error = f_upload(data['uuid'], files) if error: mydb.delete_board(data['uuid']) return_data['msg'] = error else: return_data['status'] = "ok" del mydb else: del mydb return_data['status'] = "ok" else: del mydb return_data['status'] = "error" else: return_data['status'] = "permission error" return jsonify(return_data)