- 1
- 2
- 3
- 4
- 5
obj_l = list()
for obj, obj_id in [(QuizQuestion, quest_id), (QuizAssigment, ass_id), (QuizQuestionAnswer, answ_id)]:
q_set = getattr(getattr(obj, 'objects'), 'filter')(id=obj_id)
obj_l.append(getattr(q_set, 'count')() > 0 and q_set[0] or False)
(False in obj_l or obj_l[2].question != obj_l[0] or (user and obj_l[0].user)) and abort(IntegrityError())