Example #1
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
Example #2
0
    def _process(self):
        roles = get_roles_for_event(self.event)
        form = AbstractReviewingRolesForm(event=self.event,
                                          obj=FormDefaults(roles=roles))

        if form.validate_on_submit():
            role_data = form.roles.role_data
            self.event.global_conveners = set(role_data['global_conveners'])
            self.event.global_abstract_reviewers = set(
                role_data['global_reviewers'])

            for track, user_roles in role_data['track_roles'].viewitems():
                track.conveners = set(user_roles['convener'])
                track.abstract_reviewers = set(user_roles['reviewer'])

            # Update actual ACLs
            update_object_principals(self.event,
                                     role_data['all_conveners'],
                                     permission='track_convener')
            update_object_principals(self.event,
                                     role_data['all_reviewers'],
                                     permission='abstract_reviewer')

            flash(_("Abstract reviewing roles have been updated."), 'success')
            logger.info(
                "Abstract reviewing roles of %s have been updated by %s",
                self.event, session.user)
            return jsonify_data()
        return jsonify_form(form,
                            skip_labels=True,
                            form_header_kwargs={'id': 'reviewing-role-form'},
                            disabled_until_change=True)
Example #3
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
Example #4
0
 def _process(self):
     reg_managers = {p.principal for p in self.event_new.acl_entries
                     if p.has_management_role('registration', explicit=True)}
     form = RegistrationManagersForm(obj=FormDefaults(managers=reg_managers))
     if form.validate_on_submit():
         update_object_principals(self.event_new, form.managers.data, role='registration')
         return jsonify_data(flash=False)
     return jsonify_form(form)
Example #5
0
 def _process(self):
     reg_managers = {p.principal for p in self.event.acl_entries
                     if p.has_management_role('registration', explicit=True)}
     form = RegistrationManagersForm(obj=FormDefaults(managers=reg_managers))
     if form.validate_on_submit():
         update_object_principals(self.event, form.managers.data, role='registration')
         return jsonify_data(flash=False)
     return jsonify_form(form)
Example #6
0
    def _process(self):
        roles = {}
        event_permissions = event_permissions_schema.dump(self.event).get('acl_entries', {})
        roles['global'] = self._map_event_to_track_permissions(event_permissions)
        tracks = Track.query.with_parent(self.event).options(subqueryload('acl_entries'))
        tracks_by_id = {str(track.id): track for track in tracks}
        for track in tracks:
            roles[str(track.id)] = track_permissions_schema.dump(track).get('acl_entries', {})
        form = AbstractReviewingRolesForm(event=self.event, obj=FormDefaults(roles=roles))

        if form.validate_on_submit():
            role_data = form.data['roles']

            # Update global permissions
            global_conveners = []
            global_reviewers = []
            global_roles = role_data.pop('global')
            for identifier, permissions in global_roles:
                principal = principal_from_identifier(identifier, allow_groups=True, allow_event_roles=True,
                                                      event_id=self.event.id)
                if 'convene' in permissions:
                    global_conveners.append(principal)
                if 'review' in permissions:
                    global_reviewers.append(principal)
            update_object_principals(self.event, global_conveners, permission='convene_all_abstracts')
            update_object_principals(self.event, global_reviewers, permission='review_all_abstracts')

            # Update track specific permissions
            track_conveners = []
            track_reviewers = []
            for (track_id, track_roles) in role_data.items():
                acl_entries = {}
                for identifier, permissions in track_roles:
                    principal = principal_from_identifier(identifier, allow_groups=True, allow_event_roles=True,
                                                          event_id=self.event.id)
                    acl_entries[principal] = set(permissions)
                    if 'convene' in permissions:
                        track_conveners.append(principal)
                    if 'review' in permissions:
                        track_reviewers.append(principal)
                track = tracks_by_id[track_id]
                current = {e.principal: get_unified_permissions(e) for e in track.acl_entries}
                update_principals_permissions(track, current, acl_entries)

            # Update event ACL for track and global permissions
            all_conveners = set(global_conveners + track_conveners)
            all_reviewers = set(global_reviewers + track_reviewers)
            update_object_principals(self.event, all_conveners, permission='track_convener')
            update_object_principals(self.event, all_reviewers, permission='abstract_reviewer')

            flash(_("Abstract reviewing roles have been updated."), 'success')
            logger.info("Abstract reviewing roles of %s have been updated by %s", self.event, session.user)
            return jsonify_data()
        return jsonify_form(form, skip_labels=True, form_header_kwargs={'id': 'reviewing-role-form'},
                            disabled_until_change=False)
