Get project permissions page URL
161437
private String getProjectPermissionsURL() {
    String projectPermissionsURL = null;
    final String baseURL = this.azkabanProps.get(AZKABAN_WEBSERVER_URL);
    if (baseURL != null) {
      final String projectName = this.node.getParentFlow().getProjectName();
      projectPermissionsURL = String
          .format("%s/manager?project=%s&permissions", baseURL, projectName);
    }
    return projectPermissionsURL;
  }
791376
void displayInheritedPermissions() {

        // store all parent folder ids together with path in a map
        m_parents = new HashMap<CmsUUID, String>();
        String sitePath = m_cms.getSitePath(m_resource);
        String path = CmsResource.getParentFolder(sitePath);
        List<CmsResource> parentResources = new ArrayList<CmsResource>();
        try {
            // get all parent folders of the current file
            parentResources = m_cms.readPath(path, CmsResourceFilter.IGNORE_EXPIRATION);
        } catch (CmsException e) {
            // can usually be ignored
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }
        Iterator<CmsResource> k = parentResources.iterator();
        while (k.hasNext()) {
            // add the current folder to the map
            CmsResource curRes = k.next();
            m_parents.put(curRes.getResourceId(), curRes.getRootPath());
        }

        ArrayList<CmsAccessControlEntry> inheritedEntries = new ArrayList<CmsAccessControlEntry>();
        try {
            Iterator<CmsAccessControlEntry> itAces = m_cms.getAccessControlEntries(path, true).iterator();
            while (itAces.hasNext()) {
                CmsAccessControlEntry curEntry = itAces.next();
                inheritedEntries.add(curEntry);
            }
        } catch (CmsException e) {
            // can usually be ignored
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }
        addEntryTableToLayout(inheritedEntries, m_inheritedPermissions, false, true);

        //        buildInheritedList(inheritedEntries, parents);
    }
1226237
@RequestMapping(value = "projects/roles", method = RequestMethod.GET)
    public Resources<ProjectRole> getProjectRoles() {
        return Resources.of(
                rolesService.getProjectRoles(),
                uri(on(PermissionController.class).getProjectRoles())
        );
    }
1347708
def get_user_permissions(self, username):
        

        path = Client.urls['user_permissions'] % (username,)
        conns = self._call(path, 'GET')
        return conns
1048331
private String getPermissionString(CmsObject cms, CmsResource res, DialogType type) throws CmsException {

        if (type.equals(DialogType.User)) {
            cms.getPermissions(res.getRootPath(), m_principal.getName()).getPermissionString();
        } else if (type.equals(DialogType.Group)) {
            Iterator<CmsAccessControlEntry> itAces = cms.getAccessControlEntries(res.getRootPath(), false).iterator();
            while (itAces.hasNext()) {
                CmsAccessControlEntry ace = itAces.next();
                if (ace.getPrincipal().equals(m_principal.getId())) {
                    return ace.getPermissions().getPermissionString();
                }
            }
        }
        return "";
    }
834796
def getUrlList():
    
    """
    IF YOU WANT REBUILD YOUR STRUCTURE UNCOMMENT THE FOLLOWING LINE
    """
    #Node.rebuild()

    set_to_return = []
    set_url = []

    roots = Node.objects.filter(parent__isnull=True)
    for root in roots:
        nodes = root.get_descendants()
        for node in nodes:
            if node.page:
                page = node.page
                view = page.view
                regex = r'^{0}$'.format(node.get_pattern())
                regex_path = '{0}'.format(node.get_pattern())
                view = u'{0}.{1}.{2}'.format(view.app_name, view.module_name, view.func_name)
                """
                check_static_vars add UPY_CONTEXT to page
                """
                page.check_static_vars(node)
                app_url = url(regex, view, page.static_vars, page.scheme_name)
                set_to_return.append(app_url)
                set_url.append(regex_path)
                if node.is_index:
                    regex = r'^$'
                    regex_path = ''
                    app_url = url(regex, view, page.static_vars, page.scheme_name)
                    set_to_return.append(app_url)
                    set_url.append(regex_path)
    return set_to_return, set_url
136939
def get_urls(self):
        
        urls = super().get_urls()
        forum_admin_urls = [
            url(
                r'^(?P<forum_id>[0-9]+)/move-forum/(?P<direction>up|down)/$',
                self.admin_site.admin_view(self.moveforum_view),
                name='forum_forum_move',
            ),
            url(
                r'^edit-global-permissions/$',
                self.admin_site.admin_view(self.editpermissions_index_view),
                name='forum_forum_editpermission_index',
            ),
            url(
                r'^edit-global-permissions/user/(?P<user_id>[0-9]+)/$',
                self.admin_site.admin_view(self.editpermissions_user_view),
                name='forum_forum_editpermission_user',
            ),
            url(
                r'^edit-global-permissions/user/anonymous/$',
                self.admin_site.admin_view(self.editpermissions_anonymous_user_view),
                name='forum_forum_editpermission_anonymous_user',
            ),
            url(
                r'^edit-global-permissions/group/(?P<group_id>[0-9]+)/$',
                self.admin_site.admin_view(self.editpermissions_group_view),
                name='forum_forum_editpermission_group',
            ),
            url(
                r'^(?P<forum_id>[0-9]+)/edit-permissions/$',
                self.admin_site.admin_view(self.editpermissions_index_view),
                name='forum_forum_editpermission_index',
            ),
            url(
                r'^(?P<forum_id>[0-9]+)/edit-permissions/user/(?P<user_id>[0-9]+)/$',
                self.admin_site.admin_view(self.editpermissions_user_view),
                name='forum_forum_editpermission_user',
            ),
            url(
                r'^(?P<forum_id>[0-9]+)/edit-permissions/user/anonymous/$',
                self.admin_site.admin_view(self.editpermissions_anonymous_user_view),
                name='forum_forum_editpermission_anonymous_user',
            ),
            url(
                r'^(?P<forum_id>[0-9]+)/edit-permissions/group/(?P<group_id>[0-9]+)/$',
                self.admin_site.admin_view(self.editpermissions_group_view),
                name='forum_forum_editpermission_group',
            ),
        ]
        return forum_admin_urls + urls
