Merge branch 'guange_dev' into szzh

This commit is contained in:
sw 2015-04-23 17:46:00 +08:00
commit cbb5fb1ee0
17 changed files with 1650 additions and 1507 deletions

View File

@ -894,7 +894,6 @@ class ApplicationController < ActionController::Base
set_autologin_cookie(user)
end
call_hook(:controller_account_success_authentication_after, {:user => user })
end
end

View File

@ -20,7 +20,7 @@ class MyController < ApplicationController
# edit
before_filter :auth_login1, :only => [:account]
#
before_filter :require_login
before_filter :require_login, except: [:change_mail_notification]
helper :issues
helper :users
@ -75,6 +75,19 @@ class MyController < ApplicationController
end
end
def change_mail_notification
token = params[:token]
user = try_to_autologin1
if user
user.mail_notification = params[:mail_notification]
user.save
flash[:notice] = l(:notice_mail_notification_updated)
redirect_to my_account_url
else
redirect_to signin_url
end
end
# Edit user's account
def account
@user = User.current

View File

@ -57,5 +57,98 @@ class TestController < ApplicationController
attach.filename
end
def mailer()
raise unless Rails.env.development?
@user = User.find(params[:user_id])
send_for_user_activities(@user, Time.now,1)
render 'mailer/send_for_user_activities'
end
def send_for_user_activities(user, date_to, days)
date_from = date_to - days.days
end
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.new(:user =>user , :action => 'autologin')
token.save
@token = token
# 查询user参加的项目及课程
projects = user.projects
courses = user.courses
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}))
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
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
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 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?
messages.each do |msg|
if msg.project
@project_messages << msg
elsif msg.course
@course_messages << msg
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})
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") : []
# 查询user在课程及个人中留言
@course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where
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?
}
#有内容才发,没有不发
end
end

View File

@ -64,19 +64,16 @@ 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} : #{date_to} #{l(:label_day_mail)}"
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.new(:user =>user , :action => 'autologin')
token.save
@token = token
@token = Token.get_token_from_user(user, 'autologin')
@user_url = url_for(my_account_url(user,:token => @token.value))
# 查询user参加的项目及课程
projects = user.projects
courses = user.courses
@ -256,10 +253,9 @@ class Mailer < ActionMailer::Base
@author = issue.author
@issue = issue
user = User.find_by_mail(recipients)
token = Token.new(:user =>user , :action => 'autologin')
token.save
@token = token
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value)
@user = user
@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))
@ -299,10 +295,8 @@ class Mailer < ActionMailer::Base
@author = journal.user
user = User.find_by_mail(recipients)
token = Token.new(:user =>user , :action => 'autologin')
token.save
@token = token
@user = user
@token = Token.get_token_from_user(user, 'autologin')
# edit

View File

@ -27,6 +27,14 @@ class Token < ActiveRecord::Base
self.value = Token.generate_token_value
end
def self.get_token_from_user(user, action)
token = Token.where(:action => action, :user_id => user).first
unless token
token = Token.create(user: user, action: action)
end
token
end
# Return true if token has expired
def expired?
return Time.now > self.created_on + @@validity_time

View File

@ -1,6 +1,6 @@
<!--add by huang-->
<div class="clearfix"></div>
<div id="footer" style="margin-left:-5px;padding-top: 20px;clear: both;font-size: 12px;">
<div id="footer" style="padding-top: 20px;clear: both;font-size: 12px;">
<div style="border-top:solid 1px #C6E9F1;"></div>
<div class="base_footer">
<div align="center">

View File

@ -89,7 +89,7 @@
</script>
</head>
<body style=" height:1500px;">
<body>
<div id="update_info"></div>
</body>
</html>
</html>

View File