Example #7
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()),
                                event=self.event)
     if form.validate_on_submit():
         update_event_protection(
             self.event, {
                 'protection_mode': form.protection_mode.data,
                 'own_no_access_contact': form.own_no_access_contact.data,
                 'access_key': form.access_key.data,
                 'visibility': form.visibility.data
             })
         update_object_principals(self.event,
                                  form.acl.data,
                                  read_access=True)
         update_object_principals(self.event,
                                  form.managers.data,
                                  full_access=True)
         update_object_principals(self.event,
                                  form.submitters.data,
                                  role='submit')
         self._update_session_coordinator_privs(form)
         flash(_('Protection settings have been updated'), 'success')
         return redirect(url_for('.protection', self.event))
     return WPEventProtection.render_template('event_protection.html',
                                              self.event,
                                              'protection',
                                              form=form)
Example #8
0
 def _process(self):
     form = CategoryProtectionForm(obj=self._get_defaults(),
                                   category=self.category)
     if form.validate_on_submit():
         update_category(
             self.category, {
                 'protection_mode': form.protection_mode.data,
                 'own_no_access_contact': form.own_no_access_contact.data,
                 'event_creation_restricted':
                 form.event_creation_restricted.data,
                 'visibility': form.visibility.data
             })
         update_object_principals(self.category,
                                  form.acl.data,
                                  read_access=True)
         update_object_principals(self.category,
                                  form.managers.data,
                                  full_access=True)
         update_object_principals(self.category,
                                  form.event_creators.data,
                                  role='create')
         flash(_('Protection settings of the category have been updated'),
               'success')
         return redirect(url_for('.manage_protection', self.category))
     return WPCategoryManagement.render_template(
         'management/category_protection.html',
         self.category,
         'protection',
         form=form)
Example #9
0
    def _process(self):
        roles = get_roles_for_event(self.event_new)
        form = AbstractReviewingRolesForm(event=self.event_new, obj=FormDefaults(roles=roles))

        if form.validate_on_submit():
            role_data = form.roles.role_data
            self.event_new.global_conveners = set(role_data['global_conveners'])
            self.event_new.global_abstract_reviewers = set(role_data['global_reviewers'])

            for track, user_roles in role_data['track_roles'].viewitems():
                track.conveners = set(user_roles['convener'])
                track.abstract_reviewers = set(user_roles['reviewer'])

            # Update actual ACLs
            update_object_principals(self.event_new, role_data['all_conveners'], role='track_convener')
            update_object_principals(self.event_new, role_data['all_reviewers'], role='abstract_reviewer')

            flash(_("Abstract reviewing roles have been updated."), 'success')
            logger.info("Abstract reviewing roles of %s have been updated by %s", self.event_new, session.user)
            return jsonify_data()
        return jsonify_form(form, skip_labels=True, form_header_kwargs={'id': 'reviewing-role-form'},
                            disabled_until_change=True)
Example #10
0
 def _process(self):
     form = SessionProtectionForm(obj=FormDefaults(**self._get_defaults()), session=self.session,
                                  prefix='session-protection-')
     if form.validate_on_submit():
         update_session(self.session, {'protection_mode': form.protection_mode.data})
         if self.session.is_protected:
             update_object_principals(self.session, form.acl.data, read_access=True)
         update_object_principals(self.session, form.managers.data, full_access=True)
         update_object_principals(self.session, form.coordinators.data, role='coordinate')
         return jsonify_data(flash=False, html=_render_session_list(self.event))
     return jsonify_form(form)
