Permalink
Browse files

Project detail: membership delete added

  • Loading branch information...
1 parent c0caf81 commit 8f8d491a50ff225fa0673e42b390c1e76fb79af5 @yvesvanbroekhoven yvesvanbroekhoven committed Apr 30, 2010
@@ -50,7 +50,7 @@ def create
def destroy
membership.destroy
- redirect_to project
+ redirect_to membership.project
end
private
@@ -70,17 +70,17 @@ def require_project_ownership
if current_user.member?(project)
redirect_to project
else
- redirect_to home_path
+ redirect_to project_path()
end
return false
end
end
def require_ownership
- unless current_user.owner?(membership)
+ unless current_user.owner?(membership) or current_user.owner?(membership.project)
store_location
flash[:notice] = "You must be the owner of this project"
- redirect_to home_path
+ redirect_to membership.project
return false
end
end
@@ -425,12 +425,14 @@ body
:padding 0
:list-style none
li
+ :position relative
:clear both
:border-top 1px solid rgb(255,255,255)
:border-bottom 1px solid rgb(228,230,223)
img
:float left
.info
+ :position relative
:float left
:padding 7px 10px
:line-height 1em
@@ -439,6 +441,18 @@ body
.email
:font-size 10px
:color rgb(178,181,174)
+ .delete
+ :position absolute
+ :display block
+ :top 50%
+ :right 0
+ :margin -8px 0 0 0
+ :border none
+ :width 16px
+ :height 16px
+ :background url(/images/icons/delete.png) no-repeat center center
+ :text-indent -8888px
+
li.first
:border-top none
li.last
@@ -11,14 +11,18 @@
.block.members
%h3 Members
%ul
- - @project.members.each_with_index do |member, idx|
+ - @project.memberships.all(:include => :user).each_with_index do |membership, idx|
+ - member = membership.user
%li{:class => %{clearfix #{css_class('first', idx, 0)} #{css_class('last', idx, (@project.members.length - 1))} #{css_class('owner', member.owner?(@project), true)}} }
= image_tag member.gravatar_url(:size => 40)
%span.info
%strong.name
= member.name
%span.email
= member.email
+ - if current_user.owner?(@project) and current_user != member
+ = link_to 'Delete', membership_path(membership), :class => 'delete', :method => :delete, :confirm => "Are you sure you want to delete this member?"
+
- if current_user.owner?(@project)
%li.clearfix.last.add-member
View
@@ -32,22 +32,22 @@
:shallow => true,
:member => member do |projects|
- projects.resources :memberships,
- :except => [:index, :show]
+ projects.resources :memberships,
+ :except => [:index, :show]
- projects.resources :errors,
- :shallow => true,
- :only => [:show, :update] do |errors|
+ projects.resources :errors,
+ :shallow => true,
+ :only => [:show, :update] do |errors|
- errors.resources :comments,
- :only => [:create]
-
- errors.resources :occurences,
- :only => [:show],
- :member => {
- :backtrace => :get,
- :environment => :get }
+ errors.resources :comments,
+ :only => [:create]
+ errors.resources :occurences,
+ :only => [:show],
+ :member => {
+ :backtrace => :get,
+ :environment => :get }
+
end
end
@@ -420,12 +420,14 @@ body {
padding: 0;
list-style: none; }
#container #sidebar .members ul li {
+ position: relative;
clear: both;
border-top: 1px solid rgb(255,255,255);
border-bottom: 1px solid rgb(228,230,223); }
#container #sidebar .members ul li img {
float: left; }
#container #sidebar .members ul li .info {
+ position: relative;
float: left;
padding: 7px 10px;
line-height: 1em; }
@@ -434,6 +436,17 @@ body {
#container #sidebar .members ul li .info .email {
font-size: 10px;
color: rgb(178,181,174); }
+ #container #sidebar .members ul li .delete {
+ position: absolute;
+ display: block;
+ top: 50%;
+ right: 0;
+ margin: -8px 0 0 0;
+ border: none;
+ width: 16px;
+ height: 16px;
+ background: url(/images/icons/delete.png) no-repeat center center;
+ text-indent: -8888px; }
#container #sidebar .members ul li.first {
border-top: none; }
#container #sidebar .members ul li.last {

0 comments on commit 8f8d491

Please sign in to comment.