def logged_in_user(request): user_id = '' if _is_authenticated(request): user = request.get('AUTHENTICATED_USER', '') user_id = user.id return user_id
def nrcs(self, REQUEST): """ view nrcs and members in these roles """ if not _is_authenticated(REQUEST): pass country_code = REQUEST.form.get("nfp") country_name = code_to_name(country_code) agent = self._get_ldap_agent() if not self._allowed(agent, REQUEST, country_code): return None roles = get_members(agent, country_code, 'eionet-nrc') has_problematic_users = False for role in roles: for user in role.users: if not user['ldap_org']: has_problematic_users = True break if has_problematic_users: msg = "There are problematic users with regards to their "\ "connection to a national organisation" _set_session_message(REQUEST, 'info', msg) options = {'roles': roles, 'country': country_code, 'country_name': country_name or country_code, # naming is similar to all NRC roles 'naming': roles_leaders.naming(roles[0].role_id), } self._set_breadcrumbs([("Browsing NRC-s in %s" % country_name, '#')]) return self._render_template('zpt/nfp_nrc/nrcs.zpt', **options)
def index_html(self, REQUEST): """ view """ if not _is_authenticated(REQUEST): return self._render_template('zpt/nfp_nrc/index.zpt') agent = self._get_ldap_agent() user_id = logged_in_user(REQUEST) nfps = get_nfp_roles(agent, user_id) options = {'nfps': nfps} return self._render_template('zpt/nfp_nrc/index.zpt', **options)
def awps(self, REQUEST): """ view awp roles and members in these roles """ if not _is_authenticated(REQUEST): pass country_code = REQUEST.form.get("nfp", 'eea') country_name = code_to_name(country_code) agent = self._get_ldap_agent() if not self._allowed(agent, REQUEST, country_code): return None roles = get_members(agent, country_code, 'reportnet-awp') options = {'roles': roles, 'country': country_code, 'country_name': country_name or country_code, } self._set_breadcrumbs([("Browsing reporter roles in %s" % country_name, '#')]) return self._render_template('zpt/nfp_nrc/awps.zpt', **options)
def nrcs(self, REQUEST): """ view nrcs and members in these roles """ if not _is_authenticated(REQUEST): pass country_code = REQUEST.form.get("nfp") country_name = code_to_name(country_code) agent = self._get_ldap_agent() if not self._allowed(agent, REQUEST, country_code): return None top_role_dns = get_top_role_dns(agent, 'eionet-nrc') options = {'top_role_dns': top_role_dns, 'country': country_code, 'agent': agent, 'country_name': country_name or country_code, } self._set_breadcrumbs([("Browsing NRC-s in %s" % country_name, '#')]) return self._render_template('zpt/nfp_nrc/nrcs.zpt', **options)
def awps(self, REQUEST): """ view awp roles and members in these roles """ if not _is_authenticated(REQUEST): pass country_code = REQUEST.form.get("nfp", 'eea') country_name = code_to_name(country_code) agent = self._get_ldap_agent() if not self._allowed(agent, REQUEST, country_code): return None roles = get_members(agent, country_code, 'reportnet-awp') options = { 'roles': roles, 'country': country_code, 'country_name': country_name or country_code, } self._set_breadcrumbs([("Browsing reporter roles in %s" % country_name, '#')]) return self._render_template('zpt/nfp_nrc/awps.zpt', **options)
def nrcs(self, REQUEST): """ view nrcs and members in these roles """ if not _is_authenticated(REQUEST): pass country_code = REQUEST.form.get("nfp") country_name = code_to_name(country_code) agent = self._get_ldap_agent() if not self._allowed(agent, REQUEST, country_code): return None top_role_dns = get_top_role_dns(agent, 'eionet-nrc') options = { 'top_role_dns': top_role_dns, 'country': country_code, 'agent': agent, 'country_name': country_name or country_code, } self._set_breadcrumbs([("Browsing NRC-s in %s" % country_name, '#')]) return self._render_template('zpt/nfp_nrc/nrcs.zpt', **options)