Example #11
0
 def _process(self):
     form = ContributionProtectionForm(obj=FormDefaults(**self._get_defaults()), contrib=self.contrib,
                                       prefix='contribution-protection-')
     if form.validate_on_submit():
         update_contribution(self.contrib, {'protection_mode': form.protection_mode.data})
         update_object_principals(self.contrib, form.managers.data, full_access=True)
         if self.contrib.is_protected:
             update_object_principals(self.contrib, form.acl.data, read_access=True)
         update_object_principals(self.contrib, form.submitters.data, role='submit')
         return jsonify_data(flash=False, **self.list_generator.render_list(self.contrib))
     return jsonify_form(form)
Example #12
0
 def _process(self):
     form = ContributionProtectionForm(obj=FormDefaults(**self._get_defaults()), contrib=self.contrib,
                                       prefix='contribution-protection-')
     if form.validate_on_submit():
         update_contribution(self.contrib, {'protection_mode': form.protection_mode.data})
         update_object_principals(self.contrib, form.managers.data, full_access=True)
         if self.contrib.is_protected:
             update_object_principals(self.contrib, form.acl.data, read_access=True)
         update_object_principals(self.contrib, form.submitters.data, role='submit')
         return jsonify_data(flash=False, **self.list_generator.render_list(self.contrib))
     return jsonify_form(form)
Example #13
0
 def _process(self):
     form = SessionProtectionForm(obj=FormDefaults(**self._get_defaults()), session=self.session,
                                  prefix='session-protection-')
     if form.validate_on_submit():
         update_session(self.session, {'protection_mode': form.protection_mode.data})
         if self.session.is_protected:
             update_object_principals(self.session, form.acl.data, read_access=True)
         update_object_principals(self.session, form.managers.data, full_access=True)
         update_object_principals(self.session, form.coordinators.data, permission='coordinate')
         return jsonify_data(flash=False, html=_render_session_list(self.event))
     return jsonify_form(form)
Example #14
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()), event=self.event_new)
     if form.validate_on_submit():
         update_event(self.event_new, {'protection_mode': form.protection_mode.data,
                                       'own_no_access_contact': form.own_no_access_contact.data,
                                       'access_key': form.access_key.data})
         update_object_principals(self.event_new, form.acl.data, read_access=True)
         update_object_principals(self.event_new, form.managers.data, full_access=True)
         update_object_principals(self.event_new, form.submitters.data, role='submit')
         self._update_session_coordinator_privs(form)
         flash(_('Protection settings have been updated'), 'success')
         return redirect(url_for('.protection', self.event_new))
     return WPEventManagement.render_template('event_protection.html', self._conf, form=form, event=self.event_new)
Example #15
0
 def _process(self):
     form = CategoryProtectionForm(obj=self._get_defaults(), category=self.category)
     if form.validate_on_submit():
         update_category(self.category,
                         {'protection_mode': form.protection_mode.data,
                          'own_no_access_contact': form.own_no_access_contact.data,
                          'event_creation_restricted': form.event_creation_restricted.data})
         update_object_principals(self.category, form.acl.data, read_access=True)
         update_object_principals(self.category, form.managers.data, full_access=True)
         update_object_principals(self.category, form.event_creators.data, role='create')
         flash(_('Protection settings of the category have been updated'), 'success')
         return redirect(url_for('.manage_protection', self.category))
     return WPCategoryManagement.render_template('management/category_protection.html', self.category, 'protection',
                                                 form=form)
Example #16
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()), event=self.event_new)
     if form.validate_on_submit():
         update_event(
             self.event_new,
             {
                 "protection_mode": form.protection_mode.data,
                 "own_no_access_contact": form.own_no_access_contact.data,
                 "access_key": form.access_key.data,
             },
         )
         update_object_principals(self.event_new, form.acl.data, read_access=True)
         update_object_principals(self.event_new, form.managers.data, full_access=True)
         update_object_principals(self.event_new, form.submitters.data, role="submit")
         self._update_session_coordinator_privs(form)
         flash(_("Protection settings have been updated"), "success")
         return redirect(url_for(".protection", self.event_new))
     return WPEventManagement.render_template("event_protection.html", self._conf, form=form, event=self.event_new)