def __call__(self): profile = self.request.profile if not profile: raise HTTPForbidden(_("Must be logged in")) if not profile.email or not profile.email_validated: raise HTTPForbidden( _("You need to have a validated email address to use this. ")) came_from = self.request.GET.get("came_from", None) if came_from: response = HTTPFound(location=came_from) else: response = HTTPFound( location=self.request.resource_url(self.context)) for uid in self.context.hashlist_uids: hashlist = self.request.resolve_uid(uid, perm=None) res = hashlist.check(profile.email) if res is True: self.context.local_roles.add(profile.userid, ROLE_MOTION_PROCESS_PARTICIPANT) self.flash_messages.add(_GRANTED_ACCESS_MSG, type="success", auto_destruct=False) return response self.flash_messages.add( _( "not_found_when_checked_against_hashlist", default="We couldn't find your email address. " "Please contact the organisation responsible for this process to gain access.", ), type="danger", auto_destruct=False, ) return response
def set_endorsement(self): state = self.request.GET.get("s", None) came_from = self.request.GET.get("came_from", None) endorsements = set(self.context.endorsements) userid = self.request.authenticated_userid if state == "yes": if userid not in endorsements: endorsements.add(userid) self.context.endorsements = endorsements self.flash_messages.add( _("youre_now_endorsing", default="You're now endorsing this motion."), type="success", ) if state == "no": if userid in endorsements: endorsements.remove(userid) self.context.endorsements = endorsements self.flash_messages.add( _( "your_endorsement_removed", default="You're no longer endorsing this motion.", ), type="warning", ) if came_from: return HTTPFound(location=came_from) return HTTPFound(location=self.request.resource_url(self.context))
def toggle_sharing(self): state = self.request.GET.get("s", None) if state == "on": self.context.enable_sharing_token() self.flash_messages.add( _( "sharing_switched_on", default="Sharing enalbed - use the link below.", ), type="success", ) if state == "off": self.context.remove_sharing_token() self.flash_messages.add( _( "sharing_switched_off", default= "Sharing switched off - motion not accessible unless you're logged in.", ), type="warning", ) return HTTPFound(location=self.request.resource_url(self.context))
def __call__(self): userid = self.request.authenticated_userid if not userid: raise HTTPForbidden(_("Must be logged in")) came_from = self.request.GET.get("came_from", None) if came_from: response = HTTPFound(location=came_from) else: response = HTTPFound( location=self.request.resource_url(self.context)) self.context.local_roles.add(userid, ROLE_MOTION_PROCESS_PARTICIPANT) self.flash_messages.add(_GRANTED_ACCESS_MSG, type="success", auto_destruct=False) return response
def main_view(self): can_submit = self.context.wf_state == "draft" and self.request.has_permission( CHANGE_WORKFLOW_STATE, self.context) motion_process = find_interface(self.context, IMotionProcess) return { "can_submit": can_submit, "can_delete": self.request.has_permission(DELETE, self.context), "can_edit": self.request.has_permission(EDIT, self.context), "can_endorse": self.request.authenticated_userid not in self.context.creator and self.request.has_permission(ENDORSE_MOTION, self.context), "can_enable_sharing": self.request.has_permission(ENABLE_MOTION_SHARING, self.context), "access_snippet": render_access_snippet(self.context, self.request), "motion_visibility": dict(MOTION_VISIBILITY).get(motion_process.motion_visibility, _("(Unknown)")), }
self.context.endorsements = endorsements self.flash_messages.add( _( "your_endorsement_removed", default="You're no longer endorsing this motion.", ), type="warning", ) if came_from: return HTTPFound(location=came_from) return HTTPFound(location=self.request.resource_url(self.context)) _GRANTED_ACCESS_MSG = _( "granted_access_message", default="You've been granted access to add motions " "(if process is open) and to endorse motions.", ) @view_config(context=IMotionProcess, name="check_email", permission=CHECK_EMAIL_AGAINST_HASHLIST) class CheckAgainstHashlistView(BaseView): def __call__(self): profile = self.request.profile if not profile: raise HTTPForbidden(_("Must be logged in")) if not profile.email or not profile.email_validated: raise HTTPForbidden( _("You need to have a validated email address to use this. "))