From 6cddb59a4a92c2281c2c089d0f2ec27f5b30e58b Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 2 Jun 2015 11:02:12 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=8F=90=E9=86=92=EF=BC=9A=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=8D=E8=83=BD=E6=94=B6=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 42 +- .../mailer/send_for_user_activities.html.erb | 616 +++++++++--------- 2 files changed, 324 insertions(+), 334 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index dbc5d3cff..44139fb03 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -45,7 +45,6 @@ class Mailer < ActionMailer::Base MailerProxy.new(self) end - # author: alan # 发送邀请未注册用户加入项目邮件 # 功能: 在加入项目的同时自动注册用户 def send_invite_in_project(email, project, invitor) @@ -101,16 +100,16 @@ class Mailer < ActionMailer::Base course_ids = courses.map {|course| course.id}.join(",") # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷 - sql = "select DISTINCT i.* from issues i, watchers w - where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id} - or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id})) - and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" + # sql = "select DISTINCT i.* from issues i, watchers w + # where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id} + # or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id})) + # and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" + sql = "select DISTINCT i.* from issues i where (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" @issues = Issue.find_by_sql(sql) # @bids 查询课程作业,包括老师发布的作业,以及user提交作业 # @attachments查询课程课件更新 @attachments ||= [] - @bids ||= [] # 老师发布的作业 unless courses.first.nil? @@ -142,9 +141,9 @@ class Mailer < ActionMailer::Base # 查询user在课程中发布的通知,项目中发的新闻 @course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.course_id in (#{course_ids}) - and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] + and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] @project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids}) - and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] + and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] # 查询user在课程及个人中留言 @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where @@ -165,7 +164,7 @@ class Mailer < ActionMailer::Base } mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 - mail :to => user.mail,:subject => subject if has_content + mail :to => user.mail, :subject => subject if has_content end # 公共讨论区发帖、回帖添加邮件发送信息 @@ -188,8 +187,8 @@ class Mailer < ActionMailer::Base :subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]", :filter => true end - # Builds a Mail::Message object used to email recipients of the added journals for message. + # Builds a Mail::Message object used to email recipients of the added journals for message. # 留言分为直接留言,和对留言人留言的回复 # 字段说明在JournalsForMessage.rb # 直接留言后 reply_id,m_parent_id 为空,相对应的at_user取值为nil @@ -511,7 +510,7 @@ class Mailer < ActionMailer::Base end # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added. - # + # 新增新闻评论时邮件通知 # Example: # news_comment_added(comment) => Mail::Message object # Mailer.news_comment_added(comment) => sends an email to the news' project recipients @@ -526,9 +525,9 @@ class Mailer < ActionMailer::Base @comment = comment @news_url = url_for(:controller => 'news', :action => 'show', :id => news) mail :to => news.recipients, - :cc => news.watcher_recipients, - :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}", - :filter => true + :cc => news.watcher_recipients, + :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}", + :filter => true elsif news.course redmine_headers 'Course' => news.course.id @author = comment.author @@ -563,9 +562,9 @@ class Mailer < ActionMailer::Base @message = message @message_url = url_for(message.event_url) mail :to => recipients, - :cc => cc, - :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", - :filter => true + :cc => cc, + :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", + :filter => true elsif message.course redmine_headers 'Course' => message.course.id, 'Topic-Id' => (message.parent_id || message.id) @@ -909,10 +908,11 @@ class Mailer < ActionMailer::Base if email.attachments && email.attachments.any? email.attachments.each do |attachment| obj.attachments << Attachment.create(:container => obj, - :file => attachment.decoded, - :filename => attachment.filename, - :author => user, - :content_type => attachment.mime_type) + :file => attachment.decoded, + :filename => attachment.filename, + :author => user, + + :content_type => attachment.mime_type) end end end diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index 73a561ca3..2cf070960 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -1,341 +1,331 @@ +
+

+ <%= @subject %> +

+<% if @attachments.first || @course_news.first || @bids.first || + @homeworks.first || @course_journal_messages.first|| @course_messages.first %> +
+

<%= l(:label_course_overview)%>

