Skip to content

Commit

Permalink
removing users from projects
Browse files Browse the repository at this point in the history
  • Loading branch information
2easy committed Mar 19, 2011
1 parent d301d9a commit 21b422a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/controllers/project_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ def create
end
end
def destroy
@project_user = ProjectUser.where(:project_id => current_user.projects).find(params[:project_id])
@project = @project_user.project
@project_user.destroy
flash[:notice] = t('project_users.actions.remove_user.successful')
redirect_to @project
end
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class User < ActiveRecord::Base
has_many :project_users
has_many :owned_project_users, :through => :projects
has_many :projects, :through => :project_users

# Include default devise modules. Others available are:
Expand Down
8 changes: 4 additions & 4 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- if user_signed_in?
= link_to t(:sign_out), destroy_user_session_path
= link_to t('sign_out'), destroy_user_session_path
= link_to t('projects.owned'), projects_path(current_user)
- else
= link_to t(:sign_in), new_user_session_path
= link_to t(:sign_up), new_user_registration_path
= link_to t('sign_in'), new_user_session_path
= link_to t('sign_up'), new_user_registration_path

%h3 Home#index
%h3= t('home')
8 changes: 5 additions & 3 deletions app/views/projects/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
%h2= t('activerecord.project') + " #{@project.name}"
%p= "Api Token: #{@project.api_token}"
%p= t('activerecord.attributes.project.api_token')+" #{@project.api_token}"
%p= t('projects.watchers')
%ul
- @project.users.each do |watcher|
%li= watcher.email
- @project.project_users.each do |project_user|
%li
= project_user.user.email
= link_to t('projects.remove_user'), project_user, :confirm => t('confirmations.delete'), :method => :delete
%p= link_to t('projects.add_user'), new_project_user_path(:project_id => @project.id)
%p
%b= t('issues.all')
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ en:
attributes:
project:
name: Project name
api_token: Api token
user:
name: User name
email: Email
Expand All @@ -29,6 +30,7 @@ en:
delete: Delete
save: Save project
add_user: Add user
remove_user: Remove user
watchers: Watchers
actions:
destroy:
Expand All @@ -50,6 +52,9 @@ en:
add_user:
successful: User successfully added as a watcher
failed: Cannot add user as a watcher
remove_user:
successful: User successfully removed from the project
failed: Cannot remove user form the project
sign_in: Sign in
sign_out: Sign out
sign_up: Sign up
Expand Down

0 comments on commit 21b422a

Please sign in to comment.