示例#1
0
 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
示例#2
0
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
示例#3
0
 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
示例#4
0
 def _process_args(self):
     RHManageAbstractsBase._process_args(self)
     self.question = AbstractReviewQuestion.get_one(
         request.view_args['question_id'])
示例#5
0
 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)
示例#6
0
文件: clone.py 项目: bkolobara/indico
 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)
示例#7
0
 def _process_args(self):
     RHManageAbstractsBase._process_args(self)
     self.question = AbstractReviewQuestion.get_one(request.view_args['question_id'])