Bugfixing in memberships-filter.

This commit is contained in:
Benjamin Meichsner 2009-02-02 17:28:59 +01:00
parent aec93d4b73
commit f7b9582261
3 changed files with 5 additions and 8 deletions

View file

@ -2,18 +2,16 @@ class MembershipsController < ApplicationController
before_filter :authenticate_membership_or_admin
def add_member
@group = Group.find(params[:group_id])
user = User.find(params[:user_id])
Membership.create(:group => @group, :user => user)
redirect_to :action => 'reload', :group_id => @group
redirect_to :action => 'reload', :id => @group
end
def drop_member
begin
group = Group.find(params[:group_id])
Membership.find(params[:membership_id]).destroy
if User.find(@current_user.id).role_admin?
redirect_to :action => 'reload', :group_id => group
redirect_to :action => 'reload', :id => @group
else
# If the user drops himself from admin group
flash[:notice] = MESG_NO_ADMIN_ANYMORE
@ -21,12 +19,11 @@ class MembershipsController < ApplicationController
end
rescue => error
flash[:error] = error.to_s
redirect_to :action => 'reload', :group_id => group
redirect_to :action => 'reload', :id => @group
end
end
def reload
@group = Group.find(params[:group_id])
render :update do |page|
page.replace_html 'members', :partial => 'shared/memberships/current_members', :object => @group
page.replace_html 'non_members', :partial => 'shared/memberships/non_members', :object => @group

View file

@ -10,7 +10,7 @@
<li style="margin-left:-15px">
<b><%= membership.user.nick %></b> (<%=h membership.user.first_name + ' ' + membership.user.last_name %>)
| <%= link_to_remote 'entfernen',
:url => { :controller => '/memberships', :action => 'drop_member', :group_id => @group, :membership_id => membership },
:url => { :controller => '/memberships', :action => 'drop_member', :id => @group, :membership_id => membership },
:before => "Element.show('loader')",
:success => "Element.hide('loader')" %>
</li>

View file

@ -3,7 +3,7 @@
<li>
<b><%= user.nick %></b> (<%=h user.first_name + ' ' + user.last_name %>)
| <%= link_to_remote 'hinzufügen',
:url => { :controller => '/memberships', :action => 'add_member', :group_id => @group, :user_id => user },
:url => { :controller => '/memberships', :action => 'add_member', :id => @group, :user_id => user },
:before => "Element.show('loader')",
:success => "Element.hide('loader')" %>
</li>