def _migrate_question(self, old_question, pos=None, is_deleted=False): assert old_question not in self.question_map question = AbstractReviewQuestion(position=pos, text=convert_to_unicode(old_question._text), is_deleted=is_deleted) self.question_map[old_question] = question self.event.abstract_review_questions.append(question) return question
def test_abstract_review_scale_ratings(db, dummy_abstract, dummy_event, dummy_user, value, scale_min, scale_max, expected): from indico.modules.events.abstracts.controllers.management import RHManageAbstractReviewing abstracts_reviewing_settings.set(dummy_event, 'scale_lower', 0) abstracts_reviewing_settings.set(dummy_event, 'scale_upper', 5) question = AbstractReviewQuestion(field_type='rating', title='Rating') dummy_event.abstract_review_questions.append(question) review = AbstractReview( abstract=dummy_abstract, track=Track(title='Dummy Track', event=dummy_event), user=dummy_user, proposed_action=AbstractAction.accept ) rating = AbstractReviewRating(question=question, value=value) review.ratings.append(rating) db.session.flush() rh = RHManageAbstractReviewing() rh.event = dummy_event rh._scale_ratings(scale_min, scale_max) assert rating.value == expected
def process_formdata(self, valuelist): super(AbstractReviewQuestionsField, self).process_formdata(valuelist) if valuelist: existing = {x.id: x for x in self.object_data or ()} data = [] for pos, entry in enumerate(self.data, 1): question = existing.pop(int(entry['id'])) if entry.get( 'id') is not None else AbstractReviewQuestion() question.text = entry['text'] question.position = pos question.no_score = entry['no_score'] data.append(question) for question in existing.itervalues(): if question.ratings: # keep it around and soft-delete if it has been used; otherwise we just skip it # which will delete it once it's gone from the relationship (when populating the # Event from the form's data) question.is_deleted = True data.append(question) self.data = data
def _process_args(self): RHManageAbstractsBase._process_args(self) self.question = AbstractReviewQuestion.get_one( request.view_args['question_id'])
def _clone_review_questions(self, new_event): attrs = get_simple_column_attrs(AbstractReviewQuestion) for old_question in self.old_event.abstract_review_questions: question = AbstractReviewQuestion() question.populate_from_attrs(old_question, attrs) new_event.abstract_review_questions.append(question)
def _process_args(self): RHManageAbstractsBase._process_args(self) self.question = AbstractReviewQuestion.get_one(request.view_args['question_id'])