+ <% unless @course_news.first.nil? %> +
    +

    + <%= l(:label_course_news) %> + (<%= @course_news.count %>) +

    + <% @course_news.each do |course_new|%> +
  • + + [ + <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + <%= link_to course_new.author, user_activities_url(course_new.author,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_project_notice) %> + <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(course_new.created_on) %> +
  • + <% end %> +
    +
+ <% end %> + <% if !@bids.first.nil? || !@homeworks.first.nil? %> +
    + +

    <%= l(:label_homework_overview) %>(<%= @bids.count %>)

    + <% unless @bids.first.nil?%> + <% @bids.each do |bid| %> +
  • + + [ + + <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(bid.courses.first, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + + <%= link_to bid.author, user_activities_url(bid.author,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_course_homework) %> + + <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => bid.id,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(bid.created_on) %> +
  • + <% end %> + <% end %> + <% unless @homeworks.first.nil? %> + <% @homeworks.each do |homework| %> +
  • + + [ + + <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + + <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_course_submit_homework) %> + + <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(homework.created_at) %> +
  • + <% end %> + <% end %> +
    +
+ <% end %> + <% unless @course_journal_messages.first.nil? %> +
    -
    -

    -<%= @subject %> -

    -<% if @attachments.first || @course_news.first || @bids.first || - @homeworks.first || @course_journal_messages.first|| @course_messages.first %> -
    -

    <%= l(:label_course_overview)%>

    - <% unless @course_news.first.nil? %> -
      - -

      - <%= l(:label_course_news) %> - (<%= @course_news.count %>) -

      - - <% @course_news.each do |course_new|%> -
    • - - [ - - <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to course_new.author, user_activities_url(course_new.author,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_project_notice) %> - - <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(course_new.created_on) %> -
    • - <% end %> +

      + <%= l(:view_course_journals_for_messages) %> + (<%= @course_journal_messages.count %>) +

      -
      -
    - <% end %> - <% if !@bids.first.nil? || !@homeworks.first.nil? %> -
      - -

      <%= l(:label_homework_overview) %>(<%= @bids.count %>)

      - <% unless @bids.first.nil?%> - <% @bids.each do |bid| %> -
    • - - [ - - <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(bid.courses.first, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to bid.author, user_activities_url(bid.author,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_course_homework) %> - - <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => bid.id,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(bid.created_on) %> -
    • + <% @course_journal_messages.each do |course_journal_message|%> +
    • + + [ + + <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + + <%= link_to course_journal_message.user, user_activities_url(course_journal_message.user,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_send_course_journals_for_messages) %> + + <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(course_journal_message.created_on) %> +
    • + <% end %> + +
      +
    <% end %> + + <% unless @course_messages.first.nil? %> +
      + +

      + <%= l(:view_borad_course) %> + (<%= @course_journal_messages.count %>) +

      + + <% @course_messages.each do |course_message|%> +
    • + + [ + + <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + + <%= link_to course_message.author, user_activities_url(course_message.author,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_send_course_messages) %> + + <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_id,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(course_message.created_on) %> +
    • + <% end %> + +
      +
    <% end %> - <% unless @homeworks.first.nil? %> - <% @homeworks.each do |homework| %> -
  • - - [ - - <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_course_submit_homework) %> - - <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(homework.created_at) %> -
  • + + <% unless @attachments.first.nil? %> +
      +

      + <%= l(:label_course_attendingcontestwork_download) %> + (<%= @attachments.count %>) +

      + + <% @attachments.each do |attachment|%> +
    • + + [ + + <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + + <%= link_to attachment.author, user_activities_url(attachment.author,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_course_file_upload) %> + + <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(attachment.created_on) %> +
    • + <% end %> +
      +
    <% end %> +
    +<% end %> +<% if @issues.first || @project_messages.first %> +
    +

    <%= l(:label_project_overview_new)%>

    + <% unless @issues.first.nil? %> +
      +

      + <%= l(:label_issue_tracking) %> + (<%= @issues.count %>) +

      + <% @issues.each do |issue|%> +
    • + + [ + + <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] + + <%= link_to issue.author, user_activities_url(issue.author,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_project_issue) %> + + <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(issue.created_on) %> +
    • + <% end %> + +
      +
    <% end %> -
    -
- <% end %> - - <% unless @course_journal_messages.first.nil? %> -
    - -

    - <%= l(:view_course_journals_for_messages) %> - (<%= @course_journal_messages.count %>) -

    - - <% @course_journal_messages.each do |course_journal_message|%> -
  • - - [ - - <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to course_journal_message.user, user_activities_url(course_journal_message.user,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_send_course_journals_for_messages) %> - - <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(course_journal_message.created_on) %> -
  • - <% end %> - -
    -
- <% end %> - - <% unless @course_messages.first.nil? %> -
    - -

    - <%= l(:view_borad_course) %> - (<%= @course_journal_messages.count %>) -

    - - <% @course_messages.each do |course_message|%> -
  • - - [ - - <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to course_message.author, user_activities_url(course_message.author,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_send_course_messages) %> - - <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_id,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(course_message.created_on) %> -
  • - <% end %> - -
    -
- <% end %> - - <% unless @attachments.first.nil? %> -
    -

    - <%= l(:label_course_attendingcontestwork_download) %> - (<%= @attachments.count %>) -

    - - <% @attachments.each do |attachment|%> -
  • - - [ - - <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to attachment.author, user_activities_url(attachment.author,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_course_file_upload) %> - - <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(attachment.created_on) %> -
  • - <% end %> -
    -
- <% end %> -
- <% end %> - <% if @issues.first || @project_messages.first %> -
-

<%= l(:label_project_overview_new)%>

- <% unless @issues.first.nil? %> -
    -

    - <%= l(:label_issue_tracking) %> - (<%= @issues.count %>) -

    - - <% @issues.each do |issue|%> -
  • - - [ - - <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to issue.author, user_activities_url(issue.author,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_project_issue) %> - - <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(issue.created_on) %> -
  • - <% end %> - -
    -
- <% end %> - - <% unless @project_messages.first.nil? %> -
    -

    - <%= l(:project_moule_boards_show) %> - (<%= @project_messages.count %>) -

    - - <% @project_messages.each do |project_message|%> -
  • - - [ - - <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to project_message.author, user_activities_url(project_message.author,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_send_course_messages) %> - - <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(project_message.created_on) %> -
  • - <% end %> - -
    -
- <% end %> - - - -
- <% end %> - <% unless @user_journal_messages.first.nil? %> -
-

<%= l(:label_activities) %>

- -
    -

    - <%= l(:label_user_message) %> - (<%= @user_journal_messages.count %>) -

    - - <% @user_journal_messages.each do |user_journal_message|%> -
  • - - - <%= link_to user_journal_message.user, user_activities_url(user_journal_message.user,:token => @token.value), - :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - <%= l(:label_show_your_message) %> - - <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'),feedback_url(@user,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(user_journal_message.created_on) %>
  • + <% unless @project_messages.first.nil? %> +
      +

      + <%= l(:project_moule_boards_show) %> + (<%= @project_messages.count %>) +

      - <% end %> + <% @project_messages.each do |project_message|%> +
    • + + [ -
      -
    + <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value), + :class=> "wmail_column", + :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> + ] -
- <% end %> - <% if @forums.first || @memos.first %> + <%= link_to project_message.author, user_activities_url(project_message.author,:token => @token.value), :class => "wmail_name", + :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> + <%= l(:label_send_course_messages) %> + + <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value), + :class => 'wmail_info', + :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" + %> + <%= format_time(project_message.created_on) %> + + <% end %> + +
+ + <% end %> + + + +
+<% end %> +<% unless @user_journal_messages.first.nil? %>
-

<%= l(:lable_bar_active) %>

- <% unless @forums.first.nil? %> +

<%= l(:label_activities) %>

+ + + +
+<% end %> +<% if @forums.first || @memos.first %> +
+

<%= l(:lable_bar_active) %>

+ <% unless @forums.first.nil? %> + <% end %> <% unless @memos.first.nil? %>
<% end %> -
- <% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %> - <% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %> - - <% else %> - <%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> - <% end %> - <% end %> -
+
+ <% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %> + <% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %> + + <% else %> + <%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> + <% end %> + <% end %> +
From 64e56eca8e98d902505a5c8eb7c66eae5f9d4d53 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 2 Jun 2015 11:14:13 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=8F=90=E9=86=92?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E8=AE=BA=E5=9D=9B?= =?UTF-8?q?=E6=8F=90=E9=86=92=E4=B8=8D=E5=85=A8?= 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 44139fb03..7be526f41 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -126,7 +126,7 @@ class Mailer < ActionMailer::Base @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") # 查询user在课程。项目中发布的讨论帖子 - messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + messages = Message.find_by_sql("select DISTINCT * from messages where (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") @course_messages ||= [] @project_messages ||= [] unless messages.first.nil? From 0354e65497a0f779f08a9cac70c154c594323a9e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 3 Jun 2015 14:25:22 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9issues=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E9=80=9A=E7=9F=A5=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 138 +++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 70 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7be526f41..e0726599b 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -45,6 +45,7 @@ class Mailer < ActionMailer::Base MailerProxy.new(self) end + # author: alan # 发送邀请未注册用户加入项目邮件 # 功能: 在加入项目的同时自动注册用户 def send_invite_in_project(email, project, invitor) @@ -88,7 +89,7 @@ class Mailer < ActionMailer::Base date_from = "#{date_from} 17:59:59" date_to = "#{date_to} 17:59:59" - + # 生成token用于直接点击登录 @user = user @token = Token.get_token_from_user(user, 'autologin') @@ -100,16 +101,14 @@ class Mailer < ActionMailer::Base course_ids = courses.map {|course| course.id}.join(",") # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷 - # sql = "select DISTINCT i.* from issues i, watchers w - # where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id} - # or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id})) - # and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" - sql = "select DISTINCT i.* from issues i where (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" + sql = "select * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}' + and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" @issues = Issue.find_by_sql(sql) # @bids 查询课程作业,包括老师发布的作业,以及user提交作业 # @attachments查询课程课件更新 @attachments ||= [] + @bids ||= [] # 老师发布的作业 unless courses.first.nil? @@ -118,15 +117,15 @@ class Mailer < ActionMailer::Base for i in 0..count do bids = courses[i].homeworks.where("bids.created_on between '#{date_from}' and '#{date_to}'").order("bids.created_on desc") attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC') - @bids += bids if bids.count > 0 - @attachments += attachments if attachments.count > 0 + @bids += bids if bids.count > 0 + @attachments += attachments if attachments.count > 0 end end # user 提交的作业 @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") # 查询user在课程。项目中发布的讨论帖子 - messages = Message.find_by_sql("select DISTINCT * from messages where (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") @course_messages ||= [] @project_messages ||= [] unless messages.first.nil? @@ -141,9 +140,9 @@ class Mailer < ActionMailer::Base # 查询user在课程中发布的通知,项目中发的新闻 @course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.course_id in (#{course_ids}) - and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] + and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] @project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids}) - and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] + and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] # 查询user在课程及个人中留言 @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where @@ -160,11 +159,11 @@ class Mailer < ActionMailer::Base has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news, @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| - !o.empty? - } + !o.empty? + } mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 - mail :to => user.mail, :subject => subject if has_content + mail :to => user.mail,:subject => subject if has_content end # 公共讨论区发帖、回帖添加邮件发送信息 @@ -187,8 +186,8 @@ class Mailer < ActionMailer::Base :subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]", :filter => true end - # Builds a Mail::Message object used to email recipients of the added journals for message. + # 留言分为直接留言,和对留言人留言的回复 # 字段说明在JournalsForMessage.rb # 直接留言后 reply_id,m_parent_id 为空,相对应的at_user取值为nil @@ -276,11 +275,11 @@ class Mailer < ActionMailer::Base @token = Token.get_token_from_user(user, 'autologin') @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value) - # edit - @issue_author_url = url_for(user_activities_url(@author,:token => @token.value)) - @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) + # edit + @issue_author_url = url_for(user_activities_url(@author,:token => @token.value)) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) - @user_url = url_for(my_account_url(user,:token => @token.value)) + @user_url = url_for(my_account_url(user,:token => @token.value)) subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" @@ -288,13 +287,13 @@ class Mailer < ActionMailer::Base :subject => subject, :filter => true end - # issue.attachments.each do |attach| - # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}") - # end - # cc = issue.watcher_recipients - recipients - #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll") + # issue.attachments.each do |attach| + # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}") + # end + # cc = issue.watcher_recipients - recipients + #mail.attachments['test'] = File.read("#{RAILS.root}/files/2015/01/150114094010_libegl.dll") + - # Builds a Mail::Message object used to email recipients of the edited issue. @@ -323,13 +322,13 @@ class Mailer < ActionMailer::Base @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) @user_url = url_for(my_account_url(user,:token => @token.value)) - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value) + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value) s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " s << "(#{issue.status.name}) " if journal.new_value_for('status_id') s << issue.subject @issue = issue @journal = journal - # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") + # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") mail :to => recipients, :subject => s, :filter => true @@ -359,10 +358,10 @@ class Mailer < ActionMailer::Base @issues = issues @days = days @issues_url = url_for(:controller => 'issues', :action => 'index', - :set_filter => 1, :assigned_to_id => user.id, - :sort => 'due_date:asc') + :set_filter => 1, :assigned_to_id => user.id, + :sort => 'due_date:asc') mail :to => user.mail, - :subject => l(:mail_subject_reminder, :count => issues.size, :days => days) + :subject => l(:mail_subject_reminder, :count => issues.size, :days => days) end #缺陷到期邮件通知 @@ -493,8 +492,8 @@ class Mailer < ActionMailer::Base @news = news @news_url = url_for(:controller => 'news', :action => 'show', :id => news) mail :to => news.recipients, - :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}", - :filter => true + :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}", + :filter => true elsif news.course redmine_headers 'Course' => news.course.id @author = news.author @@ -510,7 +509,7 @@ class Mailer < ActionMailer::Base end # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added. - # 新增新闻评论时邮件通知 + # # Example: # news_comment_added(comment) => Mail::Message object # Mailer.news_comment_added(comment) => sends an email to the news' project recipients @@ -597,12 +596,12 @@ class Mailer < ActionMailer::Base cc = wiki_content.page.wiki.watcher_recipients - recipients @wiki_content = wiki_content @wiki_content_url = url_for(:controller => 'wiki', :action => 'show', - :project_id => wiki_content.project, - :id => wiki_content.page.title) + :project_id => wiki_content.project, + :id => wiki_content.page.title) mail :to => recipients, - :cc => cc, - :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}", - :filter => true + :cc => cc, + :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}", + :filter => true end # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated. @@ -619,15 +618,15 @@ class Mailer < ActionMailer::Base cc = wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients @wiki_content = wiki_content @wiki_content_url = url_for(:controller => 'wiki', :action => 'show', - :project_id => wiki_content.project, - :id => wiki_content.page.title) + :project_id => wiki_content.project, + :id => wiki_content.page.title) @wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff', - :project_id => wiki_content.project, :id => wiki_content.page.title, - :version => wiki_content.version) + :project_id => wiki_content.project, :id => wiki_content.page.title, + :version => wiki_content.version) mail :to => recipients, - :cc => cc, - :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}", - :filter => true + :cc => cc, + :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}", + :filter => true end # Builds a Mail::Message object used to email the specified user their account information. @@ -641,7 +640,7 @@ class Mailer < ActionMailer::Base @password = password @login_url = url_for(:controller => 'account', :action => 'login') mail :to => user.mail, - :subject => l(:mail_subject_register, Setting.app_title) + :subject => l(:mail_subject_register, Setting.app_title) end # Builds a Mail::Message object used to email all active administrators of an account activation request. @@ -654,10 +653,10 @@ class Mailer < ActionMailer::Base recipients = User.active.where(:admin => true).all.collect { |u| u.mail }.compact @user = user @url = url_for(:controller => 'users', :action => 'index', - :status => User::STATUS_REGISTERED, - :sort_key => 'created_on', :sort_order => 'desc') + :status => User::STATUS_REGISTERED, + :sort_key => 'created_on', :sort_order => 'desc') mail :to => recipients, - :subject => l(:mail_subject_account_activation_request, Setting.app_title) + :subject => l(:mail_subject_account_activation_request, Setting.app_title) end # Builds a Mail::Message object used to email the specified user that their account was activated by an administrator. @@ -670,7 +669,7 @@ class Mailer < ActionMailer::Base @user = user @login_url = url_for(:controller => 'account', :action => 'login') mail :to => user.mail, - :subject => l(:mail_subject_register, Setting.app_title) + :subject => l(:mail_subject_register, Setting.app_title) end def lost_password(token) @@ -678,7 +677,7 @@ class Mailer < ActionMailer::Base @token = token @url = url_for(:controller => 'account', :action => 'lost_password', :token => token.value) mail :to => token.user.mail, - :subject => l(:mail_subject_lost_password, Setting.app_title) + :subject => l(:mail_subject_lost_password, Setting.app_title) end def register(token) @@ -686,14 +685,14 @@ class Mailer < ActionMailer::Base @token = token @url = url_for(:controller => 'account', :action => 'activate', :token => token.value) mail :to => token.user.mail, - :subject => l(:mail_subject_register, Setting.app_title) + :subject => l(:mail_subject_register, Setting.app_title) end def test_email(user) set_language_if_valid(user.language) @url = url_for(:controller => 'welcome') mail :to => user.mail, - :subject => 'forge test' + :subject => 'forge test' end # Overrides default deliver! method to prevent from sending an email @@ -701,8 +700,8 @@ class Mailer < ActionMailer::Base def deliver!(mail = @mail) set_language_if_valid @initial_language return false if (recipients.nil? || recipients.empty?) && - (cc.nil? || cc.empty?) && - (bcc.nil? || bcc.empty?) + (cc.nil? || cc.empty?) && + (bcc.nil? || bcc.empty?) # Log errors when raise_delivery_errors is set to false, Rails does not @@ -734,8 +733,8 @@ class Mailer < ActionMailer::Base user_ids = options[:users] scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" + - " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + - " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date + " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + + " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date ) scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? scope = scope.where(:project_id => project.id) if project @@ -799,12 +798,12 @@ class Mailer < ActionMailer::Base def mail(headers={}) headers.merge! 'X-Mailer' => 'Redmine', - 'X-Redmine-Host' => Setting.host_name, - 'X-Redmine-Site' => Setting.app_title, - 'X-Auto-Response-Suppress' => 'OOF', - 'Auto-Submitted' => 'auto-generated', - 'From' => Setting.mail_from, - 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>" + 'X-Redmine-Host' => Setting.host_name, + 'X-Redmine-Site' => Setting.app_title, + 'X-Auto-Response-Suppress' => 'OOF', + 'Auto-Submitted' => 'auto-generated', + 'From' => Setting.mail_from, + 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>" # Removes the author from the recipients and cc # if he doesn't want to receive notifications about what he does @@ -850,7 +849,7 @@ class Mailer < ActionMailer::Base set_language_if_valid Setting.default_language super end - + def self.deliver_mail(mail) return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank? Thread.new do @@ -897,7 +896,7 @@ class Mailer < ActionMailer::Base end def mylogger - if Setting.delayjob_enabled? + if Setting.delayjob_enabled? Delayed::Worker.logger else Rails.logger @@ -908,11 +907,10 @@ class Mailer < ActionMailer::Base if email.attachments && email.attachments.any? email.attachments.each do |attachment| obj.attachments << Attachment.create(:container => obj, - :file => attachment.decoded, - :filename => attachment.filename, - :author => user, - - :content_type => attachment.mime_type) + :file => attachment.decoded, + :filename => attachment.filename, + :author => user, + :content_type => attachment.mime_type) end end end From 9e0a986fe92477d499531200825564b9f5f3c9af Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 3 Jun 2015 16:59:27 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E3=80=81=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E8=AE=A8=E8=AE=BA=E5=8C=BA=E9=82=AE=E4=BB=B6=E6=8F=90?= =?UTF-8?q?=E9=86=92=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 9 ++++----- app/views/mailer/send_for_user_activities.html.erb | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e0726599b..c13334b08 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -83,13 +83,10 @@ class Mailer < ActionMailer::Base # 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言 def send_for_user_activities(user, date_to, days) date_from = date_to - days.days - subject = "[ #{user.show_name}#{l(:label_day_mail)}]" @subject = " #{user.show_name}#{l(:label_day_mail)}" - date_from = "#{date_from} 17:59:59" date_to = "#{date_to} 17:59:59" - # 生成token用于直接点击登录 @user = user @token = Token.get_token_from_user(user, 'autologin') @@ -102,7 +99,7 @@ class Mailer < ActionMailer::Base # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷 sql = "select * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}' - and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" + and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" @issues = Issue.find_by_sql(sql) # @bids 查询课程作业,包括老师发布的作业,以及user提交作业 @@ -125,7 +122,9 @@ class Mailer < ActionMailer::Base @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") # 查询user在课程。项目中发布的讨论帖子 - messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + messages = Message.find_by_sql("select me.* from messages me, boards b, members m where + b.id = me.board_id and b.project_id = m.project_id and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") @course_messages ||= [] @project_messages ||= [] unless messages.first.nil? diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index 2cf070960..1ea977e89 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -193,6 +193,7 @@ <% end %> <% end %> + <% if @issues.first || @project_messages.first %>

<%= l(:label_project_overview_new)%>

@@ -260,11 +261,9 @@
<% end %> - - -
<% end %> + <% unless @user_journal_messages.first.nil? %>

<%= l(:label_activities) %>

@@ -293,7 +292,7 @@ <% end %>
- +
<% end %> From e40f1a570e9993b0d3000a03572950b75a414ea7 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 3 Jun 2015 18:11:52 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E6=88=90=E5=91=98=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 3 ++- app/models/invite_list.rb | 12 ++++++++++-- app/models/mailer.rb | 1 + app/models/project.rb | 2 +- app/views/projects/invite_members_by_mail.html.erb | 7 ++++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index fbafd16e9..3c34aa549 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -363,7 +363,8 @@ class ProjectsController < ApplicationController #发送邮件邀请新用户 def invite_members_by_mail - if User.current.member_of?(@project) || User.current.admin? + if User.current.member_of?(@project) || User.current.admin? + @inviter_lists = InviteList.where(project_id:@project.id).all @is_zhuce = false respond_to do |format| format.html diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb index f1ba8546f..4868fc3d7 100644 --- a/app/models/invite_list.rb +++ b/app/models/invite_list.rb @@ -1,5 +1,13 @@ class InviteList < ActiveRecord::Base attr_accessible :project_id, :user_id - # belongs_to :user - # belongs_to :project + belongs_to :user + belongs_to :project + + # 用户拒绝邀请后,删除记录 + def self.delete_inviter(userid, projectid) + @inviters = AppliedProject.where("user_id = ? and project_id = ?", userid, projectid) + @inviters.each do |inviter| + inviter.destroy + end + end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index c13334b08..001d1b1f6 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -58,6 +58,7 @@ class Mailer < ActionMailer::Base us = UsersService.new # 自动激活用户 user = us.register_auto(login, @email, @password) + InviteList.create(:user_id => user.id, :project_id => project.id) User.current = user unless User.current.nil? @user = user diff --git a/app/models/project.rb b/app/models/project.rb index bf94df248..249df8640 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -67,7 +67,7 @@ class Project < ActiveRecord::Base has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy has_many :applied_projects - # has_many :invite_lists + has_many :invite_lists # end #ADDED BY NIE diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index 7f952cb3c..7cad9bff3 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -80,4 +80,9 @@ <% end %> - \ No newline at end of file + + +
<% @inviter_lists.each do |inviter_list| %> + <%= inviter_list.user.name %> + <% end + %>
\ No newline at end of file From d6fb35544ecbe9abe4dc8faae8bc3bb1a1946814 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Jun 2015 09:01:49 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E8=AF=84=E5=88=86=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E6=97=B6=E6=8F=90=E4=BA=A4=E6=8C=89=E9=92=AE=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=9C=A8=E6=8F=90=E4=BA=A4=E6=A0=8F=E7=9A=84=E5=8F=B3=E4=B8=8B?= =?UTF-8?q?=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_add_score.html.erb | 2 +- app/views/student_work/_show.html.erb | 2 +- public/stylesheets/courses.css | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/student_work/_add_score.html.erb b/app/views/student_work/_add_score.html.erb index e091e507d..bdfcff6e1 100644 --- a/app/views/student_work/_add_score.html.erb +++ b/app/views/student_work/_add_score.html.erb @@ -16,7 +16,7 @@ <%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %> <%end%> - 提交 + 提交
<% end%> \ No newline at end of file diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 3758ffedd..a04b5036b 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -54,7 +54,7 @@ <% if @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2 && @work.user != User.current )%> -
+
<%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%>
<% end%> diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 85db8361d..0663dc905 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -671,6 +671,8 @@ input#score{ width:40px;} .ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;top:0;height:100%;background:#64bdd9;left:0;} .filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px;} +.evaluation{position: relative;} +.evaluation_submit{position: absolute;right: 0px;bottom: 5px;} From f168e43b0fb92e2d49f5cd6ad3950a586cffc02b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Jun 2015 09:57:30 +0800 Subject: [PATCH 07/24] =?UTF-8?q?1=E3=80=81=E8=BF=94=E8=BF=98=E6=89=B9?= =?UTF-8?q?=E9=98=85=E7=9A=84=E9=99=84=E4=BB=B6=E5=8F=AF=E4=BB=A5=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=B9=B6=E4=B8=94js=E5=88=B7=E6=96=B0=202=E3=80=81?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=8F=AF=E4=BB=A5=E5=9C=A8=E4=BD=9C=E5=93=81?= =?UTF-8?q?show=E7=95=8C=E9=9D=A2=E5=88=A0=E9=99=A4=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A=E7=9A=84=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 10 +++- app/controllers/homework_attach_controller.rb | 5 +- app/controllers/homework_common_controller.rb | 3 ++ app/views/attachments/destroy.js.erb | 52 ++++++++++--------- .../student_work/_work_attachments.html.erb | 11 ++-- 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index c8b6a6fda..46428d5e8 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -191,9 +191,15 @@ class AttachmentsController < ApplicationController if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && - @attachment.container.board && @attachment.container.board.course ) ) + @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon)) if @attachment.container.is_a?(News) format.html { redirect_to_referer_or news_path(@attachment.container) } + elsif @attachment.container.is_a?(StudentWorksScore) + @is_destroy = true #根据ID删除页面对应的数据,js刷新页面 + format.js + elsif @attachment.container.is_a?(HomeworkCommon) + @is_destroy = true #根据ID删除页面对应的数据,js刷新页面 + format.js elsif @attachment.container.is_a?(Message) format.html { redirect_to_referer_or new_board_message_path(@attachment.container) } elsif @course.nil? @@ -431,7 +437,7 @@ private @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWorks' + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index f6b044c63..5dd5363b9 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -334,9 +334,8 @@ class HomeworkAttachController < ApplicationController @homework.name = name @homework.description = description @homework.project_id = params[:project_id] || 0 - if params[:attachments] - @homework.save_attachments(params[:attachments]) - end + @homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@homework) if @homework.save respond_to do |format| format.html { redirect_to course_for_bid_url @homework.bid } diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 58c959512..281ff7cf8 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -101,6 +101,9 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.evaluation_num = params[:evaluation_num] @homework_detail_manual.absence_penalty = params[:absence_penalty] + @homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@homework) + if @homework.save && @homework_detail_manual.save respond_to do |format| format.html { diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index 0b6cee0df..d23422e24 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -1,26 +1,30 @@ -var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>'); -//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start -var containerid=$('.remove-upload',attachment_html_obj).data('containerid'); -if(containerid==undefined){ - $('#attachments_<%= j params[:attachment_id] %>').remove(); - var count=$('#attachments_fields>span').length; - if(count<=0){ - $("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>'); - $(".remove_all").remove(); +<% if @is_destroy%> + $("#attachment_<%= @attachment.id%>").remove(); +<%else%> + var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>'); + //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start + var containerid=$('.remove-upload',attachment_html_obj).data('containerid'); + if(containerid==undefined){ + $('#attachments_<%= j params[:attachment_id] %>').remove(); + var count=$('#attachments_fields>span').length; + if(count<=0){ + $("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>'); + $(".remove_all").remove(); + }else{ + $("#upload_file_count").html(""+count+""+"个文件"+"已上传"); + } }else{ - $("#upload_file_count").html(""+count+""+"个文件"+"已上传"); + $('#attachments_<%= j params[:attachment_id] %>').remove(); + var count=$('#attachments_fields'+containerid+'>span').length; + if(count<=0){ + $('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>'); + var remove_all_html_obj = $(".remove_all").filter(function(index){ + return $(this).data('containerid')==containerid; + }); + remove_all_html_obj.remove(); + }else{ + $('#upload_file_count'+containerid).html(""+count+""+"个文件"+"已上传"); + } } -}else{ - $('#attachments_<%= j params[:attachment_id] %>').remove(); - var count=$('#attachments_fields'+containerid+'>span').length; - if(count<=0){ - $('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>'); - var remove_all_html_obj = $(".remove_all").filter(function(index){ - return $(this).data('containerid')==containerid; - }); - remove_all_html_obj.remove(); - }else{ - $('#upload_file_count'+containerid).html(""+count+""+"个文件"+"已上传"); - } -} -//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end \ No newline at end of file + //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end +<% end%> \ No newline at end of file diff --git a/app/views/student_work/_work_attachments.html.erb b/app/views/student_work/_work_attachments.html.erb index 638644fdf..2f7e1e1cd 100644 --- a/app/views/student_work/_work_attachments.html.erb +++ b/app/views/student_work/_work_attachments.html.erb @@ -1,5 +1,8 @@ -<% for attachment in attachments %> - <%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%> - (<%= number_to_human_size attachment.filesize %>) -
+<% attachments.each_with_index do |attachment,i| %> +
+ <%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%> + <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') if attachment.id && User.current == attachment.author %> + (<%= number_to_human_size attachment.filesize %>) +
+
<% end -%> From b822db9995be41fbac011022220ec380c7152a09 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Jun 2015 10:00:08 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A2=9E=E5=8A=A0title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_work_attachments.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/_work_attachments.html.erb b/app/views/student_work/_work_attachments.html.erb index 2f7e1e1cd..373b84b74 100644 --- a/app/views/student_work/_work_attachments.html.erb +++ b/app/views/student_work/_work_attachments.html.erb @@ -1,7 +1,7 @@ <% attachments.each_with_index do |attachment,i| %>
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%> - <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') if attachment.id && User.current == attachment.author %> + <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload') if attachment.id && User.current == attachment.author %> (<%= number_to_human_size attachment.filesize %>)
From ae950cf3c0fa3ff3856ee0d3117242ea64cabd4b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Jun 2015 10:10:16 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=AF=84=E5=88=86?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=A1=86=E7=BC=BA=E5=B0=91=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/show_member_score.js.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/courses/show_member_score.js.erb b/app/views/courses/show_member_score.js.erb index 083f070c2..013b478fc 100644 --- a/app/views/courses/show_member_score.js.erb +++ b/app/views/courses/show_member_score.js.erb @@ -6,8 +6,8 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/show_me showModal('ajax-modal', '400px'); //$('#ajax-modal').css('height','569px'); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + -""); +$('#ajax-modal').before("" + +""); //$('#ajax-modal').parent().removeClass(); $('#ajax-modal').parent().css("top","30%").css("left","40%").css("position","fixed"); $('#ajax-modal').parent().addClass("new-watcher"); From b7dbaca15b12a18fbae840daf2b2b0da0f9b8d87 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 4 Jun 2015 10:29:00 +0800 Subject: [PATCH 10/24] =?UTF-8?q?=E5=9C=A8=E5=AD=A6=E7=94=9F=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E7=82=B9=E5=87=BB=E5=AD=A6=E7=94=9F=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E4=B9=8B=E5=90=8E=EF=BC=8Ca=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=9C=89=E4=B8=8B=E5=88=92=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_show_member_score.html.erb | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/app/views/courses/_show_member_score.html.erb b/app/views/courses/_show_member_score.html.erb index bb080b57b..0d250cf14 100644 --- a/app/views/courses/_show_member_score.html.erb +++ b/app/views/courses/_show_member_score.html.erb @@ -1,24 +1,5 @@