Exemplo n.º 1
0
 def _value(self):
     return {
         'notify_on_added_to_event': [x.name for x in settings.get(self.event, 'notify_on_added_to_event')],
         'notify_on_assigned_contrib': [x.name for x in settings.get(self.event, 'notify_on_assigned_contrib')],
         'notify_on_paper_submission': [x.name for x in settings.get(self.event, 'notify_on_paper_submission')],
         'notify_judge_on_review': settings.get(self.event, 'notify_judge_on_review'),
         'notify_author_on_judgment': settings.get(self.event, 'notify_author_on_judgment')
     }
Exemplo n.º 2
0
 def _process(self):
     role = PaperReviewingRole[request.view_args['role']]
     deadline = paper_reviewing_settings.get(self.event, '{}_deadline'.format(role.name))
     enforce = paper_reviewing_settings.get(self.event, 'enforce_{}_deadline'.format(role.name))
     form = DeadlineForm(obj=FormDefaults(deadline=deadline, enforce=enforce), event=self.event)
     if form.validate_on_submit():
         set_deadline(self.event, role, form.deadline.data, form.enforce.data)
         messages = {
             PaperReviewingRole.content_reviewer: _('Content reviewing deadline has been set.'),
             PaperReviewingRole.layout_reviewer: _('Layout reviewing deadline has been set.'),
             PaperReviewingRole.judge: _('Judging deadline has been set.')
         }
         flash(messages[role], 'success')
         return jsonify_data(html=_render_paper_dashboard(self.event))
     return jsonify_form(form)
Exemplo n.º 3
0
 def _process(self):
     role = PaperReviewingRole[request.view_args['role']]
     deadline = paper_reviewing_settings.get(self.event, '{}_deadline'.format(role.name))
     enforce = paper_reviewing_settings.get(self.event, 'enforce_{}_deadline'.format(role.name))
     form = DeadlineForm(obj=FormDefaults(deadline=deadline, enforce=enforce), event=self.event)
     if form.validate_on_submit():
         set_deadline(self.event, role, form.deadline.data, form.enforce.data)
         messages = {
             PaperReviewingRole.content_reviewer: _('Content reviewing deadline has been set.'),
             PaperReviewingRole.layout_reviewer: _('Layout reviewing deadline has been set.'),
             PaperReviewingRole.judge: _('Judging deadline has been set.')
         }
         flash(messages[role], 'success')
         return jsonify_data(html=_render_paper_dashboard(self.event))
     return jsonify_form(form)
Exemplo n.º 4
0
def notify_paper_revision_submission(revision):
    event = revision.paper.event_new
    roles_to_notify = paper_reviewing_settings.get(
        event, 'notify_on_paper_submission')
    if PaperReviewingRole.judge in roles_to_notify:
        for judge in revision.paper.contribution.paper_judges:
            template = get_template_module(
                'events/papers/emails/revision_submission_to_judge.html',
                event=event,
                revision=revision,
                receiver=judge)
            email = make_email(to_list=judge.email,
                               template=template,
                               html=True)
            send_email(email, event=event, module='Papers', user=session.user)
    reviewers = set()
    if PaperReviewingRole.layout_reviewer in roles_to_notify:
        reviewers |= revision.paper.contribution.paper_layout_reviewers
    if PaperReviewingRole.content_reviewer in roles_to_notify:
        reviewers |= revision.paper.contribution.paper_content_reviewers
    for reviewer in reviewers:
        template = get_template_module(
            'events/papers/emails/revision_submission_to_reviewer.html',
            event=event,
            revision=revision,
            receiver=reviewer)
        email = make_email(to_list=reviewer.email,
                           template=template,
                           html=True)
        send_email(email, event=event, module='Papers', user=session.user)
Exemplo n.º 5
0
def update_team_members(event,
                        managers,
                        judges,
                        content_reviewers=None,
                        layout_reviewers=None):
    updated = {}
    update_object_principals(event, managers, permission='paper_manager')
    updated[PaperReviewingRole.judge] = update_object_principals(
        event, judges, permission='paper_judge')
    if content_reviewers is not None:
        updated[
            PaperReviewingRole.content_reviewer] = update_object_principals(
                event, content_reviewers, permission='paper_content_reviewer')
    if layout_reviewers is not None:
        updated[PaperReviewingRole.layout_reviewer] = update_object_principals(
            event, layout_reviewers, permission='paper_layout_reviewer')
    unassigned_contribs = _unassign_removed(event, updated)
    roles_to_notify = paper_reviewing_settings.get(event,
                                                   'notify_on_added_to_event')
    for role, changes in updated.items():
        if role not in roles_to_notify:
            continue
        for user in changes['added']:
            notify_added_to_reviewing_team(user, role, event)
        for user in changes['removed']:
            notify_removed_from_reviewing_team(user, role, event)

    logger.info("Paper teams of %r updated by %r", event, session.user)
    return unassigned_contribs
