From 538ba33174ba63fe056bef55cc90307fb7aeaae2 Mon Sep 17 00:00:00 2001 From: whimlex Date: Thu, 30 Apr 2015 10:47:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E6=8B=89=E4=BC=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachments/_project_file_links.html.erb | 49 +++++++++++++++---- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index 28fde5fe1..a42593290 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -1,23 +1,49 @@ +
<% is_float ||= false %> <% for attachment in attachments %> From 119e540373f154b7c9adad3498d005ff5ba2293d Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 30 Apr 2015 11:08:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=B7=B2=E6=B3=A8=E5=86=8C=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 11 ++++++++++ app/models/mailer.rb | 12 ++++++++++ .../mailer/request_member_to_project.html.erb | 22 +++++++++++++++++++ .../mailer/request_member_to_project.text.erb | 3 +++ config/locales/projects/zh.yml | 4 +++- 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 app/views/mailer/request_member_to_project.html.erb create mode 100644 app/views/mailer/request_member_to_project.text.erb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 76e136216..2b58f1265 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -344,12 +344,22 @@ class ProjectsController < ApplicationController end + # 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定) def send_mail_to_member if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? email = params[:mail] Mailer.run.send_invite_in_project(email, @project, User.current) @is_zhuce =false flash[:notice] = l(:notice_email_sent, :value => email) + elsif !User.find_by_mail(params[:mail].to_s).nil? + user = User.find_by_mail(params[:mail].to_s) + if !user.member_of?(@project) + email = params[:mail] + Mailer.run.request_member_to_project(email, @project, User.current) + flash[:notice] = l(:notice_email_sent, :value => email) + else + flash[:error] = l(:label_member_of_project, :value => email) + end else flash[:error] = l(:notice_registed_error, :value => email) @is_zhuce = true @@ -358,6 +368,7 @@ class ProjectsController < ApplicationController format.html{redirect_to invite_members_by_mail_project_url(@project)} end end + #发送邮件邀请新用户 def invite_members_by_mail if User.current.member_of?(@project) || User.current.admin? diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e67d042e1..d35374fcf 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -69,6 +69,18 @@ class Mailer < ActionMailer::Base mail :to => email, :subject => @subject end + # 邀请已注册的用户加入项目 + def request_member_to_project(email, project, invitor) + user = User.find_by_mail(email.to_s) + Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id) + @invitor_name = "#{invitor.name}" + @project_name = "#{project.name}" + @user = user + @token = Token.get_token_from_user(user, 'autologin') + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,:user => user, :token => @token.value) + mail :to => email, :invitor_name => "#{@invitor_name}", :project_name => "#{@project_name}" + end + # author: alan # 根据用户选择发送个人日报或周报 # 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言 diff --git a/app/views/mailer/request_member_to_project.html.erb b/app/views/mailer/request_member_to_project.html.erb new file mode 100644 index 000000000..7c0d25dbb --- /dev/null +++ b/app/views/mailer/request_member_to_project.html.erb @@ -0,0 +1,22 @@ + +
+
    + +
  • <%= l(:mail_issue_content)%> + +

    <%= @invitor_name %> 邀请您加入项目:<%= @project_name %>

    +
    +

    点击“同意加入”按钮,即可快速加入项目!


    + +
    +
    +
  • + +
+ +
+
+ + diff --git a/app/views/mailer/request_member_to_project.text.erb b/app/views/mailer/request_member_to_project.text.erb new file mode 100644 index 000000000..ef2f5d130 --- /dev/null +++ b/app/views/mailer/request_member_to_project.text.erb @@ -0,0 +1,3 @@ +<%= @invitor_name %> +<%= @project_name %> +<%= link_to( l(:label_apply_project), @project_url) %> \ No newline at end of file diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 3b125181e..e371296a5 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -48,11 +48,13 @@ zh: # 左边栏 # label_project_id: "项目ID:" - + + label_agree_join_project: 同意加入 label_apply_project: "+申请加入" label_button_following: "+添加关注" label_exit_project: 退出项目 label_apply_project_waiting: 已处理申请,请等待管理员审核 + label_member_of_project: 该用户已经是项目成员了! label_unapply_project: 取消申请 lable_sure_exit_project: 是否确认退出该项目 label_friend_organization: 圈子模式 From 78c410b1ecd4bb1a2a3518d51186c11c2278e458 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 30 Apr 2015 11:10:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E4=B8=AD=E5=A4=9A=E4=BD=99=E7=9A=84=E5=AF=B9=E5=8B=BE=E5=9B=BE?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/project.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 4f9c6ec78..4b26d74aa 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -338,7 +338,7 @@ a:hover.st_add{ color:#ff8e15;} .newpro_box input{ height:26px; float:left; margin-bottom:10px;} .newpro_box textarea{ height:150px; float:left; margin-bottom:10px;} .newpro_box select{ height:29px; float:left; margin-bottom:10px;} -.label{ width:80px; text-align:right; font-size:14 background-image: url(../images/true.png); } +/*.label{ width:80px; text-align:right; font-size:14 background-image: url(../images/true.png); }*/ .icon-reload { background-image: url(../images/reload.png); } .icon { background-position: 0% 50%;