From 17317da31464cde8a675c8ab04cc873d48b45af1 Mon Sep 17 00:00:00 2001 From: huangjingquan Date: Wed, 6 Nov 2013 09:13:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=92=8C=E8=AF=BE=E7=A8=8B=E9=87=8C=E9=9D=A2=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=88=90=E5=91=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/views/layouts/base_courses.html.erb | 12 +-- app/views/projects/settings/_members.html.erb | 98 ++++++++++++++----- 3 files changed, 83 insertions(+), 29 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index b7dbb5822..042e57ee6 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -8,7 +8,7 @@ class CoursesController < ApplicationController course = Project.find(params[:object_id]) if params[:course_password] == Course.find_by_extra(course.identifier).password members = [] - members << Member.new(:role_ids => [5], :user_id => User.current.id) + members << Member.new(:role_ids => [10], :user_id => User.current.id) course.members << members StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 39203679c..cb1694629 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -52,15 +52,15 @@
- <% @project = Project.find_by_id(@project.id)%> - <% @course = Course.find_by_extra(@project.identifier)%> + <% @project = Project.find_by_id(@project.id) %> + <% @course = Course.find_by_extra(@project.identifier) %>
<% if(@project.project_type==1) %> <% if get_avatar?(@project) %> <%= image_tag(url_to_avatar(@project), :class => "avatar2") %> <% else %> - <%= link_to image_tag('../images/avatars/Project/course.jpg', :class => "avatar2"), project_path(@project)%> + <%= link_to image_tag('../images/avatars/Project/course.jpg', :class => "avatar2"), project_path(@project) %> <% end %> <% else %> <%= image_tag(url_to_avatar(@project), :class => "avatar2") %> @@ -69,12 +69,12 @@
<%= @project.name %>
- <%if User.current.logged?%> - <% if @course.teacher.id == User.current.id%> + <%if User.current.logged? %> + <% if @course.teacher.id == User.current.id %>
<%= link_to l(:label_course_modify_settings), {:controller => 'projects', :action => 'settings', :id => @project} %> <% else %> - <%= join_in_course(@project, User.current)%> + <%= join_in_course(@project, User.current) %> <% end %> <% unless User.current.member_of?(@project) %> diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb index bbc598e20..828cb7f8c 100644 --- a/app/views/projects/settings/_members.html.erb +++ b/app/views/projects/settings/_members.html.erb @@ -1,20 +1,6 @@ <%= error_messages_for 'member' %> -<% if @project.project_type == 1 %> -<% r = [] %> -<% for i in 3..5 %> -<% roles = Role.givable.all[i] +<% roles = Role.find_all_givable members = @project.member_principals.includes(:roles, :principal).all.sort %> - <% r << roles %> - <% end %> -<% else %> -<% r = [] %> -<% for i in 0..2 %> -<% roles = Role.givable.all[i] - members = @project.member_principals.includes(:roles, :principal).all.sort %> - <% r << roles %> - <% end %> - -<% end %>
<% if members.any? %> @@ -30,11 +16,40 @@ - + <% else %> + + :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> + + <% end %> + <% else %> + + <% end %> + <%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %> <% end; reset_cycle %> @@ -64,6 +99,25 @@ <% end %> + +<%= error_messages_for 'member' %> +<% if @project.project_type == 1 %> +<% r = [] %> +<% for i in 3..5 %> +<% roles = Role.givable.all[i] + members = @project.member_principals.includes(:roles, :principal).all.sort %> + <% r << roles %> + <% end %> +<% else %> +<% r = [] %> +<% for i in 0..2 %> +<% roles = Role.givable.all[i] + members = @project.member_principals.includes(:roles, :principal).all.sort %> + <% r << roles %> + <% end %> +<% end %> + +
<% if r.any? %> <%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %> @@ -75,7 +129,7 @@
<%= render_principals_for_new_members(@project) %>
- +

<%= l(:label_role_plural) %>: <% r.each do |role| %>

<%= link_to_user member.principal %> - <%=h member.roles.sort.collect(&:to_s).join(', ') %> + + + <% if @project.project_type == 1 %> + <% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %> + 老师 + <% else %> + <%=h member.roles.sort.collect(&:to_s).join(', ') %> + <% end %> + <% else %> + <%=h member.roles.sort.collect(&:to_s).join(', ') %> + <% end %> + <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), :method => :put, :html => { :id => "member-#{member.id}-roles-form", :class => 'hol' }} ) do |f| %> + +<%= error_messages_for 'member' %> +<% if @project.project_type == 1 %> +<% r = [] %> +<% for i in 3..5 %> +<% roles = Role.givable.all[i] + members = @project.member_principals.includes(:roles, :principal).all.sort %> + <% r << roles %> + <% end %> +<% else %> +<% r = [] %> +<% for i in 0..2 %> +<% roles = Role.givable.all[i] + members = @project.member_principals.includes(:roles, :principal).all.sort %> + <% r << roles %> + <% end %> +<% end %> +

<% r.each do |role| %>
@@ -46,14 +61,34 @@ %>

<% end %>
- <%= link_to_function l(:button_edit), + + <%= error_messages_for 'member' %> +<% roles = Role.find_all_givable + members = @project.member_principals.includes(:roles, :principal).all.sort %> + <% if @project.project_type == 1 %> + <%if member.roles.first.to_s == "Manager" %> + + <%= link_to_function l(:button_edit), "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", :class => 'icon icon-edit' %> - <%= delete_link membership_path(member), + <%= delete_link membership_path(member), :remote => true, - :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> - + <%= link_to_function l(:button_edit), + "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", + :class => 'icon icon-edit' %> + <%= delete_link membership_path(member), + :remote => true, + :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> +