From 87fdd840ecb014257c1ea5b4d3967ffdc665f319 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 11:39:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=A2=9E=E5=8A=A0=E5=B7=B2=E6=98=AF=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 17 +++++++++++------ .../applied_project/applied_join_project.js.erb | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) 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/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 From 36c07f96642ef7bfbd1b1b3046d30897c290838e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 14:16:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=88=90=E5=91=98=E5=8A=A0=E5=85=A5=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E9=A1=B5=E9=9D=A2=E4=B8=8D=E4=BC=9A=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 4 +- app/views/members/create.js.erb | 8 +- app/views/projects/settings/_members.html.erb | 80 ++++++++++++------- 3 files changed, 60 insertions(+), 32 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index ca80d90f8..668e243c9 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 :homepage, :maximum => 255 validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH 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 %>