Merge branch 'dev_hjq' into szzh

This commit is contained in:
sw 2015-06-04 17:45:51 +08:00
commit 1cff2a85e9
9 changed files with 455 additions and 416 deletions

View File

@ -364,6 +364,7 @@ class ProjectsController < ApplicationController
#发送邮件邀请新用户
def invite_members_by_mail
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

View File

@ -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

View File

@ -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
@ -73,6 +74,10 @@ class Mailer < ActionMailer::Base
@project_name = "#{project.name}"
@user = user
@project = project
inviter_lists = InviteList.where(project_id:@project.id, user_id:@user.id).all
if inviter_lists.blank?
InviteList.create(:user_id => user.id, :project_id => project.id)
end
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject
@ -83,13 +88,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')
@ -100,19 +102,15 @@ class Mailer < ActionMailer::Base
project_ids = projects.map{|project| project.id}.join(",")
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}))
# 查询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"
@issues = Issue.find_by_sql(sql)
# @bids 查询课程作业包括老师发布的作业以及user提交作业
# @attachments查询课程课件更新
@attachments ||= []
@bids ||= [] # 老师发布的作业
unless courses.first.nil?
count = courses.count
count = count - 1
@ -127,7 +125,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?
@ -139,6 +139,7 @@ class Mailer < ActionMailer::Base
end
end
end
# 查询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})
@ -151,18 +152,13 @@ class Mailer < ActionMailer::Base
jour_type='Course' and user_id = #{user.id}
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@user_journal_messages = user.journals_for_messages.where("m_parent_id IS NULL and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
# 查询user新建贴吧或发布帖子
@forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
@memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
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?
}
@course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty?}
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发
mail :to => user.mail,:subject => subject if has_content

View File

@ -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

View File

