added the ability to manage users memberships directly on users/edit (administration module)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@118 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a6c8feea21
commit
4c84165aa0
|
@ -80,6 +80,27 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@auth_sources = AuthSource.find(:all)
|
@auth_sources = AuthSource.find(:all)
|
||||||
|
@roles = Role.find :all
|
||||||
|
@projects = Project.find(:all) - @user.projects
|
||||||
|
@membership ||= Member.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit_membership
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
@membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
|
||||||
|
@membership.attributes = params[:membership]
|
||||||
|
if request.post? and @membership.save
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
end
|
||||||
|
redirect_to :action => 'edit', :id => @user and return
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_membership
|
||||||
|
@user = User.find(params[:id])
|
||||||
|
if request.post? and Member.find(params[:membership_id]).destroy
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
end
|
||||||
|
redirect_to :action => 'edit', :id => @user and return
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<div class="box" style="margin-top: 16px;">
|
||||||
|
<h3><%= l(:label_project_plural) %></h3>
|
||||||
|
|
||||||
|
<% @user.memberships.each do |membership| %>
|
||||||
|
<%= start_form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") %>
|
||||||
|
<p style="margin:0;padding-top:0;">
|
||||||
|
<label><%= membership.project.name %></label>
|
||||||
|
<select name="membership[role_id]">
|
||||||
|
<%= options_from_collection_for_select @roles, "id", "name", membership.role_id %>
|
||||||
|
</select>
|
||||||
|
<%= submit_tag l(:button_change), :class => "button-small" %>
|
||||||
|
<%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :confirm => l(:text_are_you_sure), :post => true, :class => 'pic picDelete' %>
|
||||||
|
</p>
|
||||||
|
<%= end_form_tag %>
|
||||||
|
<% end %>
|
||||||
|
<hr />
|
||||||
|
<p>
|
||||||
|
<label><%=l(:label_project_new)%></label><br/>
|
||||||
|
<%= start_form_tag({ :action => 'edit_membership', :id => @user }) %>
|
||||||
|
<select name="membership[project_id]">
|
||||||
|
<%= options_from_collection_for_select @projects, "id", "name", @membership.project_id %>
|
||||||
|
</select>
|
||||||
|
<select name="membership[role_id]">
|
||||||
|
<%= options_from_collection_for_select @roles, "id", "name", @membership.role_id %>
|
||||||
|
</select>
|
||||||
|
<%= submit_tag l(:button_add) %>
|
||||||
|
<%= end_form_tag %>
|
||||||
|
</p>
|
||||||
|
</div>
|
|
@ -4,3 +4,5 @@
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_save) %>
|
<%= submit_tag l(:button_save) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= render :partial => 'memberships' %>
|
Binary file not shown.
After Width: | Height: | Size: 171 B |
Loading…
Reference in New Issue