From bbc916baeecfd848eba86dd71c83623a79512a68 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 27 Aug 2013 12:47:28 +0300 Subject: [PATCH] If user is owner of project it cant be removed from this project --- app/models/users_project.rb | 4 ++++ app/views/admin/projects/show.html.haml | 9 ++++++--- app/views/admin/users/show.html.haml | 9 ++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/models/users_project.rb b/app/models/users_project.rb index c435df2..6f14785 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -110,4 +110,8 @@ class UsersProject < ActiveRecord::Base def access_field project_access end + + def owner? + project.owner == user + end end diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 800f91d..72317bb 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -102,6 +102,9 @@ %strong = link_to user.name, admin_user_path(user) .pull-right - %span.light= users_project.human_access - = link_to admin_project_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn btn-small btn-remove" do - %i.icon-remove + - if users_project.owner? + %span.light Owner + - else + %span.light= users_project.human_access + = link_to admin_project_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn btn-small btn-remove" do + %i.icon-remove diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index d48660f..9b1718d 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -90,6 +90,9 @@ - if tm .pull-right - %span.light= tm.human_access - = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @user), method: :delete, class: "btn btn-small btn-remove" do - %i.icon-remove + - if tm.owner? + %span.light Owner + - else + %span.light= tm.human_access + = link_to admin_project_member_path(project, tm.user), confirm: remove_from_project_team_message(project, @user), method: :delete, class: "btn btn-small btn-remove" do + %i.icon-remove -- libgit2 0.21.2