From 8384eff7f2ca9992df4f41c8ba0e045bfd05b622 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 29 Apr 2015 23:17:24 +0800 Subject: [PATCH 1/8] =?UTF-8?q?delayed=5Fjob=E6=9D=A1=E4=BB=B6=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a930b5467..d0a928bfa 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -33,7 +33,7 @@ class Mailer < ActionMailer::Base @target = cls end def method_missing(name, *args, &block) - if Setting.delayjob_enabled && Object.const_defined?('Delayed') + if Setting.delayjob_enabled? && Object.const_defined?('Delayed') @target.delay.send(name, *args, &block) else @target.send(name, *args, &block).deliver From dbccf9034dc839da1540d305b0f995146f2d4f55 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 30 Apr 2015 10:31:06 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d0a928bfa..7ccee1932 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -143,7 +143,7 @@ class Mailer < ActionMailer::Base @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty? } - binding.pry if Rails.env.development? + mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 mail :to => user.mail,:subject => subject if has_content end @@ -818,11 +818,12 @@ class Mailer < ActionMailer::Base end set_language_if_valid @initial_language - super headers do |format| + m = super headers do |format| format.text format.html unless Setting.plain_text_mail? end - + mylogger.debug "Sent a mail from #{m.from} to [#{m.to},#{m.cc}, #{m.bcc if Setting.bcc_recipients?}] subject: #{m.subject}" + m end def initialize(*args) @@ -877,7 +878,11 @@ class Mailer < ActionMailer::Base end def mylogger - Rails.logger + if Setting.delayjob_enabled? + Delayed::Worker.logger + else + Rails.logger + end end def add_attachments(obj) From 538ba33174ba63fe056bef55cc90307fb7aeaae2 Mon Sep 17 00:00:00 2001 From: whimlex Date: Thu, 30 Apr 2015 10:47:34 +0800 Subject: [PATCH 3/8] =?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 4/8] =?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 5/8] =?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%; From 76b4ae24dac2171c41e6e24de3d5c090b3dc81dd Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 30 Apr 2015 16:30:02 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=82=80=E8=AF=B7--=E9=82=AE=E4=BB=B6=E5=90=8D=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=88=90=E7=94=A8=E6=88=B7=E7=82=B9=E5=87=BB=E5=90=8C?= =?UTF-8?q?=E6=84=8F=E6=8C=89=E9=92=AE=E5=90=8E=E6=89=8D=E8=83=BD=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 7 +++---- app/models/mailer.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2b58f1265..96807d2dc 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -247,10 +247,9 @@ class ProjectsController < ApplicationController # 1、自动注册 # 2、加入项目、创建角色 # 3、用户得分 - if params[:login] - # 自动激活用户 - user.status = 1 - user.save + if params[:email] + user = User.find_by_mail(params[:email].to_s) + Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id) end if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d35374fcf..e2ccb2230 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -71,14 +71,14 @@ class Mailer < ActionMailer::Base # 邀请已注册的用户加入项目 def request_member_to_project(email, project, invitor) + @subject = "#{invitor.name} #{l(:label_invite_project)}: #{project.name} " 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}" + @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, :email => email, :token => @token.value) + mail :to => email, :subject => @subject end # author: alan From 88bbd70102a3eedc09fe7f2fd4f54d188cdc004e Mon Sep 17 00:00:00 2001 From: whimlex Date: Thu, 30 Apr 2015 17:24:30 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=EF=BC=9B=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=A1=B9=E7=9B=AE=E5=AF=BC=E8=88=AA=E5=88=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=EF=BC=9B?= =?UTF-8?q?IE=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=BC=A9=E7=95=A5=E5=9B=BE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 +- .../attachments/_project_file_links.html.erb | 70 +++++-------------- app/views/avatar/_avatar_preview.html.erb | 66 +++++++++++++++++ app/views/issues/show.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 7 +- public/stylesheets/project.css | 3 +- 6 files changed, 91 insertions(+), 61 deletions(-) create mode 100644 app/views/avatar/_avatar_preview.html.erb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 65ad32602..405dc72ed 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -329,12 +329,12 @@ module ApplicationHelper imagesize = attachment.thumbnail(:size => "200*200") imagepath = named_attachment_path(attachment, attachment.filename) if imagesize - link_to image_tag(thumbnail_path(attachment), height: '73', width: '100', name: 'issue_attachment_picture'), + link_to image_tag(thumbnail_path(attachment), height: '73', width: '100', class: 'issue_attachment_picture'), imagepath, :title => attachment.filename else - link_to image_tag(imagepath , height: '73', width: '100', name: 'issue_attachment_picture'), + link_to image_tag(imagepath , height: '73', width: '100', class: 'issue_attachment_picture'), imagepath, :title => attachment.filename end diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index a42593290..a18d819da 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -1,62 +1,28 @@
diff --git a/app/views/avatar/_avatar_preview.html.erb b/app/views/avatar/_avatar_preview.html.erb new file mode 100644 index 000000000..f7a014c64 --- /dev/null +++ b/app/views/avatar/_avatar_preview.html.erb @@ -0,0 +1,66 @@ + + +
+ +
+
+ diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index bed1e3d77..8fb63bd10 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -4,7 +4,7 @@ <% html_title "#{@issue.tracker.name} #{@issue.source_from}'#'#{@issue.project_index}: #{@issue.subject}" %>
- <%= @issue.project.name %> > + <%= link_to "#{@issue.project.name}"+">", project_issues_path(@issue.project) %> <%= "#" + @issue.project_index %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 096dadf8b..64a9111e0 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -89,7 +89,7 @@ <%=l(:label_project_hosting_platform) %> > - <%= link_to @project.name, nil %> + <%= link_to @project.name, project_path(@project.id) %>