Beispiel #1
0
class PaperReviewingSettingsForm(IndicoForm):
    """Settings form for paper reviewing."""

    announcement = IndicoMarkdownField(_('Announcement'), editor=True)
    scale_lower = IntegerField(_('Scale (from)'), [InputRequired()])
    scale_upper = IntegerField(_('Scale (to)'), [InputRequired()])
    email_settings = PaperEmailSettingsField(_('Email notifications'))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        self.has_ratings = kwargs.pop('has_ratings', False)
        super().__init__(*args, **kwargs)
        if self.has_ratings:
            self.scale_upper.warning = _(
                'Changing the ratings scale will proportionally affect existing ratings.'
            )

    def validate_scale_upper(self, field):
        lower = self.scale_lower.data
        upper = self.scale_upper.data
        if lower is None or upper is None:
            return
        if lower >= upper:
            raise ValidationError(
                _("The scale's 'to' value must be greater than the 'from' value."
                  ))
        if upper - lower > 20:
            raise ValidationError(
                _("The difference between 'to' and' from' may not be greater than 20."
                  ))
Beispiel #2
0
class PaperReviewingSettingsForm(IndicoForm):
    """Settings form for paper reviewing"""

    RATING_FIELDS = ('scale_lower', 'scale_upper')

    announcement = IndicoMarkdownField(_('Announcement'), editor=True)
    scale_lower = IntegerField(_("Scale (from)"), [UsedIf(lambda form, field: not form.has_ratings), InputRequired()])
    scale_upper = IntegerField(_("Scale (to)"), [UsedIf(lambda form, field: not form.has_ratings), InputRequired()])
    email_settings = PaperEmailSettingsField(_("Email notifications"))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        self.has_ratings = kwargs.pop('has_ratings', False)
        super(PaperReviewingSettingsForm, self).__init__(*args, **kwargs)
        if self.has_ratings:
            self.scale_upper.warning = _("Some reviewers have already submitted ratings so the scale cannot be changed "
                                         "anymore.")

    def validate_scale_upper(self, field):
        lower = self.scale_lower.data
        upper = self.scale_upper.data
        if lower is None or upper is None:
            return
        if lower >= upper:
            raise ValidationError(_("The scale's 'to' value must be greater than the 'from' value."))
        if upper - lower > 20:
            raise ValidationError(_("The difference between 'to' and' from' may not be greater than 20."))

    @property
    def data(self):
        data = super(PaperReviewingSettingsForm, self).data
        if self.has_ratings:
            for key in self.RATING_FIELDS:
                del data[key]
        return data
Beispiel #3
0
class PaperReviewingSettingsForm(IndicoForm):
    content_review_questions = ReviewQuestionsField(
        _("Content review questions"),
        question_model=lambda: PaperReviewQuestion(type=PaperReviewType.content
                                                   ))
    layout_review_questions = ReviewQuestionsField(
        _("Layout review questions"),
        question_model=lambda: PaperReviewQuestion(type=PaperReviewType.layout
                                                   ))
    announcement = IndicoMarkdownField(_('Announcement'), editor=True)
    email_settings = PaperEmailSettingsField(_("Email notifications"))

    def __init__(self, *args, **kwargs):
        self.event = kwargs.pop('event')
        super(PaperReviewingSettingsForm, self).__init__(*args, **kwargs)
        if not self.event.cfp.content_reviewing_enabled:
            del self.content_review_questions
        if not self.event.cfp.layout_reviewing_enabled:
            del self.layout_review_questions