def deny_handler(self, targets, fields=None): assert len(targets) == 1 proj_id = targets[0] if not self._apply_transition_to(proj_id, 'reject_by_owner'): return {} id_ = self.viewed_member_info['id'] # there must be a better way to get the last wf transition which was an invite... right? wftool = self.get_tool("portal_workflow") team = self.get_tool("portal_teams").getTeamById(proj_id) mship = team.getMembershipByMemberId(id_) wf_id = wftool.getChainFor(mship)[0] wf_history = mship.workflow_history.get(wf_id) spurned_admin = [i for i in wf_history if i['review_state'] == 'pending'][-1]['actor'] transient_msgs = ITransientMessage(self.portal) member_url = u'%s/%s' % (getToolByName(self.context, 'portal_url')(), member_path(id_)) project_url = self.project_url(proj_id) msg = _(u'tmsg_decline_invite', u'<a href="${member_url}">${id}</a> has declined your invitation to join <a href="${project_url}">${proj_id}</a>', mapping={u'id':id_, u'project_url':project_url, u'proj_id':proj_id, u'member_url':member_url}) transient_msgs.store(spurned_admin, "membership", msg) elt_id = '%s_invitation' % proj_id return ajax_update(elt_id, self.nupdates())
def accept_handler(self, targets, fields=None): assert len(targets) == 1 proj_id = targets[0] if not self._apply_transition_to(proj_id, 'approve_public'): return {} # security reindex (async to the catalog queue) team = self.get_tool('portal_teams').getTeamById(proj_id) team.reindexTeamSpaceSecurity() admin_ids = team.get_admin_ids() transient_msgs = ITransientMessage(self.portal) id_ = self.viewed_member_info['id'] member_url = u'%s/%s' % (getToolByName(self.context, 'portal_url')(), member_path(id_)) project_url = self.project_url(proj_id) msg = _(u'tmsg_joined_project', u'<a href="${member_url}">${id}</a> has joined <a href="${project_url}">${proj_id}</a>', mapping={u'id':id_, u'project_url':project_url, u'proj_id':proj_id, u'member_url':member_url}) for mem_id in admin_ids: transient_msgs.store(mem_id, "membership", msg) projinfos = self.projects_for_user if len(projinfos) > 1: projinfo = self._get_projinfo_for_id(proj_id) new_proj_row = self.project_row(proj_id=proj_id, projinfo=projinfo) command = {'projinfos_for_user': {'action': 'append', 'effects': 'highlight', 'html': new_proj_row }} else: new_proj_table = self.project_table() command = {'project_table': {'action': 'replace', 'html': new_proj_table }} elt_id = '%s_invitation' % proj_id command.update(ajax_update(elt_id, self.nupdates())) mship = team._getOb(id_) notify(JoinedProjectEvent(mship)) return command