308177
def get_protected_page(url, user, pwd, filename):
    
    import requests
    r = requests.get(url, auth=(user, pwd))
    print(r.status_code)
    if r.status_code == 200:
        print('success')
        with open(filename, 'wb') as fd:
            for chunk in r.iter_content(4096):
                fd.write(chunk)
        lg.record_result("Success - downloaded " + url)
    else:
        lg.record_result('network_tools.get_protected_page:Failed to downloaded ' + url + ' (status code = ' + str(r.status_code) + ')')
499394
def permission_denied(request, template_name='403.html'):
    

    response = render_in_page(request, template_name)

    if response:
        return response

    try:
        template = loader.get_template(template_name)
    except TemplateDoesNotExist:
        return http.HttpResponseForbidden('<h1>403 Forbidden</h1>', content_type='text/html')
    return http.HttpResponseForbidden(template.render(RequestContext(request)))
1123352
protected Project filterProjectByPermission(final Project project, final User user,
      final Permission.Type type, final Map<String, Object> ret) {
    if (project == null) {
      if (ret != null) {
        ret.put("error", "Project 'null' not found.");
      }
    } else if (!hasPermission(project, user, type)) {
      if (ret != null) {
        ret.put("error",
            "User '" + user.getUserId() + "' doesn't have " + type.name()
                + " permissions on " + project.getName());
      }
    } else {
      return project;
    }

    return null;
  }
1187431
private Map<String,Function<HttpRequestContext, String>> createSubstitutionMap(String[] permissions, AbstractMethod am) {
        Map<String, Function<HttpRequestContext, String>> map = Maps.newLinkedHashMap();

        for (String permission : permissions) {
            Matcher matcher = SUBSTITUTION_MATCHER.matcher(permission);
            while (matcher.find()) {
                String match = matcher.group();
                if (map.containsKey(match)) {
                    continue;
                }

                String param = matcher.group("param");
                Function<HttpRequestContext, String> substitution;

                if (param.startsWith("?")) {
                    substitution = createQuerySubstitution(param.substring(1));
                } else {
                    substitution = createPathSubstitution(param, am);
                }

                map.put(match, substitution);
            }
        }

        return map;
    }
555221
def get_project_resources(self, project, type=None, id=None):
        
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url('project', project, 'str')
        query_parameters = {}
        if type is not None:
            query_parameters['type'] = self._serialize.query('type', type, 'str')
        if id is not None:
            query_parameters['id'] = self._serialize.query('id', id, 'str')
        response = self._send(http_method='GET',
                              location_id='398c85bc-81aa-4822-947c-a194a05f0fef',
                              version='5.0-preview.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('[DefinitionResourceReference]', self._unwrap_collection(response))
476668
def has_project_permissions(user: 'User', project: 'Project', request_method: str) -> bool:
    """"""
    # Superusers and the creator is allowed to do everything
    if user.is_staff or user.is_superuser or project.user == user:
        return True

    # Other user
    return request_method in permissions.SAFE_METHODS and project.is_public
293780
def permission_request_approve_link(context, perm):
    
    user = context['request'].user
    if user.is_authenticated():
        if user.has_perm('authority.approve_permission_requests'):
            return base_link(context, perm, 'authority-approve-permission-request')
    return {'url': None}
1310825
def return_current_uri_page_only(self):
        
        uri = post_slash("%s%s" % (post_slash(self.current_dir()),
                         self.slots['page']))
        return uri
923317
def get_permissions_for_registration(self):
        
        from wagtail.wagtailsnippets.models import SNIPPET_MODELS
        if not self.is_pagemodel and self.model not in SNIPPET_MODELS:
            return self.permission_helper.get_all_model_permissions()
        return Permission.objects.none()
418668
def _get_action_urls(self):
        """"""
        actions = {}

        model_name = self.model._meta.model_name
        # e.g.: polls_poll
        base_url_name = '%s_%s' % (self.model._meta.app_label, model_name)
        # e.g.: polls_poll_actions
        model_actions_url_name = '%s_actions' % base_url_name

        self.tools_view_name = 'admin:' + model_actions_url_name

        # WISHLIST use get_change_actions and get_changelist_actions
        # TODO separate change and changelist actions
        for action in chain(self.change_actions, self.changelist_actions):
            actions[action] = getattr(self, action)
        return [
            # change, supports the same pks the admin does
            # https://github.com/django/django/blob/stable/1.10.x/django/contrib/admin/options.py#L555
            url(r'^(?P<pk>.+)/actions/(?P<tool>\w+)/$',
                self.admin_site.admin_view(  # checks permissions
                    ChangeActionView.as_view(
                        model=self.model,
                        actions=actions,
                        back='admin:%s_change' % base_url_name,
                        current_app=self.admin_site.name,
                    )
                ),
                name=model_actions_url_name),
            # changelist
            url(r'^actions/(?P<tool>\w+)/$',
                self.admin_site.admin_view(  # checks permissions
                    ChangeListActionView.as_view(
                        model=self.model,
                        actions=actions,
                        back='admin:%s_changelist' % base_url_name,
                        current_app=self.admin_site.name,
                    )
                ),
                # Dupe name is fine. https://code.djangoproject.com/ticket/14259
                name=model_actions_url_name),
        ]