restapi/app/routes/question.py
def update_question_for_type(question_id):
	"""
	"	admin change question name for type
	"""
	try:
		review_type = request.args.get('type', '')
		if len(review_type) == 0:
			return response_error(MESSAGE.TYPE_INVALID, CODE.TYPE_INVALID)
		
		t = db.session.query(ReviewType).filter(ReviewType.name==func.binary(review_type)).first()
		if t is None:
			return response_error(MESSAGE.TYPE_INVALID, CODE.TYPE_INVALID)

		question = db.session.query(Question).filter(Question.id==question_id, Question.type_id==t.id).first()
		if question is None:
			return response_error(MESSAGE.QUESTION_NOT_EXIST, CODE.QUESTION_NOT_EXIST)

		if request.method == 'PUT':
			data = request.json
			if data is None:
				return response_error(MESSAGE.INVALID_DATA, CODE.INVALID_DATA)

			name = data.get('name', '')
			question.name = name

		else:
			db.session.delete(question)

		db.session.commit()
		return response_ok()
	except Exception, ex:
		db.session.rollback()
		return response_error(ex.message)

	"	admin change question name for type
	
"       admin change question name for type
" admin change question name for type
def update_question_for_type(question_id):
	try:
		review_type = request.args.get('type', '')
		if len(review_type) == 0:
			return response_error(MESSAGE.TYPE_INVALID, CODE.TYPE_INVALID)
		t = db.session.query(ReviewType).filter(ReviewType.name==func.binary(review_type)).first()
		if t is None:
			return response_error(MESSAGE.TYPE_INVALID, CODE.TYPE_INVALID)
		question = db.session.query(Question).filter(Question.id==question_id, Question.type_id==t.id).first()
		if question is None:
			return response_error(MESSAGE.QUESTION_NOT_EXIST, CODE.QUESTION_NOT_EXIST)
		if request.method == 'PUT':
			data = request.json
			if data is None:
				return response_error(MESSAGE.INVALID_DATA, CODE.INVALID_DATA)
			name = data.get('name', '')
			question.name = name
		else:
			db.session.delete(question)
		db.session.commit()
		return response_ok()
	except Exception, ex:
		db.session.rollback()
		return response_error(ex.message)
def update_question_for_type ( question_id ) : try : review_type = request . args . get ( 'type' , '' ) if len ( review_type ) == 0 : return response_error ( MESSAGE . TYPE_INVALID , CODE . TYPE_INVALID ) t = db . session . query ( ReviewType ) . filter ( ReviewType . name == func . binary ( review_type ) ) . first ( ) if t is None : return response_error ( MESSAGE . TYPE_INVALID , CODE . TYPE_INVALID ) question = db . session . query ( Question ) . filter ( Question . id == question_id , Question . type_id == t . id ) . first ( ) if question is None : return response_error ( MESSAGE . QUESTION_NOT_EXIST , CODE . QUESTION_NOT_EXIST ) if request . method == 'PUT' : data = request . json if data is None : return response_error ( MESSAGE . INVALID_DATA , CODE . INVALID_DATA ) name = data . get ( 'name' , '' ) question . name = name else : db . session . delete ( question ) db . session . commit ( ) return response_ok ( ) except Exception , ex : db . session . rollback ( ) return response_error ( ex . message )
"       admin change question name for type
" admin change question name for type
"""
	"	admin change question name for type
	"""
question_id