Exemplo n.º 1
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()),
                                event=self.event)
     selectable_permissions = {
         k
         for k, v in get_available_permissions(Event).items()
         if v.user_selectable
     }
     user_permissions = [(p.principal, set(p.permissions))
                         for p in self.event.acl_entries]
     hidden_permissions = sorted(
         [(principal, sorted(perms))
          for principal, perms in user_permissions
          if perms and not (perms & selectable_permissions)],
         key=lambda x: (x[0].principal_order, x[0].name.lower()))
     form.permissions.hidden_permissions = [
         (p.name, perms) for p, perms in hidden_permissions
     ]
     if form.validate_on_submit():
         update_permissions(self.event, form)
         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,
                 'public_regform_access': form.public_regform_access.data
             })
         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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()), event=self.event)
     if form.validate_on_submit():
         update_permissions(self.event, form)
         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})
         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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
 def _process(self):
     event = self.event
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()), event=event)
     if form.validate_on_submit():
         update_permissions(event, form)
         update_event_protection(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})
         self._update_session_coordinator_privs(form)
         flash(_('Protection settings have been updated'), 'success')
         return redirect(url_for('.protection', event))
     return WPEventProtection.render_template('event_protection.html', event, 'protection', form=form)
Exemplo n.º 6
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)
Exemplo n.º 7
0
    def _process(self):
        event = self.event
        form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()),
                                   event=event)
        if form.validate_on_submit():
            current_principal_permissions = {
                p.principal: self._get_principal_permissions(p)
                for p in event.acl_entries
            }
            current_principal_permissions = {
                k: v
                for k, v in current_principal_permissions.iteritems() if v
            }
            new_principal_permissions = {
                principal_from_fossil(fossil,
                                      allow_emails=True,
                                      allow_networks=True,
                                      event=event): set(permissions)
                for fossil, permissions in form.permissions.data
            }
            self._update_permissions(current_principal_permissions,
                                     new_principal_permissions)

            update_event_protection(
                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
                })
            self._update_session_coordinator_privs(form)
            flash(_('Protection settings have been updated'), 'success')
            return redirect(url_for('.protection', event))
        return WPEventProtection.render_template('event_protection.html',
                                                 event,
                                                 'protection',
                                                 form=form)