Exemplo n.º 6
0
    def _scale_ratings(self, scale_min, scale_max):
        prev_min = paper_reviewing_settings.get(self.event, 'scale_lower')
        prev_max = paper_reviewing_settings.get(self.event, 'scale_upper')
        if scale_min == prev_min and scale_max == prev_max:
            return
        assert scale_max > scale_min

        paper_reviewing_settings.set_multi(self.event, {
            'scale_lower': scale_min,
            'scale_upper': scale_max,
        })
        for rating in self.ratings_query:
            if rating.value is None:
                continue
            value = (rating.value - prev_min) / (prev_max - prev_min)
            rating.value = round(value * (scale_max - scale_min) + scale_min)
Exemplo n.º 7
0
def update_team_members(event, managers, judges, content_reviewers=None, layout_reviewers=None):
    updated = {}
    update_object_principals(event, managers, permission='paper_manager')
    updated[PaperReviewingRole.judge] = update_object_principals(event, judges, permission='paper_judge')
    if content_reviewers is not None:
        updated[PaperReviewingRole.content_reviewer] = update_object_principals(event, content_reviewers,
                                                                                permission='paper_content_reviewer')
    if layout_reviewers is not None:
        updated[PaperReviewingRole.layout_reviewer] = update_object_principals(event, layout_reviewers,
                                                                               permission='paper_layout_reviewer')
    unassigned_contribs = _unassign_removed(event, updated)
    roles_to_notify = paper_reviewing_settings.get(event, 'notify_on_added_to_event')
    if PaperReviewingRole.judge in roles_to_notify:
        for judge in updated[PaperReviewingRole.judge]['added']:
            notify_added_to_reviewing_team(judge, PaperReviewingRole.judge, event)
        for judge in updated[PaperReviewingRole.judge]['removed']:
            notify_removed_from_reviewing_team(judge, PaperReviewingRole.judge, event)
    if PaperReviewingRole.content_reviewer in roles_to_notify:
        for reviewer in updated[PaperReviewingRole.content_reviewer]['added']:
            notify_added_to_reviewing_team(reviewer, PaperReviewingRole.content_reviewer, event)
        for reviewer in updated[PaperReviewingRole.content_reviewer]['removed']:
            notify_removed_from_reviewing_team(reviewer, PaperReviewingRole.content_reviewer, event)
    if PaperReviewingRole.layout_reviewer in roles_to_notify:
        for reviewer in updated[PaperReviewingRole.layout_reviewer]['added']:
            notify_added_to_reviewing_team(reviewer, PaperReviewingRole.layout_reviewer, event)
        for reviewer in updated[PaperReviewingRole.layout_reviewer]['removed']:
            notify_removed_from_reviewing_team(reviewer, PaperReviewingRole.layout_reviewer, event)
    logger.info("Paper teams of %r updated by %r", event, session.user)
    return unassigned_contribs
Exemplo n.º 8
0
def update_reviewing_roles(event, users, contributions, role, assign):
    role_map = {
        PaperReviewingRole.judge: attrgetter('paper_judges'),
        PaperReviewingRole.content_reviewer: attrgetter('paper_content_reviewers'),
        PaperReviewingRole.layout_reviewer: attrgetter('paper_layout_reviewers'),
    }

    for contrib in contributions:
        role_group = role_map[role](contrib)
        for user in users:
            if assign:
                role_group.add(user)
            else:
                role_group.discard(user)

    contrib_ids = ['#{}'.format(c.friendly_id) for c in sorted(contributions, key=attrgetter('friendly_id'))]
    log_data = {'Users': ', '.join(sorted(person.full_name for person in users)),
                'Contributions': ', '.join(contrib_ids)}
    roles_to_notify = paper_reviewing_settings.get(event, 'notify_on_assigned_contrib')
    if role in roles_to_notify:
        for user in users:
            notify_paper_assignment(user, role, contributions, event, assign)
    if assign:
        event.log(EventLogRealm.reviewing, EventLogKind.positive, 'Papers',
                  'Papers assigned ({})'.format(orig_string(role.title)), session.user, data=log_data)
    else:
        event.log(EventLogRealm.reviewing, EventLogKind.negative, 'Papers',
                  'Papers unassigned ({})'.format(orig_string(role.title)), session.user, data=log_data)
    db.session.flush()
    logger.info('Paper reviewing roles in event %r updated by %r', event, session.user)
Exemplo n.º 9
0
def update_reviewing_roles(event, users, contributions, role, assign):
    role_map = {
        PaperReviewingRole.judge: attrgetter('paper_judges'),
        PaperReviewingRole.content_reviewer: attrgetter('paper_content_reviewers'),
        PaperReviewingRole.layout_reviewer: attrgetter('paper_layout_reviewers'),
    }

    for contrib in contributions:
        role_group = role_map[role](contrib)
        for user in users:
            if assign:
                role_group.add(user)
            else:
                role_group.discard(user)

    contrib_ids = [f'#{c.friendly_id}' for c in sorted(contributions, key=attrgetter('friendly_id'))]
    log_data = {'Users': ', '.join(sorted(person.full_name for person in users)),
                'Contributions': ', '.join(contrib_ids)}
    roles_to_notify = paper_reviewing_settings.get(event, 'notify_on_assigned_contrib')
    if role in roles_to_notify:
        for user in users:
            notify_paper_assignment(user, role, contributions, event, assign)
    if assign:
        event.log(EventLogRealm.reviewing, EventLogKind.positive, 'Papers',
                  f'Papers assigned ({orig_string(role.title)})', session.user, data=log_data)
    else:
        event.log(EventLogRealm.reviewing, EventLogKind.negative, 'Papers',
                  f'Papers unassigned ({orig_string(role.title)})', session.user, data=log_data)
    db.session.flush()
    logger.info('Paper reviewing roles in event %r updated by %r', event, session.user)
