restapi/app/routes/question.py
def add_quesion_for_type():
	"""
	"	admin will add questions for object type which need to be reviewed
	"""
	try:
		data = request.json
		if data is None:
			return response_error(MESSAGE.INVALID_DATA, CODE.INVALID_DATA)

		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)

		for d in data:
			if 'name' in d:
				question = Question(
					name=d['name'],
					type_id=t.id
				)
				db.session.add(question)
				db.session.flush()

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

	"	admin will add questions for object type which need to be reviewed
	
"       admin will add questions for object type which need to be reviewed
" admin will add questions for object type which need to be reviewed
def add_quesion_for_type():
	try:
		data = request.json
		if data is None:
			return response_error(MESSAGE.INVALID_DATA, CODE.INVALID_DATA)
		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)
		for d in data:
			if 'name' in d:
				question = Question(
					name=d['name'],
					type_id=t.id
				)
				db.session.add(question)
				db.session.flush()
		db.session.commit()
		return response_ok()
	except Exception, ex:
		db.session.rollback()
		return response_error(ex.message)
def add_quesion_for_type ( ) : try : data = request . json if data is None : return response_error ( MESSAGE . INVALID_DATA , CODE . INVALID_DATA ) 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 ) for d in data : if 'name' in d : question = Question ( name = d [ 'name' ] , type_id = t . id ) db . session . add ( question ) db . session . flush ( ) db . session . commit ( ) return response_ok ( ) except Exception , ex : db . session . rollback ( ) return response_error ( ex . message )
"       admin will add questions for object type which need to be reviewed
" admin will add questions for object type which need to be reviewed
"""
	"	admin will add questions for object type which need to be reviewed
	"""