@ -1,9 +1,6 @@
<p>
<span class="c_blue" style="color:#1b55a7;">
<%= link_to(h("#{@news.author.login}(#{@news.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %>
</span><%= l(:mail_issue_title_userin)%>
<span class="c_blue" style="color:#1b55a7;">
<% if @news.project %>
@ -11,7 +8,8 @@
<% elsif @news.course %>
<%=h @news.course.name %> : <%= link_to(h(@news.title), @news_url,:style=>'color:#1b55a7; font-weight:bold;') %>
<% end %>
</span><%= l(:mail_issue_title_active)%></p>
</span><%= l(:mail_issue_title_active)%>
</p>
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
<ul style="list-style-type:none; margin:0; padding:0;">
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_subject)%></strong></span>
@ -25,7 +23,7 @@
</li>
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
<span style="float: left; width: 526px">
<%= @news.description %>
<%= @news.description.html_safe %>
</span>
</li>

View File

@ -1,10 +1,3 @@
<div class="content">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= @subject %>
@ -15,12 +8,10 @@
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_course_overview)%></h2>
<% unless @course_news.first.nil? %>
<ul class="wmail_ul" style=" list-style-type:none;clear: both;margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= l(:label_course_news) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @course_news.count %>)</span>
</h4>
<% @course_news.each do |course_new|%>
<li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
@ -44,11 +35,12 @@
<% end %>
<div class="cl"></div>
</ul><!--课程动态 end-->
</ul><!--课程通知 end-->
<% end %>
<!--课程作业-->
<% if !@bids.first.nil? || !@homeworks.first.nil? %>
<ul class="wmail_ul" style="clear: both;margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;"><%= l(:label_homework_overview) %><span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @bids.count %>)</span></h4>
<% unless @bids.first.nil?%>
<% @bids.each do |bid| %>
@ -101,9 +93,9 @@
</ul><!--作业动态 end-->
<% end %>
<!-- 课程留言 -->
<% unless @course_journal_messages.first.nil? %>
<ul class="wmail_ul" style="clear: both;margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= l(:view_course_journals_for_messages) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @course_journal_messages.count %>)</span>
@ -130,45 +122,39 @@
<span class="wmail_date" style="color:#6e6e6e; float:right;display:block; margin-left:10px;"><%= format_time(course_journal_message.created_on) %></span>
</li>
<% end %>
<div class="cl"></div>
</ul><!--课程留言 end-->
<% end %>
<!-- 课程讨论区 -->
<% unless @course_messages.first.nil? %>
<ul class="wmail_ul" style="margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= l(:view_borad_course) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @course_journal_messages.count %>)</span>
</h4>
<% @course_messages.each do |course_message|%>
<li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">[</span>
<%= 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;" %>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">]</span>
<%= 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;"%>
<span class="wmail_txt" style="float:left; margin-right:5px;color:#6e6e6e;"><%= l(:label_send_course_messages) %></span>
<%= 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;"
%>
:style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
<span class="wmail_date" style="color:#6e6e6e; float:right;display:block; margin-left:10px;"><%= format_time(course_message.created_on) %></span>
</li>
<% end %>
<div class="cl"></div>
</ul><!--课程讨论 end-->
</ul><!-- 课程讨论区end -->
<% end %>
<!-- 课件 -->
<% unless @attachments.first.nil? %>
<ul class="wmail_ul" style="margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
@ -200,8 +186,12 @@
<div class="cl"></div>
</ul><!--课件下载 end-->
<% end %>
</div><!--课程动态 end-->
</div>
<% end %>
<!--项目相关-->
<% if @issues.first || @project_messages.first %>
<div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_project_overview_new)%></h2>
@ -211,21 +201,17 @@
<%= l(:label_issue_tracking) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @issues.count %>)</span>
</h4>
<% @issues.each do |issue|%>
<li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">[</span>
<%= 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;" %>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">]</span>
<%= 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;"%>
<span class="wmail_txt" style="float:left; margin-right:5px;color:#6e6e6e;"><%= l(:label_project_issue) %></span>
<%= 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;"
@ -238,6 +224,7 @@
</ul><!--问题跟踪 end-->
<% end %>
<!-- 讨论区 -->
<% unless @project_messages.first.nil? %>
<ul class="wmail_ul" style="margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
@ -271,10 +258,41 @@
</ul><!--项目论坛 end-->
<% end %>
<!--项目新闻-->
<% unless @project_news.first.nil? %>
<ul class="wmail_ul" style=" list-style-type:none;clear: both;margin-left:10px; border-bottom:1px dashed #cfcfcf; padding-bottom:15px; width:720px; margin-bottom:15px;">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= l(:label_course_news) %>
<span class="wmail_num" style="color:#fe3f0c; margin-left:5px; font-weight:normal;">(<%= @project_news.count %>)</span>
</h4>
<% @project_news.each do |project_new|%>
<li style="clear: both; list-style: none;">
<span class="wmail_dis" style="float:left; color:#000000; margin-right:5px;">▪</span>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">[</span>
<%= link_to truncate(project_new.project.name,length: 30,omission: '...'), project_url(project_new.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;" %>
<span class="wmail_b" style="color:#1b55a7; font-weight:bold; float:left;">]</span>
<%= link_to project_new.author, user_activities_url(project_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;"%>
<span class="wmail_txt" style="float:left; margin-right:5px;color:#6e6e6e;"><%= l(:label_project_notice) %></span>
</div><!--项目动态 end-->
<%= link_to truncate(project_new.title,length: 30,omission: '...'), news_url(project_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;"
%>
<span class="wmail_date" style="color:#6e6e6e; float:right;display:block; margin-left:10px;"><%= format_time(project_new.created_on) %></span>
</li>
<% end %>
<div class="cl"></div>
</ul><!-- 项目新闻end -->
<% end %>
</div>
<% end %><!-- 项目动态end -->
<!-- 用户留言 -->
<% unless @user_journal_messages.first.nil? %>
<div class="wmail_main" style="padding:20px 10px 0px;">
<h2 class="wmail_h2" style="color:#15bccf; "><%= l(:label_activities) %></h2>
@ -303,7 +321,7 @@
<% end %>
<div class="cl"></div>
</ul><!--课程动态 end-->
</ul><!--用户留言 end-->
</div><!--个人动态 end-->
<% end %>

View File

@ -76,8 +76,24 @@
<a href="#" class="btn_free" onclick="senderEmail($(this));">
<%= l(:label_send_email)%>
</a>
<% end %>
<%# 邀请用户的状态 %>
<% unless @inviter_lists.blank? %>
<div>
<span class="status_inviter">已邀请的用户</span><br/>
<% @inviter_lists.each do |inviter_list| %>
<%= inviter_list.user.name %><br/>
<% end %>
</br>
<span class="status_inviter">等待加入项目的用户</span><br/>
<% @inviter_lists.each do |inviter_list| %>
<% unless inviter_list.user.member_of?(@project) %>
<%= inviter_list.user.name %><br/>
<% end %>
<% end %>
</div>
<% end %>
</div>
</div>

View File

@ -86,6 +86,7 @@ zh:
label_roadmap: 里程碑 #版本路线图
project_module_dts: DTS测试工具
label_project_tool_response: 用户反馈
label_course_news: 项目新闻
label_project_overview: "项目简介"
label_expend_information: 展开更多信息

View File

@ -49,6 +49,7 @@ a.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repea
a:hover.icon_removem{background:url(../images/img_floatbox.png) -22px -61px no-repeat;}
a.btn_free{ background:#ff5722; display:block; text-align:center; color:#fff; padding:3px 0; width:80px; margin-bottom:10px;}
a:hover.btn_free{ background:#d63502;}
.status_inviter{color: #3CA5C6;font-weight: bold; font-size: 14px }
/*成员邀请*/
.invi_search{ }
.invi_search_input{ border:1px solid #15bccf; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;}