Exemplo n.º 10
0
def notify_paper_review_submission(review):
    event = review.revision.paper.event
    if not paper_reviewing_settings.get(event, 'notify_judge_on_review'):
        return
    for judge in review.revision.paper.contribution.paper_judges:
        template = get_template_module('events/papers/emails/review_submission_to_judge.html', event=event,
                                       review=review, contribution=review.revision.paper.contribution, receiver=judge)
        email = make_email(to_list=judge.email, template=template, html=True)
        send_email(email, event=event, module='Papers', user=session.user)
Exemplo n.º 11
0
def notify_paper_review_submission(review):
    event = review.revision.paper.event
    if not paper_reviewing_settings.get(event, 'notify_judge_on_review'):
        return
    for judge in review.revision.paper.contribution.paper_judges:
        template = get_template_module('events/papers/emails/review_submission_to_judge.html', event=event,
                                       review=review, contribution=review.revision.paper.contribution, receiver=judge)
        email = make_email(to_list=judge.email, template=template, html=True)
        send_email(email, event=event, module='Papers', user=session.user)
Exemplo n.º 12
0
def notify_paper_judgment(paper, reset=False):
    event = paper.event
    authors = [x for x in paper.contribution.person_links if x.is_author]
    recipients = ([x for x in authors if x.email] if paper.last_revision.submitter.is_system
                  else [paper.last_revision.submitter])
    template_file = None
    if reset:
        template_file = 'events/papers/emails/judgment_reset_to_author.html'
    elif paper_reviewing_settings.get(event, 'notify_author_on_judgment'):
        template_file = 'events/papers/emails/judgment_to_author.html'

    if not template_file:
        return
    for receiver in recipients:
        template = get_template_module(template_file, event=event, paper=paper, contribution=paper.contribution,
                                       receiver=receiver)
        email = make_email(to_list=receiver.email, template=template, html=True)
        send_email(email, event=event, module='Papers', user=session.user)
Exemplo n.º 13
0
def notify_paper_judgment(paper, reset=False):
    event = paper.event
    authors = [x for x in paper.contribution.person_links if x.is_author]
    recipients = ([x for x in authors if x.email] if paper.last_revision.submitter.is_system
                  else [paper.last_revision.submitter])
    template_file = None
    if reset:
        template_file = 'events/papers/emails/judgment_reset_to_author.html'
    elif paper_reviewing_settings.get(event, 'notify_author_on_judgment'):
        template_file = 'events/papers/emails/judgment_to_author.html'

    if not template_file:
        return
    for receiver in recipients:
        template = get_template_module(template_file, event=event, paper=paper, contribution=paper.contribution,
                                       receiver=receiver)
        email = make_email(to_list=receiver.email, template=template, html=True)
        send_email(email, event=event, module='Papers', user=session.user)
Exemplo n.º 14
0
def notify_paper_revision_submission(revision):
    event = revision.paper.event
    roles_to_notify = paper_reviewing_settings.get(event, 'notify_on_paper_submission')
    if PaperReviewingRole.judge in roles_to_notify:
        for judge in revision.paper.contribution.paper_judges:
            template = get_template_module('events/papers/emails/revision_submission_to_judge.html', event=event,
                                           revision=revision, receiver=judge)
            email = make_email(to_list=judge.email, template=template, html=True)
            send_email(email, event=event, module='Papers', user=session.user)
    reviewers = set()
    if PaperReviewingRole.layout_reviewer in roles_to_notify:
        reviewers |= revision.paper.contribution.paper_layout_reviewers
    if PaperReviewingRole.content_reviewer in roles_to_notify:
        reviewers |= revision.paper.contribution.paper_content_reviewers
    for reviewer in reviewers:
        template = get_template_module('events/papers/emails/revision_submission_to_reviewer.html', event=event,
                                       revision=revision, receiver=reviewer)
        email = make_email(to_list=reviewer.email, template=template, html=True)
        send_email(email, event=event, module='Papers', user=session.user)
Exemplo n.º 15
0
 def rating_range(self):
     return tuple(
         paper_reviewing_settings.get(self.event, key)
         for key in ('scale_lower', 'scale_upper'))
Exemplo n.º 16
0
 def announcement(self):
     return MarkdownText(
         paper_reviewing_settings.get(self.event, 'announcement'))
Exemplo n.º 17
0
 def announcement(self):
     return MarkdownText(paper_reviewing_settings.get(self.event, 'announcement'))
Exemplo n.º 18
0
 def rating_range(self):
     return tuple(paper_reviewing_settings.get(self.event, key) for key in ('scale_lower', 'scale_upper'))