summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/users_controller.rb21
-rw-r--r--app/views/users/_memberships.rhtml29
-rw-r--r--app/views/users/edit.rhtml2
-rw-r--r--public/images/arrow_down.pngbin0 -> 171 bytes
4 files changed, 52 insertions, 0 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 47d0e51c9..ab4aae08d 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -80,6 +80,27 @@ class UsersController < ApplicationController
end
end
@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
def destroy
diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml
new file mode 100644
index 000000000..ccf2111a6
--- /dev/null
+++ b/app/views/users/_memberships.rhtml
@@ -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> \ No newline at end of file
diff --git a/app/views/users/edit.rhtml b/app/views/users/edit.rhtml
index 2332b70ad..0da99d0d2 100644
--- a/app/views/users/edit.rhtml
+++ b/app/views/users/edit.rhtml
@@ -4,3 +4,5 @@
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>
+
+<%= render :partial => 'memberships' %> \ No newline at end of file
diff --git a/public/images/arrow_down.png b/public/images/arrow_down.png
new file mode 100644
index 000000000..ea37f3a9e
--- /dev/null
+++ b/public/images/arrow_down.png
Binary files differ