def add_project(self, id, title=None): project = self.add_check(PROJECT_TYPE, id, IProject, Project) members = ISiteMembers(self.portal) if self.TEST_MEMBER not in members: members.register(self.TEST_MEMBER, send=False) assert self.TEST_MEMBER in members roster = IWorkspaceRoster(project) roster.add(self.TEST_MEMBER) assert self.TEST_MEMBER in roster return project
def update(self, *args, **kwargs): self.roster = IWorkspaceRoster(self.context) if 'confirm_purge' in self.request.form: userid = self.request.form.get('purgeuser').strip() if userid not in self.roster: raise ValueError('User id for purge not found %s' % userid) if not self.roster.can_purge(userid): raise ValueError('User id %s locked from purging.' % userid) self.roster.remove(userid, purge=True) msg = u'User %s permanently removed from site.' % (userid,) self.status.addStatusMessage(msg, type='info') self._log(msg)
class PurgeUserView(WorkspaceViewBase): """View to purge a single user from project""" def __init__(self, context, request): if not IProjectContext.providedBy(context): raise ValueError('Can only purge from top-level projects') super(PurgeUserView, self).__init__(context, request) def update(self, *args, **kwargs): self.roster = IWorkspaceRoster(self.context) if 'confirm_purge' in self.request.form: userid = self.request.form.get('purgeuser').strip() if userid not in self.roster: raise ValueError('User id for purge not found %s' % userid) if not self.roster.can_purge(userid): raise ValueError('User id %s locked from purging.' % userid) self.roster.remove(userid, purge=True) msg = u'User %s permanently removed from site.' % (userid,) self.status.addStatusMessage(msg, type='info') self._log(msg) def __call__(self, *args, **kwargs): self.update(*args, **kwargs) return self.index(*args, **kwargs) # form template