diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 76e136216..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 @@ -344,12 +343,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 +367,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/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/models/mailer.rb b/app/models/mailer.rb index e67d042e1..7756b7e27 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) + @subject = "#{invitor.name} #{l(:label_invite_project)}: #{project.name} " + user = User.find_by_mail(email.to_s) + @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 # 根据用户选择发送个人日报或周报 # 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言 @@ -154,7 +166,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 @@ -829,11 +841,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) @@ -888,7 +901,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) diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index 28fde5fe1..a18d819da 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -1,35 +1,30 @@ +
<% is_float ||= false %> <% for attachment in attachments %> 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) %>