diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index f5c42f7b4..f2c0eb056 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -6,13 +6,18 @@ class AppliedProjectController < ApplicationController @project = Project.find_by_id(params[:project_id]) if params[:project_join] if @project - @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) - if @applieds.count == 0 - appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) - Mailer.applied_project(appliedproject).deliver - @status = 2 + user = User.find @user_id + if user.member_of?(@project) + @status = 3 else - @status = 1 + @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) + if @applieds.count == 0 + appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) + Mailer.applied_project(appliedproject).deliver + @status = 2 + else + @status = 1 + end end else @status = 0 diff --git a/app/models/project.rb b/app/models/project.rb index 085851c29..df403bb5c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -114,8 +114,8 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier validates_uniqueness_of :name - validates_associated :repository, :wiki - # validates_length_of :description, :maximum => 255 + validates_associated :wiki#, :repository + # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255 validates_length_of :enterprise_name, :maximum => 255 validates_length_of :homepage, :maximum => 255 diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index deac2c9ce..3f4f6aff7 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -4,6 +4,8 @@ alert("请勿重复申请加入该项目"); <% elsif @status == 2%> alert("申请成功"); +<% elsif @status == 3%> + alert("您已加入该项目"); <%else%> alert("申请失败"); <%end%> \ No newline at end of file diff --git a/app/views/members/create.js.erb b/app/views/members/create.js.erb index 3b01980ad..35280b7a4 100644 --- a/app/views/members/create.js.erb +++ b/app/views/members/create.js.erb @@ -12,7 +12,11 @@ hideOnLoad(); $("#member-<%= member.id %>").effect("highlight"); <% end %> <% else %> - <% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ') %> - alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors))) %>'); + <% if @members %> + <% errors = @members.collect {|m| m.errors.full_messages}.flatten.uniq.join(', ')%> + alert('<%= raw(escape_javascript(l(:notice_failed_to_save_members, :errors => errors || ''))) %>'); + <% else%> +// alert(''); + <% end%> <% end %> <% end %> diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb index 25f02da0d..9c9c64bd1 100644 --- a/app/views/projects/settings/_members.html.erb +++ b/app/views/projects/settings/_members.html.erb @@ -14,8 +14,12 @@ - - + + <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> @@ -24,26 +28,30 @@ <% members.each do |member| %> <% next if member.new_record? %> - + @@ -77,7 +85,9 @@
<%= l(:label_user) %><%= l(:label_role_plural) %> + <%= l(:label_user) %> + + <%= l(:label_role_plural) %> +
<%= link_to_user member.principal %> + <%= link_to_user member.principal %> + - - <%= h member.roles.sort.collect(&:to_s).join(', ') %> - + + <%= h member.roles.sort.collect(&:to_s).join(', ') %> + <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), :method => :put, :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}} ) do |f| %> -

<% roles.each do |role| %>
- <% end %>

+ <% end %> +

<%= hidden_field_tag 'membership[role_ids][]', '' %> -

<%= submit_tag l(:button_change), :class => "small" %> +

+ <%= submit_tag l(:button_change), :class => "small" %> <%= link_to_function l(:button_cancel), "$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;" - %>

+ %> +

<% end %>
<% else %> -

<%= l(:label_no_data) %>

+

+ <%= l(:label_no_data) %> +

<% end %> @@ -87,20 +97,25 @@
<%= form_for(@applied_members, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
- <%= l(:label_apply_project) %> - + + <%= l(:label_apply_project) %> +
<%= render_principals_for_applied_members(@project) %>

-

<%= l(:label_role_plural) %>: +

+ <%= l(:label_role_plural) %>: <% roles.each do |role| %> - - - <% end %>

- -

<%= submit_tag l(:label_approve), :id => 'member-add-submit' %> + + <% end %> +

+

+ <%= submit_tag l(:label_approve), :id => 'member-add-submit' %> <%= submit_tag l(:label_refusal), :name => "refusal_button", :id => 'member-refusal-submit' %>

@@ -110,9 +125,13 @@ <%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
- <%= l(:label_member_new) %> - -

<%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %>

+ + <%= l(:label_member_new) %> + +

+ <%= label_tag "principal_search", l(:label_principal_search) %> + <%= text_field_tag 'principal_search', nil %> +

<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
@@ -120,13 +139,18 @@

-

<%= l(:label_role_plural) %>: +

+ <%= l(:label_role_plural) %>: <% roles.each do |role| %> - - - <% end %>

- -

<%= submit_tag l(:button_add), :id => 'member-add-submit' %>

+ + <% end %> +

+

+ <%= submit_tag l(:button_add), :id => 'member-add-submit' %> +

<% end %> <% end %>