Commit 439d03bb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Fix namespace api autocomplete

parent c78fd0bf63eb
:javascript
$(function() {
GitLab.GfmAutoComplete.Members.url = "#{ "/api/v2/projects/#{@project.path}/members" if @project }";
GitLab.GfmAutoComplete.Members.url = "#{ "/api/v2/projects/#{@project.id}/members" if @project }";
GitLab.GfmAutoComplete.Members.params.private_token = "#{current_user.private_token}";
GitLab.GfmAutoComplete.Emoji.data = #{raw emoji_autocomplete_source};
......
......@@ -5,13 +5,18 @@ def current_user
end
def user_project
if @project ||= current_user.projects.find_by_id(params[:id]) ||
current_user.projects.find_by_path(params[:id])
@project ||= find_project
@project || not_found!
end
def find_project
project = Project.find_by_id(params[:id]) || Project.find_with_namespace(params[:id])
if project && can?(current_user, :read_project, project)
project
else
not_found!
nil
end
@project
end
def paginate(object)
......@@ -32,6 +37,10 @@ def authorize! action, subject
end
end
def can?(object, action, subject)
abilities.allowed?(object, action, subject)
end
def attributes_for_keys(keys)
attrs = {}
keys.each do |key|
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment