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 before_filter :authenticate_membership_or_admin
def add_member def add_member
@group = Group.find(params[:group_id])
user = User.find(params[:user_id]) user = User.find(params[:user_id])
Membership.create(:group => @group, :user => user) Membership.create(:group => @group, :user => user)
redirect_to :action => 'reload', :group_id => @group redirect_to :action => 'reload', :id => @group
end end
def drop_member def drop_member
begin begin
group = Group.find(params[:group_id])
Membership.find(params[:membership_id]).destroy Membership.find(params[:membership_id]).destroy
if User.find(@current_user.id).role_admin? if User.find(@current_user.id).role_admin?
redirect_to :action => 'reload', :group_id => group redirect_to :action => 'reload', :id => @group
else else
# If the user drops himself from admin group # If the user drops himself from admin group
flash[:notice] = MESG_NO_ADMIN_ANYMORE flash[:notice] = MESG_NO_ADMIN_ANYMORE
@ -21,12 +19,11 @@ class MembershipsController < ApplicationController
end end
rescue => error rescue => error
flash[:error] = error.to_s flash[:error] = error.to_s
redirect_to :action => 'reload', :group_id => group redirect_to :action => 'reload', :id => @group
end end
end end
def reload def reload
@group = Group.find(params[:group_id])
render :update do |page| render :update do |page|
page.replace_html 'members', :partial => 'shared/memberships/current_members', :object => @group page.replace_html 'members', :partial => 'shared/memberships/current_members', :object => @group
page.replace_html 'non_members', :partial => 'shared/memberships/non_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"> <li style="margin-left:-15px">
<b><%= membership.user.nick %></b> (<%=h membership.user.first_name + ' ' + membership.user.last_name %>) <b><%= membership.user.nick %></b> (<%=h membership.user.first_name + ' ' + membership.user.last_name %>)
| <%= link_to_remote 'entfernen', | <%= 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')", :before => "Element.show('loader')",
:success => "Element.hide('loader')" %> :success => "Element.hide('loader')" %>
</li> </li>

View file

@ -3,7 +3,7 @@
<li> <li>
<b><%= user.nick %></b> (<%=h user.first_name + ' ' + user.last_name %>) <b><%= user.nick %></b> (<%=h user.first_name + ' ' + user.last_name %>)
| <%= link_to_remote 'hinzufügen', | <%= 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')", :before => "Element.show('loader')",
:success => "Element.hide('loader')" %> :success => "Element.hide('loader')" %>
</li> </li>