Example #1
0
    def _migrate_review(self, contribution, old_judgment, review_type):
        # Consider legacy custom states the same as "to be corrected"
        proposed_action = JUDGMENT_STATE_PAPER_ACTION_MAP.get(
            int(old_judgment._judgement._id), PaperAction.to_be_corrected)
        review = PaperReview(
            user=self.global_ns.avatar_merged_user[old_judgment._author.id],
            comment=convert_to_unicode(old_judgment._comments),
            type=review_type,
            proposed_action=proposed_action,
            created_dt=_to_utc(old_judgment._submissionDate))
        for old_answer in old_judgment._answers:
            old_question = old_answer._question
            try:
                question = self.legacy_question_map[old_question]
            except KeyError:
                self.print_warning(
                    '%[yellow!]Answer to deleted question {} has been ignored [{}, {}]'
                    .format(old_question._id, contribution, review_type))
                continue

            assert old_answer._rbValue >= 0 and old_answer._rbValue <= 6
            rating = PaperReviewRating(question=question,
                                       value=(old_answer._rbValue - 3))
            review.ratings.append(rating)
        return review
Example #2
0
def create_review(paper, review_type, user, review_data, questions_data):
    review = PaperReview(revision=paper.last_revision,
                         type=review_type.instance,
                         user=user)
    review.populate_from_dict(review_data)
    log_data = {}
    for question in paper.event.cfp.get_questions_for_review_type(
            review_type.instance):
        value = questions_data[f'question_{question.id}']
        review.ratings.append(PaperReviewRating(question=question,
                                                value=value))
        log_data[question.title] = question.field.get_friendly_value(value)
    db.session.flush()
    notify_paper_review_submission(review)
    logger.info("Paper %r received a review of type %s by %r", paper,
                review_type.instance.name, user)
    log_data.update({
        'Type': orig_string(review_type.title),
        'Action': orig_string(review.proposed_action.title),
        'Comment': review.comment
    })
    paper.event.log(
        EventLogRealm.reviewing,
        EventLogKind.positive,
        'Papers',
        f'Paper for contribution {paper.contribution.verbose_title} reviewed',
        user,
        data=log_data)
    return review
Example #3
0
def test_paper_review_scale_ratings(db, dummy_paper, dummy_event, dummy_user,
                                    value, scale_min, scale_max, expected):
    from indico.modules.events.papers.controllers.management import RHManageReviewingSettings
    paper_reviewing_settings.set(dummy_event, 'scale_lower', -3)
    paper_reviewing_settings.set(dummy_event, 'scale_upper', 3)

    question = PaperReviewQuestion(type=PaperReviewType.content,
                                   field_type='rating',
                                   title='Rating')
    dummy_event.paper_review_questions.append(question)
    revision = PaperRevision(submitter=dummy_user, paper=dummy_paper)
    review = PaperReview(type=PaperReviewType.content,
                         user=dummy_user,
                         proposed_action=PaperAction.accept)
    revision.reviews.append(review)
    rating = PaperReviewRating(question=question, value=value)
    review.ratings.append(rating)
    db.session.flush()

    rh = RHManageReviewingSettings()
    rh.event = dummy_event
    rh._scale_ratings(scale_min, scale_max)
    assert rating.value == expected