@ -1,9 +1,13 @@
<div class="mail_content" style="margin-top:30px; margin:0; padding:0; border:0;">
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>
</div>
<div class="mail_foot" style="margin:0; padding:0; border:0;"><%= link_to( l(:mail_issue_footer), @user_url , :style=>'font-size:12px; font-weight:normal; color:#1b55a7;') %> </div>
<div class="mail_foot" style="margin:0; padding:0; border:0;">
<% [: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 %>
<label style="margin-top:20px;color:gray; margin-left:10px;"><%= l(mail_option) %></label>
<% 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 %>
</div>

View File

@ -3,5 +3,14 @@
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>
<div class="mail_foot"><%= link_to( l(:mail_issue_footer), @user_url, :style=>'font-size:12px; font-weight:normal; color:#1b55a7;') %> </div>
<div class="mail_foot" style="margin:0; padding:0; border:0;">
<% [: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 %>
<label style="margin-top:20px;color:gray; margin-left:10px;"><%= l(mail_option) %></label>
<% 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 %>
</div>

View File

@ -3,6 +3,8 @@
<div class="content">
<h4 class="wmail_h4" style="color:#474646; font-size:14px; margin-bottom:5px;" >
<%= @subject %>
@ -365,9 +367,13 @@
</div><!--贴吧动态 end-->
<% end %>
<div class="wmail_foot" style="margin-top:20px;color:#2775d2; margin-left:10px;">
<%= link_to l(:mail_footer), @user_url, :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %>
<% [: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 %>
<label style="margin-top:20px;color:gray; margin-left:10px;"><%= l(mail_option) %></label>
<% 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 %>
</div>
</div>

View File

@ -215,3 +215,11 @@ production:
# specific configuration options for development environment
# that overrides the default ones
development:
delivery_method: :smtp
smtp_settings:
address: mail.trustie.net
port: 25
domain: mail.trustie.net
authentication: :login
user_name: "mail@trustie.net"
password: "loong2010"

View File

@ -68,6 +68,7 @@ zh:
label_user_extensions: 其他信息
notice_account_updated: 帐号更新成功
notice_mail_notification_updated: 邮件通知设置成功
#

View File

@ -80,7 +80,7 @@ zh:
field_enterprise_name: 组织
label_week_mail: 一周动态
label_day_mail: 今日动态
label_day_mail: 您好Trustie平台上与您相关的今日动态
#added by huang
field_tea_name: 教师
field_couurse_time: 学时
@ -744,9 +744,10 @@ zh:
label_theme: 主题
label_default: 默认
label_search_titles_only: 仅在标题中搜索
label_user_mail_option_all: "收取我的所有通知"
label_user_mail_option_all: "实时发送邮件"
label_user_mail_option_day: "按日发送邮件"
label_user_mail_option_none: "不发送邮件"
label_user_mail_option_week: "按周收取我的所有通知"
label_user_mail_option_day: "按天收取我的所有通知"
label_must_answer: "必答"
label_poll_title: 问卷调查_问卷页面
#huang
@ -782,7 +783,6 @@ zh:
label_project_cousre_studentun: "你还未加入任何课程,赶快加入吧!"
#end by huang
label_user_mail_option_selected: "收取选中项目的所有通知"
label_user_mail_option_none: "不收取任何通知"
label_user_mail_option_only_my_events: "只收取我跟踪或参与的项目的通知"
label_user_mail_option_only_assigned: "只收取分配给我的"
label_user_mail_option_only_owner: 只收取由我创建的

View File

@ -109,6 +109,7 @@ RedmineApp::Application.routes.draw do
namespace :test do
match 'courselist'
match 'zip'
match 'mailer'
end
##new added by linchun #以发布应用的形式参与竞赛
resources :softapplications do
@ -328,6 +329,7 @@ RedmineApp::Application.routes.draw do
match 'my/add_block', :via => :post
match 'my/remove_block', :via => :post
match 'my/order_blocks', :via => :post
match 'my/change_mail_notification', via: :get
get 'my/page2', :to => 'my#page2', :as => "my_page2"

File diff suppressed because it is too large Load Diff

View File

@ -995,18 +995,24 @@ pre,code,.line-code
font-family:'Source Code Pro'
}
/*by young*/
#main,#footer,#top-menu,#header
#main,#top-menu,#header
{
width:940px;
margin:25px auto
}
#footer {
margin:25px auto
}
#main
{
width:940px;
height:auto;
margin:0px auto;
}
#main #content_{
margin-bottom: 10px;:w
}
#header
{
width:925px;

View File

@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize