Fixing requests after namespaces. Fixed admin bug with access to project

This commit is contained in:
Dmitriy Zaporozhets 2012-11-23 22:25:28 +02:00
parent e92b563acf
commit 0e1635a68a
14 changed files with 35 additions and 62 deletions

View file

@ -42,4 +42,14 @@ class Admin::ProjectsController < AdminController
redirect_to projects_url, notice: 'Project was successfully deleted.'
end
protected
def project
id = params[:project_id] || params[:id]
id = id.split("/") if id.include?("/")
@project ||= Project.find_by_path(id)
@project || render_404
end
end

View file

@ -88,7 +88,7 @@ module ApplicationHelper
[ "Users", users.map {|u| [u.human_name, u.id]} ]
]
if selected == :current_user
if selected == :current_user && current_user.namespace
selected = current_user.namespace.id
end

View file

@ -1,6 +1,6 @@
class UserObserver < ActiveRecord::Observer
def after_create(user)
user.create_namespace(code: user.username, name: user.name)
user.create_namespace(path: user.username, name: user.name)
log_info("User \"#{user.name}\" (#{user.email}) was created")
@ -13,7 +13,7 @@ class UserObserver < ActiveRecord::Observer
def after_save user
if user.username_changed? and user.namespace
user.namespace.update_attributes(code: user.username)
user.namespace.update_attributes(path: user.username)
end
end