From c579ee51feb4dc233247dda4a65340ae46f409fe Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 6 Sep 2015 15:31:48 +0800 Subject: [PATCH 01/46] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/onclick_time.rb | 3 ++ .../20150906065702_create_onclick_times.rb | 10 +++++ db/schema.rb | 42 ++++++++++++------- spec/factories/onclick_times.rb | 7 ++++ spec/models/onclick_time_spec.rb | 5 +++ 5 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 app/models/onclick_time.rb create mode 100644 db/migrate/20150906065702_create_onclick_times.rb create mode 100644 spec/factories/onclick_times.rb create mode 100644 spec/models/onclick_time_spec.rb diff --git a/app/models/onclick_time.rb b/app/models/onclick_time.rb new file mode 100644 index 000000000..16b17ea9a --- /dev/null +++ b/app/models/onclick_time.rb @@ -0,0 +1,3 @@ +class OnclickTime < ActiveRecord::Base + attr_accessible :onclick_time, :user_id +end diff --git a/db/migrate/20150906065702_create_onclick_times.rb b/db/migrate/20150906065702_create_onclick_times.rb new file mode 100644 index 000000000..3922b775e --- /dev/null +++ b/db/migrate/20150906065702_create_onclick_times.rb @@ -0,0 +1,10 @@ +class CreateOnclickTimes < ActiveRecord::Migration + def change + create_table :onclick_times do |t| + t.integer :user_id + t.datetime :onclick_time + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5bf838c25..5867a62e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150906025009) do +ActiveRecord::Schema.define(:version => 20150906065702) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -497,23 +497,26 @@ ActiveRecord::Schema.define(:version => 20150906025009) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -936,6 +939,13 @@ ActiveRecord::Schema.define(:version => 20150906025009) do t.datetime "updated_at", :null => false end + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" diff --git a/spec/factories/onclick_times.rb b/spec/factories/onclick_times.rb new file mode 100644 index 000000000..fcdda983d --- /dev/null +++ b/spec/factories/onclick_times.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :onclick_time do + user_id 1 +onclick_time "2015-09-06 14:57:02" + end + +end diff --git a/spec/models/onclick_time_spec.rb b/spec/models/onclick_time_spec.rb new file mode 100644 index 000000000..bc453f545 --- /dev/null +++ b/spec/models/onclick_time_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OnclickTime, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From ed5f14c9ebb2c0a3b06c3cd1d772ddca29eff7a8 Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 6 Sep 2015 17:42:10 +0800 Subject: [PATCH 02/46] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 859f19f19..7744f20a4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -105,6 +105,16 @@ class UsersController < ApplicationController redirect_to signin_url return end + # 记录当前点击按钮的时间 + if OnclickTime.where("user_id =?", User.current).first.nil? + message_new_time = OnclickTime.new + message_new_time.user_id = User.current.id + message_new_time.onclick_time = Time.now + message_new_time.save + else + message_new_time = OnclickTime.where("user_id =?", User.current) + message_new_time.update_attributes(:onclick_time => Time.now) + end # 当前用户查看消息,则设置消息为已读 if params[:viewed] == "all" course_querys = @user.course_messages From ecd0056f0a8219e982b495a2978a4179b313e7eb Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 7 Sep 2015 11:13:15 +0800 Subject: [PATCH 03/46] =?UTF-8?q?1=E3=80=81=E5=AE=8C=E6=88=90=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=82=B9=E5=87=BB=E8=AE=B0=E5=90=8E=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=BA=A2=E7=82=B9=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=82=202=E3=80=81=E9=A6=96=E6=AC=A1=E7=99=BB?= =?UTF-8?q?=E9=99=86=E4=BB=A5=E2=80=9C=E6=9C=80=E5=90=8E=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E2=80=9D=E4=B8=BA=E5=87=86=EF=BC=8C=E5=90=8E?= =?UTF-8?q?=E9=9D=A2=E4=BB=A5=E7=82=B9=E5=87=BB=E6=97=B6=E9=97=B4=E4=B8=BA?= =?UTF-8?q?=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/onclick_time.rb | 2 ++ app/models/user.rb | 21 ++++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7744f20a4..4bbb9848a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -112,7 +112,7 @@ class UsersController < ApplicationController message_new_time.onclick_time = Time.now message_new_time.save else - message_new_time = OnclickTime.where("user_id =?", User.current) + message_new_time = OnclickTime.where("user_id =?", User.current).first message_new_time.update_attributes(:onclick_time => Time.now) end # 当前用户查看消息,则设置消息为已读 diff --git a/app/models/onclick_time.rb b/app/models/onclick_time.rb index 16b17ea9a..c62a9274c 100644 --- a/app/models/onclick_time.rb +++ b/app/models/onclick_time.rb @@ -1,3 +1,5 @@ class OnclickTime < ActiveRecord::Base attr_accessible :onclick_time, :user_id + + belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index b08b29981..e7f4a8c50 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,6 +132,7 @@ class User < Principal has_many :course_messages has_many :memo_messages has_many :user_feedback_messages + has_one :onclick_time # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" @@ -209,7 +210,7 @@ class User < Principal before_save :update_hashed_password before_destroy :remove_references_before_destroy # added by fq - after_create :act_as_activity + after_create :act_as_activity, :add_onclick_time # end scope :in_group, lambda {|group| @@ -257,10 +258,16 @@ class User < Principal # 新消息统计 def count_new_message - course_count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count - forge_count = ForgeMessage.where("user_id =? and viewed =?", User.current.id, 0).count - user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", User.current.id, 0).count - user_memo_count = MemoMessage.where("user_id =? and viewed =?", User.current.id, 0).count + if OnclickTime.where("user_id =?", User.current).first.nil? + message_new_time = OnclickTime.new + message_new_time.user_id = User.current.id + message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on + message_new_time.save + end + course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count + forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count + user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count messages_count = course_count + forge_count + user_feedback_count + user_memo_count end @@ -994,6 +1001,10 @@ class User < Principal self.acts << Activity.new(:user_id => self.id) end + def add_onclick_time + self.onclick_time << OnclickTime.new(:user_id => self.id, :onclick_time => self.created_on) + end + # Removes references that are not handled by associations # Things that are not deleted are reassociated with the anonymous user def remove_references_before_destroy From ef011ad473178f18ab122cb9fcb97cc14a66f839 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Sep 2015 15:23:34 +0800 Subject: [PATCH 04/46] =?UTF-8?q?=E9=A1=B9=E7=9B=AE--=E9=82=80=E8=AF=B7--?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6=E9=82=80=E8=AF=B7=E7=94=A8?= =?UTF-8?q?=E6=88=B7,=E5=AF=B9=E8=BE=93=E5=85=A5=E7=9A=84=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E5=90=8D=E8=BF=9B=E8=A1=8C=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/invite_members_by_mail.html.erb | 18 +++++++++++++----- public/stylesheets/public.css | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index 4c6ee47d8..8c951a485 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -24,16 +24,24 @@ if(email == "") { $("#valid_email").text("<%= l(:label_input_email_blank)%>"); + return false; } - else if (filter.test(email)) { - $("#valid_email").html(""); - return true; + else if(!filter.test(email)) + { + $("#valid_email").text("<%= l(:label_email_format_error)%>"); + return false; + } + else if(email.split('@')[0].length >= 20) + { + $("#valid_email").text("邮箱名过长,最长为20个字符"); + return false; } else { - $("#valid_email").text("<%= l(:label_email_format_error)%>"); + $("#valid_email").text(""); + return true; } - return false; + } function senderEmail(obj) diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 4cc859721..2288c4994 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -418,6 +418,8 @@ div.flash.notice { background-color: #dfffdf; border-color: #9fcf9f; color: #005f00; + word-wrap: break-word; + word-break: break-all } div.flash.warning, .conflict { From 103d61056d7d7ea0c8799a77581c52ce0b724e13 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 7 Sep 2015 16:08:04 +0800 Subject: [PATCH 05/46] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=9A=201=E3=80=81=E6=B7=BB=E5=8A=A0=E2=80=9C=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF=E2=80=9D=E5=88=86=E7=B1=BB=202?= =?UTF-8?q?=E3=80=81=E6=96=B0=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=82=B9=E5=87=BB=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 12 +++++++++++- app/helpers/users_helper.rb | 9 +++++++++ app/models/user.rb | 5 ++++- app/views/users/user_messages.html.erb | 6 +++--- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4bbb9848a..f05fa891a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -106,6 +106,7 @@ class UsersController < ApplicationController return end # 记录当前点击按钮的时间 + # 考虑到用户未退出刷新消息页面 if OnclickTime.where("user_id =?", User.current).first.nil? message_new_time = OnclickTime.new message_new_time.user_id = User.current.id @@ -132,10 +133,19 @@ class UsersController < ApplicationController case params[:type] when nil @message_alls = [] - messages = MessageAll.where("user_id =?",@user).order("created_at desc") + messages = MessageAll.where("user_id =?" ,@user).order("created_at desc") messages.each do |message_all| @message_alls << message_all.message end + when 'unviewed' + @message_alls = [] + messages = MessageAll.where("user_id =?", @user).order("created_at desc") + messages.each do |message_all| + # 在点击或者刷新消息列表后未读的消息存放在数组 + if message_all.message.viewed == 0 + @message_alls << message_all.message + end + end when 'homework' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") when 'course_message' diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 269630ec3..c806f3493 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -52,6 +52,15 @@ module UsersHelper end end + # 统计未读消息数 + def unviewed_message(user) + course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count + forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count + user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + end + def user_mail_notification_options(user) user.valid_notification_options.collect {|o| [l(o.last), o.first]} end diff --git a/app/models/user.rb b/app/models/user.rb index e7f4a8c50..2ccc41783 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1001,8 +1001,11 @@ class User < Principal self.acts << Activity.new(:user_id => self.id) end + # 注册用户的时候消息默认点击时间为用户创建时间 def add_onclick_time - self.onclick_time << OnclickTime.new(:user_id => self.id, :onclick_time => self.created_on) + if OnclickTime.where("user_id =?" , self.id).first.nil? + OnclickTime.create(:user_id => self.id, :onclick_time => self.created_on) + end end # Removes references that are not handled by associations diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c3c1a447b..6a6597af9 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -4,6 +4,7 @@
    • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
    • +
    • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
    • <%# 课程相关消息 %>
    • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
    • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
    • @@ -22,16 +23,15 @@
    • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
    • <%# 系统贴吧 %>
    • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
    • -
  • -<% if params[:type].nil? %> +<% if params[:type].nil? || params[:type] == "unviewed" %> <% end %> <% if @message_alls.count >0 %> From 0a45e0848816d8d8b8aec37949429c56ebd4eb8f Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 7 Sep 2015 16:14:34 +0800 Subject: [PATCH 06/46] =?UTF-8?q?1=E3=80=81=E6=B6=88=E6=81=AF=E4=B8=BA0?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D=E6=98=BE=E7=A4=BA=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=95=B0=E5=92=8C=E2=80=9C=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=B7=B2=E8=AF=BB=E2=80=9D=E3=80=82=202?= =?UTF-8?q?=E3=80=81=E6=B6=88=E6=81=AF=E4=B8=8D=E4=B8=BA=E7=A9=BA=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E6=B6=88=E6=81=AF=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=B8=8D=E6=98=BE=E7=A4=BA=E2=80=9C=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E8=AE=BE=E4=B8=BA=E5=B7=B2=E8=AF=BB=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 6a6597af9..cd64fb227 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -29,12 +29,15 @@
    -<% if params[:type].nil? || params[:type] == "unviewed" %> - -<% end %> <% if @message_alls.count >0 %> + <% if params[:type].nil? || params[:type] == "unviewed" %> +
    + 有 <%= unviewed_message(@user) %> 条未读 + <% unless unviewed_message(@user) == 0 %> + <%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %> + <% end %> +
    + <% end %> <%# 课程消息 %> <% unless @message_alls.nil? %> <% @message_alls.each do |ma| %> From fb6688265c9748d1dfc6fb7ce0b5292d99388748 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Sep 2015 17:16:25 +0800 Subject: [PATCH 07/46] =?UTF-8?q?wiki=E5=88=A0=E9=99=A4=E5=90=8E=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wiki_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index f74fbb04d..da6d48b8d 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -264,7 +264,7 @@ class WikiController < ApplicationController end @page.destroy respond_to do |format| - format.html { redirect_to project_wiki_index_url(@project) } + format.html {redirect_to edit_project_wiki_page_url @project, @page.title} format.api { render_api_ok } end end From 8d72a9a5390fafcc0b6f593765f3750d26cddcee Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 09:22:15 +0800 Subject: [PATCH 08/46] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=A1=B9=E7=9B=AEbase?= =?UTF-8?q?=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_projects.html.erb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 425b720d9..ddafdab52 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -49,16 +49,6 @@ <%= link_to l(:field_homepage), home_path %> > <%=l(:label_project_hosting_platform) %> ><%= link_to @project.name, project_path(@project.id) %>

    - - - - - - - - - -
    From 4c73e00eafde6ee333cf7e42e72e75ec943564a6 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 09:43:41 +0800 Subject: [PATCH 09/46] =?UTF-8?q?=E4=BD=9C=E5=93=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9f8d25c7e..9bc7b52ed 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -67,13 +67,14 @@ class StudentWorkController < ApplicationController end def index - # 消息状态更新 + # 作业消息状态更新 @homework.course_messages.each do |homework_message| if User.current.id == homework_message.user_id homework_message.update_attributes(:viewed => true) end end - + # 作品消息状态更新 + # 消息end #设置作业对应的forge_messages表的viewed字段 query_student_work = @homework.course_messages From ae2aa2feddcfe8f1d1f0ea89c2a047d15198b936 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 14:14:49 +0800 Subject: [PATCH 10/46] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=89=80=E6=9C=89=E9=80=BB=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9bc7b52ed..3ed5eb914 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -69,12 +69,21 @@ class StudentWorkController < ApplicationController def index # 作业消息状态更新 @homework.course_messages.each do |homework_message| - if User.current.id == homework_message.user_id - homework_message.update_attributes(:viewed => true) + if User.current.id == homework_message.user_id && homework_message.viewed == 0 + homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0 end end - # 作品消息状态更新 - + # 作品打分消息状态更新 + studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0) + studentworks_scores.each do |studentworks_score| + studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0 + end + # 作品评论消息状态更新 + journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0) + journals_for_teacher.each do |journal_for_teacher| + journal_for_teacher.update_attributes(:viewed => true) + end + # 作品留言 # 消息end #设置作业对应的forge_messages表的viewed字段 query_student_work = @homework.course_messages From d01a52904030dab8d9ddeb207b606fb27367308e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 8 Sep 2015 15:27:58 +0800 Subject: [PATCH 11/46] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_project_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/news/_project_form.html.erb b/app/views/news/_project_form.html.erb index dfe1fb937..269420bfe 100644 --- a/app/views/news/_project_form.html.erb +++ b/app/views/news/_project_form.html.erb @@ -1,7 +1,7 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
  • - +

  • From 966bd8f94cb8b18e91a99b2d6bc8c0d1c153dd14 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 8 Sep 2015 16:31:19 +0800 Subject: [PATCH 12/46] =?UTF-8?q?admin=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=A1=86=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3e01d68ff..ed274a61e 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1833,7 +1833,7 @@ input#time_entry_comments { width: 90%;} .tabular.settings p{ padding-left: 300px; } .tabular.settings label{ margin-left: -300px; width: 295px; } -.tabular.settings textarea { width: 99%; } +.tabular.settings textarea { width: 96%; } .settings.enabled_scm table {width:100%} .settings.enabled_scm td.scm_name{ font-weight: bold; } From 0746408a9df9a92af52a0c8285e3987cf0db07f9 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 16:55:36 +0800 Subject: [PATCH 13/46] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E9=86=92=E5=8A=9F=E8=83=BD=EF=BC=88=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=94=B6=E5=88=B0=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 ++ app/models/applied_project.rb | 18 +++++++++++++++--- app/views/users/user_messages.html.erb | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f05fa891a..c738ab89a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -146,6 +146,8 @@ class UsersController < ApplicationController @message_alls << message_all.message end end + when 'invite_info' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc") when 'homework' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") when 'course_message' diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index accbc90e2..fb8bf90af 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -1,8 +1,21 @@ class AppliedProject < ActiveRecord::Base attr_accessible :project_id, :user_id - belongs_to :user - belongs_to :project + belongs_to :user + belongs_to :project + has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy + + after_create :send_appliled_message + + def send_appliled_message + # if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.project.members.each do |m| + if m.roles.first.to_s.include?("Manager") + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) + end + end + # end + end #删除用户申请 def self.deleteappiled(userid, projectid) @@ -11,5 +24,4 @@ class AppliedProject < ActiveRecord::Base applied.destroy end end - end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index cd64fb227..778805db6 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -134,6 +134,21 @@ <% end %> <% if ma.class == ForgeMessage %> + <% if ma.forge_message_type == "AppliedProject" %> + + <% end %> <% if ma.forge_message_type == "Issue" %>
    • From 51d964d37149bf1de5d447ca239a4dcae279d30c Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 8 Sep 2015 17:26:10 +0800 Subject: [PATCH 14/46] =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=AE=9A=E4=BD=8D=E5=88=B0=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=9F=90=E4=B8=80=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/settings.html.erb | 12 +++++++----- app/views/users/user_messages.html.erb | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb index e70e20cef..3fc9a89d6 100644 --- a/app/views/projects/settings.html.erb +++ b/app/views/projects/settings.html.erb @@ -2,13 +2,15 @@ $(function(){ <%if @select_tab%> <%if @select_tab == "modules"%> - project_setting(2); + project_setting(2); + <% elsif @select_tab == "members"%> + project_setting(3); <% elsif @select_tab == "versions"%> - project_setting(4); - $("#pro_st_edit_ban").toggle(); + project_setting(4); + $("#pro_st_edit_ban").toggle(); <% elsif @select_tab == "repositories" %> - project_setting(6); - $("#pro_st_edit_ku").toggle(); + project_setting(6); + $("#pro_st_edit_ku").toggle(); <%else%> <% end%> <% end%> diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 778805db6..e3f8c04d0 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -144,7 +144,7 @@ ">申请加入项目:
    • - <%= link_to ma.project, project_path(ma.project_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ma.project}" %> + <%= link_to ma.project, settings_project_path(:id => ma.project, :tab => "members"), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ma.project}" %>
    • <%= time_tag(ma.created_at).html_safe %>
    From a7f2f0a6d2a22af97a48034f533c9b684951f4d6 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 8 Sep 2015 17:31:16 +0800 Subject: [PATCH 15/46] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BAflash.now[:error]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 77933666f..0f44be36c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -342,7 +342,7 @@ class ProjectsController < ApplicationController if params[:repository] == "pswd_is_null" html << l(:label_password_not_null) end - flash[:error] = html if !html.to_s.blank? + flash.now[:error] = html if !html.to_s.blank? end scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first @repository = Repository.factory(scm) From 1a6f81f3020e585279a8164c760c5b6491f26091 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 9 Sep 2015 10:15:05 +0800 Subject: [PATCH 16/46] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=EF=BC=8C=E5=8C=BA=E5=88=86=E5=B7=B2=E8=AF=BB=E5=92=8C=E6=9C=AA?= =?UTF-8?q?=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 ++++++ app/controllers/users_controller.rb | 2 +- app/views/users/user_messages.html.erb | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 77933666f..04041bdf6 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -322,6 +322,12 @@ class ProjectsController < ApplicationController end def settings + # 修改查看消息状态 + applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0) + applied_messages.each do |applied_message| + applied_message.update_attributes(:viewed => true) + end + # end @issue_custom_fields = IssueCustomField.sorted.all @issue_category ||= IssueCategory.new @member ||= @project.members.new diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c738ab89a..5680a333e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -146,7 +146,7 @@ class UsersController < ApplicationController @message_alls << message_all.message end end - when 'invite_info' + when 'apply' @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc") when 'homework' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index e3f8c04d0..a37ce30ff 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -5,6 +5,7 @@
    • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
    • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
    • <%# 课程相关消息 %>
    • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
    • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
    • From 20bef515dae1cea366f8f5a3a0ac8f5a718cd042 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 9 Sep 2015 11:42:06 +0800 Subject: [PATCH 17/46] =?UTF-8?q?issue=E5=91=A8=E6=8A=A5=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=BB=99=E6=89=80=E6=9C=89=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 6 ++++-- app/models/issue.rb | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 6a0b351ba..47e425710 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -114,8 +114,10 @@ class IssuesController < ApplicationController def show # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = @issue.forge_messages - if User.current.id == @issue.assigned_to_id - query.update_all(:viewed => true) + query.each do |m| + if m.user_id == User.current.id + m.update_attribute(:viewed, true) + end end # 缺陷状态更新 query_journals = @issue.journals diff --git a/app/models/issue.rb b/app/models/issue.rb index fa8cee988..f7f596e17 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -147,6 +147,13 @@ class Issue < ActiveRecord::Base unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) end + if self.tracker_id == 5 + self.project.members.each do |m| + if m.roles.first.to_s.include?("Manager") && m.user_id != self.author_id && m.user_id != self.assigned_to_id + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) + end + end + end end # 更新缺陷 @@ -1009,7 +1016,7 @@ class Issue < ActiveRecord::Base if leaf.start_date # Only move subtask if it starts at the same date as the parent # or if it starts before the given date - if start_date == leaf.start_date || date > leaf.start_date + if start_date == leaf.start_date || date > leaf.start_date leaf.reschedule_on!(date) end else From 66251c8d30b70f2cff928a19ed2420271f531053 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 9 Sep 2015 17:05:32 +0800 Subject: [PATCH 18/46] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=9A=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C=E9=9D=A2=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/system_messages.js.coffee | 3 + .../stylesheets/system_messages.css.scss | 3 + app/controllers/admin_controller.rb | 5 ++ app/controllers/system_messages_controller.rb | 83 +++++++++++++++++++ app/helpers/system_messages_helper.rb | 2 + app/models/system_message.rb | 4 + app/models/user.rb | 1 + app/views/admin/messages.html.erb | 14 ++++ app/views/system_messages/index.html.erb | 3 + config/locales/admins/en.yml | 2 + config/locales/admins/zh.yml | 2 + config/locales/zh.yml | 2 + config/routes.rb | 11 +++ .../20150909062619_create_system_messages.rb | 11 +++ db/schema.rb | 9 +- lib/redmine.rb | 1 + .../system_messages_controller_spec.rb | 5 ++ spec/factories/system_messages.rb | 8 ++ spec/models/system_message_spec.rb | 5 ++ 19 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/system_messages.js.coffee create mode 100644 app/assets/stylesheets/system_messages.css.scss create mode 100644 app/controllers/system_messages_controller.rb create mode 100644 app/helpers/system_messages_helper.rb create mode 100644 app/models/system_message.rb create mode 100644 app/views/admin/messages.html.erb create mode 100644 app/views/system_messages/index.html.erb create mode 100644 db/migrate/20150909062619_create_system_messages.rb create mode 100644 spec/controllers/system_messages_controller_spec.rb create mode 100644 spec/factories/system_messages.rb create mode 100644 spec/models/system_message_spec.rb diff --git a/app/assets/javascripts/system_messages.js.coffee b/app/assets/javascripts/system_messages.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/system_messages.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/system_messages.css.scss b/app/assets/stylesheets/system_messages.css.scss new file mode 100644 index 000000000..a9947d45a --- /dev/null +++ b/app/assets/stylesheets/system_messages.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the SystemMessages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1624008f2..5666934b6 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -79,6 +79,11 @@ class AdminController < ApplicationController end end + # 系统消息 + def messages + @admin_messages = SystemMessage.new + end + def plugins @plugins = Redmine::Plugin.all end diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb new file mode 100644 index 000000000..21b9ae9b8 --- /dev/null +++ b/app/controllers/system_messages_controller.rb @@ -0,0 +1,83 @@ +class SystemMessagesController < ApplicationController + # before_filter :message_author, :only => [:show] + # + # def message_author + # if(!User.current.logged? && !token.nil?) + # + # User.current =try_to_autologin1 + # end + # if @system_messages + # render_403 :message => :notice_not_authorized_message + # else + # deny_access + # end + # end + + def index + @system_messages = SystemMessage.all + end + + # def show + # @system_messages = SystemMessage.find(params[:id]) + # end + + # GET /products/new + # def new + # @product = Product.new + # end + + # GET /products/1/edit + # def edit + # end + + # POST /products + # POST /products.json + def create + @system_messages = SystemMessage.new + @system_messages.content = params[:system_message][:content] + @system_messages.user_id = User.current.id + respond_to do |format| + if @system_messages.save + format.html {redirect_to system_messages_url(@project)} + flash[:notice] = l(:notice_successful_message) + end + end + end + + # PATCH/PUT /products/1 + # PATCH/PUT /products/1.json + # def update + # respond_to do |format| + # if @product.update(product_params) + # format.html { redirect_to @product, notice: 'Product was successfully updated.' } + # format.json { render :show, status: :ok, location: @product } + # else + # format.html { render :edit } + # format.json { render json: @product.errors, status: :unprocessable_entity } + # end + # end + # end + + # DELETE /products/1 + # DELETE /products/1.json + # def destroy + # @system_messages.destroy + # respond_to do |format| + # format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' } + # format.json { head :no_content } + # end + # end + + # private + # # Use callbacks to share common setup or constraints between actions. + # def set_product + # @product = Product.find(params[:id]) + # end + # + # # Never trust parameters from the scary internet, only allow the white list through. + # def message_params + # params.require(:admin_system_messages).permit(:content) + # end + + +end diff --git a/app/helpers/system_messages_helper.rb b/app/helpers/system_messages_helper.rb new file mode 100644 index 000000000..fef238676 --- /dev/null +++ b/app/helpers/system_messages_helper.rb @@ -0,0 +1,2 @@ +module SystemMessagesHelper +end diff --git a/app/models/system_message.rb b/app/models/system_message.rb new file mode 100644 index 000000000..4802ba252 --- /dev/null +++ b/app/models/system_message.rb @@ -0,0 +1,4 @@ +class SystemMessage < ActiveRecord::Base + attr_accessible :content, :id, :user_id + belongs_to :user +end diff --git a/app/models/user.rb b/app/models/user.rb index 2ccc41783..8b5951687 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -133,6 +133,7 @@ class User < Principal has_many :memo_messages has_many :user_feedback_messages has_one :onclick_time + has_many :system_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb new file mode 100644 index 000000000..9d312c7e7 --- /dev/null +++ b/app/views/admin/messages.html.erb @@ -0,0 +1,14 @@ +

      + <%=l(:label_system_message)%> +


      +
      + <%= form_for(@admin_messages) do |f| %> +
      + <%= f.text_area :content %> +
      +
      + <%= f.submit l(:label_submit),:class => "small" %> +
      + <% end %> +
      + diff --git a/app/views/system_messages/index.html.erb b/app/views/system_messages/index.html.erb new file mode 100644 index 000000000..4ed40757b --- /dev/null +++ b/app/views/system_messages/index.html.erb @@ -0,0 +1,3 @@ +<% @system_messages.each do |sm| %> +
      • <%= sm.content %>
      +<% end %> diff --git a/config/locales/admins/en.yml b/config/locales/admins/en.yml index 479d2f0f0..ed23107cb 100644 --- a/config/locales/admins/en.yml +++ b/config/locales/admins/en.yml @@ -11,3 +11,5 @@ en: label_registration_activation_by_email: account activation by email label_registration_manual_activation: manual account activation label_registration_automatic_activation: automatic account activation + + label_system_message: system messages diff --git a/config/locales/admins/zh.yml b/config/locales/admins/zh.yml index 936b3109f..49abcfc8d 100644 --- a/config/locales/admins/zh.yml +++ b/config/locales/admins/zh.yml @@ -14,3 +14,5 @@ zh: label_registration_manual_activation: 手动激活帐号 label_registration_automatic_activation: 自动激活帐号 + label_system_message: 系统消息 + diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4a6ddce4e..d2fa502b9 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -36,6 +36,7 @@ zh: notice_create_failed: 创建失败,请先完善个人信息 notice_failed_create: 创建失败 notice_successful_update: 更新成功 + notice_successful_message: 消息创建成功! notice_successful_edit: 修改成功 notice_failed_edit: 修改失败 notice_successful_delete: 删除成功 @@ -49,6 +50,7 @@ zh: notice_not_contest_setting_authorized: 对不起,您无权配置此竞赛。 notice_not_contest_delete_authorized: 对不起,您无权删除此竞赛。 notice_not_authorized_archived_project: 要访问的项目已经归档。 + notice_not_authorized_message: 您访问的消息不存在! notice_email_sent: "邮件已发送至 %{value}" notice_email_error: "发送邮件时发生错误 (%{value})" notice_feeds_access_key_reseted: 您的RSS存取键已被重置。 diff --git a/config/routes.rb b/config/routes.rb index 8454a1c47..2a0e1a492 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -260,6 +260,16 @@ RedmineApp::Application.routes.draw do match '/users/search', :via => [:get, :post] #end + # 消息相关路由 + resources :system_messages do + collection do + post 'create', :as => 'system_messages' + get 'index', :as => 'index' + get 'show', :as => 'show' + end + end + # match 'system_messages/index', to: 'system_messages#index', :via => :get, :as => 'system_messages' + match 'account/heartbeat', to: 'account#heartbeat', :via => :get match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post] match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post] @@ -702,6 +712,7 @@ RedmineApp::Application.routes.draw do match 'admin/projects', :via => :get get 'admin/courses' match 'admin/users', :via => :get + match 'admin/messages', :via => :get match 'admin/first_page_made', as: :first_page_made match 'admin/course_page_made', as: :course_page_made match 'admin/contest_page_made', as: :contest_page_made diff --git a/db/migrate/20150909062619_create_system_messages.rb b/db/migrate/20150909062619_create_system_messages.rb new file mode 100644 index 000000000..a51715ead --- /dev/null +++ b/db/migrate/20150909062619_create_system_messages.rb @@ -0,0 +1,11 @@ +class CreateSystemMessages < ActiveRecord::Migration + def change + create_table :system_messages do |t| + t.integer :id + t.integer :user_id + t.string :content + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e44bdd1d9..71d521453 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150906083453) do +ActiveRecord::Schema.define(:version => 20150909062619) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1357,6 +1357,13 @@ ActiveRecord::Schema.define(:version => 20150906083453) do add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + create_table "system_messages", :force => true do |t| + t.integer "user_id" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" diff --git a/lib/redmine.rb b/lib/redmine.rb index 99b7ea22f..8ebdacfa6 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -369,6 +369,7 @@ Redmine::MenuManager.map :admin_menu do |menu| menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural + menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version diff --git a/spec/controllers/system_messages_controller_spec.rb b/spec/controllers/system_messages_controller_spec.rb new file mode 100644 index 000000000..c65f5b5e0 --- /dev/null +++ b/spec/controllers/system_messages_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SystemMessagesController, :type => :controller do + +end diff --git a/spec/factories/system_messages.rb b/spec/factories/system_messages.rb new file mode 100644 index 000000000..7bcc27422 --- /dev/null +++ b/spec/factories/system_messages.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :system_message do + id 1 +user_id 1 +content "MyString" + end + +end diff --git a/spec/models/system_message_spec.rb b/spec/models/system_message_spec.rb new file mode 100644 index 000000000..fd8df4e92 --- /dev/null +++ b/spec/models/system_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SystemMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 1feb7022c7465b3abb3ad765d6f6bd997efde7f4 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 9 Sep 2015 17:42:38 +0800 Subject: [PATCH 19/46] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=BAkindeditor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/messages.html.erb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 9d312c7e7..10f20e2a0 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -1,13 +1,18 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>

      <%=l(:label_system_message)%>


      <%= form_for(@admin_messages) do |f| %>
      - <%= f.text_area :content %> + <%= f.kindeditor :content, :edit_id => 'system_message', + :width => '87%', + :resizeType => '0', + :no_label => true + %>
      - <%= f.submit l(:label_submit),:class => "small" %> + <%= f.submit l(:label_submit),:class => "small", :onclick => "system_message.sync;" %>
      <% end %>
      From 0aa8c5b5ccbbb0d7338b1bd761e07f1222aba5fb Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 9 Sep 2015 17:43:33 +0800 Subject: [PATCH 20/46] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 4 ++++ app/controllers/users_controller.rb | 2 ++ app/views/users/user_messages.html.erb | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 21b9ae9b8..588e13c5e 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -33,6 +33,10 @@ class SystemMessagesController < ApplicationController # POST /products # POST /products.json def create + unless User.current.admin? + render_403 + return + end @system_messages = SystemMessage.new @system_messages.content = params[:system_message][:content] @system_messages.user_id = User.current.id diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5680a333e..23106c954 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -114,8 +114,10 @@ class UsersController < ApplicationController message_new_time.save else message_new_time = OnclickTime.where("user_id =?", User.current).first + message_last_time = message_new_time.onclick_time message_new_time.update_attributes(:onclick_time => Time.now) end + @user_system_messages = SystemMessage.where("created_at >?", message_last_time) # 当前用户查看消息,则设置消息为已读 if params[:viewed] == "all" course_querys = @user.course_messages diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a37ce30ff..e36fd4f32 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -39,6 +39,18 @@ <% end %>
  • <% end %> + <%# 系统消息 %> + <% @user_system_messages.each do |usm| %> +
      +
    • ddddddddddddddd
    • +
    • Trustiep平台发布新消息:
    • +
    • + <%= link_to usm.content, {:controller => 'system_messages', :action => 'index'}, + :class =>"newsGrey", + :title => "#{usm.content.html_safe}" %>
    • +
    • <%= time_tag(usm.created_at).html_safe %>
    • +
    + <% end %> <%# 课程消息 %> <% unless @message_alls.nil? %> <% @message_alls.each do |ma| %> From 6b0432c04c581dbe96b7e4142dc3f83093e0d14e Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 10 Sep 2015 09:06:00 +0800 Subject: [PATCH 21/46] =?UTF-8?q?=E6=B7=BB=E5=8A=A0job=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/email.rake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index 5126d7a69..f805d1382 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -202,5 +202,13 @@ END_DESC Mailer.run.send_for_user_activities(user, Date.today, 1) end end + + desc "send a message for Job deadline" + task :message => :environment do + users = User.where(mail_notification: 'day') + users.each do |user| + Mailer.run.send_for_user_activities(user, Date.today, 1) + end + end end end From a29ab60481a788aaa1fb6ae9413bf760fed07980 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 10 Sep 2015 11:34:10 +0800 Subject: [PATCH 22/46] =?UTF-8?q?=E8=80=81=E5=B8=88=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=BB=93=E6=9E=9C=E8=83=BD=E6=98=BE=E7=A4=BA=E5=87=BA?= =?UTF-8?q?=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- app/controllers/users_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 593d6bf53..018a293e3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -631,7 +631,7 @@ class StudentWorkController < ApplicationController unless @homework.save logger.debug @homework.errors.full_messages else - student_work = @homework.student_works.where(user_id: User.current.id).first + student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first end end student_work diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b2d49f2d..d71b24fc8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -354,7 +354,7 @@ class UsersController < ApplicationController @user = User.current @homework = HomeworkCommon.find(params[:homework_id]) @is_test = params[:is_test] == 'true' - @student_work = @homework.student_works.where(user_id: User.current.id).first + @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first if @student_work.nil? @student_work = StudentWork.new end @@ -369,7 +369,7 @@ class UsersController < ApplicationController def user_commit_homework homework = HomeworkCommon.find(params[:homework]) - student_work = homework.student_works.where(user_id: User.current.id).first + student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first if student_work student_work.save flash[:notice] = l(:notice_successful_create) From 596c512d0afc6800226c9343e2b326d73d1ac91c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 10 Sep 2015 11:39:53 +0800 Subject: [PATCH 23/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 ++ app/views/users/user_messages.html.erb | 29 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 23106c954..220781ed9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -148,6 +148,8 @@ class UsersController < ApplicationController @message_alls << message_all.message end end + when 'system_message' + @message_alls = SystemMessage.order("created_at desc").all when 'apply' @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc") when 'homework' diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index e36fd4f32..b5473edee 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -6,6 +6,8 @@
  • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
  • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
  • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
  • + <%# 系统消息 %> +
  • <%= link_to "系统消息", user_message_path(User.current, :type => 'system_message'), :class => "resourcesGrey" %>
  • <%# 课程相关消息 %>
  • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
  • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
  • @@ -42,8 +44,14 @@ <%# 系统消息 %> <% @user_system_messages.each do |usm| %> <% end %> <% end %> + <% if ma.class == SystemMessage %> + + <% end %> <% end %>
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> From fb155c84583d943a810a32e35656aa427973b8f2 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 10 Sep 2015 11:42:53 +0800 Subject: [PATCH 24/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index b5473edee..36392c7ac 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -311,6 +311,7 @@
    <% end %> <% end %> + <%# 系统消息 %> <% if ma.class == SystemMessage %>
    • From 06fea1bf1dabbf7110932ac7e381d0ef978cf501 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 10 Sep 2015 15:47:51 +0800 Subject: [PATCH 25/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 36392c7ac..c59930742 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -53,7 +53,7 @@
    • Trustie平台发布新消息:
    • - <%= link_to usm.content, {:controller => 'system_messages', :action => 'index'}, + <%= link_to usm.content.html_safe, {:controller => 'system_messages', :action => 'index'}, :class =>"newsGrey", :title => "#{usm.content.html_safe}" %>
    • <%= time_tag(usm.created_at).html_safe %>
    • @@ -323,7 +323,7 @@
    • Trustie平台发布新消息:
    • - <%= link_to ma.content, {:controller => 'system_messages', :action => 'index'}, + <%= link_to ma.content.html_safe, {:controller => 'system_messages', :action => 'index'}, :class =>"newsGrey", :title => "#{ma.content.html_safe}" %>
    • <%= time_tag(ma.created_at).html_safe %>
    • From 92a3d78dcc73d9863cd69b4773613bc3308cc3ee Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 10 Sep 2015 17:37:25 +0800 Subject: [PATCH 26/46] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E5=AE=9A=E6=97=B6=E5=8F=91=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 ++ app/tasks/homework_endtime_task.rb | 23 +++++++++++++++++++++++ lib/tasks/email.rake | 8 -------- lib/tasks/homework_endtime.rake | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 app/tasks/homework_endtime_task.rb create mode 100644 lib/tasks/homework_endtime.rake diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a25aff6bb..4fe2478d2 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -34,8 +34,10 @@ class Mailer < ActionMailer::Base end def method_missing(name, *args, &block) if Setting.delayjob_enabled? && Object.const_defined?('Delayed') + # with delayed_job @target.delay.send(name, *args, &block) else + # without delayed_job @target.send(name, *args, &block).deliver end end diff --git a/app/tasks/homework_endtime_task.rb b/app/tasks/homework_endtime_task.rb new file mode 100644 index 000000000..9b3d6e2ef --- /dev/null +++ b/app/tasks/homework_endtime_task.rb @@ -0,0 +1,23 @@ +#coding=utf-8 +# + +class HomeworkEndtimeTask + def massage_for_endtime + desc "send a message for Job deadline" + task :message => :environment do + current_day = Date.today.day + homework_commons = HomeworkCommon.where("end_time >?",Date.today) + homework_commons.each do |homework_common| + if homework_common.end_time.day - Date.today < 2 && homework_common.end_time.year == Date.year + homework_common.course.student.each do |s| + homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :course_message_id => homework_common.id, :course_message_type => "HomeworkEndtime") + end + end + end + end + handle_asynchronously :massage_for_endtime, :run_at => HomeworkEndtimeTask.new { 1.minutes.from_now } + end + + homwork_endtime = HomeworkEndtimeTask.new + homwork_endtime.massage_for_endtime +end diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index f805d1382..5126d7a69 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -202,13 +202,5 @@ END_DESC Mailer.run.send_for_user_activities(user, Date.today, 1) end end - - desc "send a message for Job deadline" - task :message => :environment do - users = User.where(mail_notification: 'day') - users.each do |user| - Mailer.run.send_for_user_activities(user, Date.today, 1) - end - end end end diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake new file mode 100644 index 000000000..9c7f54d75 --- /dev/null +++ b/lib/tasks/homework_endtime.rake @@ -0,0 +1,16 @@ +#coding=utf-8 + +namespace :homework_endtime do + desc "send a message for Job deadline" + task :message => :environment do + current_day = Date.today.day + homework_commons = HomeworkCommon.where("end_time >?",Date.today) + homework_commons.each do |homework_common| + if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year + homework_common.course.student.each do |s| + homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true) + end + end + end + end +end From cc3990de444239bde1d363043b2d624fed4fdfb3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Sep 2015 09:45:28 +0800 Subject: [PATCH 27/46] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B6=88=E6=81=AF=E5=90=8E=E8=B7=B3=E8=BD=AC=E8=B7=AF?= =?UTF-8?q?=E5=8A=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 2 +- app/tasks/homework_endtime_task.rb | 23 ------------------- config/routes.rb | 1 - 3 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 app/tasks/homework_endtime_task.rb diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 588e13c5e..ae49b58a8 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -42,7 +42,7 @@ class SystemMessagesController < ApplicationController @system_messages.user_id = User.current.id respond_to do |format| if @system_messages.save - format.html {redirect_to system_messages_url(@project)} + format.html {redirect_to user_message_path(User.current, :type => "system_message")} flash[:notice] = l(:notice_successful_message) end end diff --git a/app/tasks/homework_endtime_task.rb b/app/tasks/homework_endtime_task.rb deleted file mode 100644 index 9b3d6e2ef..000000000 --- a/app/tasks/homework_endtime_task.rb +++ /dev/null @@ -1,23 +0,0 @@ -#coding=utf-8 -# - -class HomeworkEndtimeTask - def massage_for_endtime - desc "send a message for Job deadline" - task :message => :environment do - current_day = Date.today.day - homework_commons = HomeworkCommon.where("end_time >?",Date.today) - homework_commons.each do |homework_common| - if homework_common.end_time.day - Date.today < 2 && homework_common.end_time.year == Date.year - homework_common.course.student.each do |s| - homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :course_message_id => homework_common.id, :course_message_type => "HomeworkEndtime") - end - end - end - end - handle_asynchronously :massage_for_endtime, :run_at => HomeworkEndtimeTask.new { 1.minutes.from_now } - end - - homwork_endtime = HomeworkEndtimeTask.new - homwork_endtime.massage_for_endtime -end diff --git a/config/routes.rb b/config/routes.rb index 2a0e1a492..1df7b0d2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -265,7 +265,6 @@ RedmineApp::Application.routes.draw do collection do post 'create', :as => 'system_messages' get 'index', :as => 'index' - get 'show', :as => 'show' end end # match 'system_messages/index', to: 'system_messages#index', :via => :get, :as => 'system_messages' From 9e61ceefa9c6e7669006fac71f1971432113efb9 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 11 Sep 2015 09:48:16 +0800 Subject: [PATCH 28/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/system_message.rb | 1 + app/views/admin/messages.html.erb | 25 ++++++++++++++++++++++++- app/views/users/user_messages.html.erb | 16 ++++++++++++++-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app/models/system_message.rb b/app/models/system_message.rb index 4802ba252..83e1ef615 100644 --- a/app/models/system_message.rb +++ b/app/models/system_message.rb @@ -1,4 +1,5 @@ class SystemMessage < ActiveRecord::Base attr_accessible :content, :id, :user_id belongs_to :user + validates_length_of :content, maximum: 255 end diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 10f20e2a0..03fa80e75 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -3,7 +3,7 @@ <%=l(:label_system_message)%>
      - <%= form_for(@admin_messages) do |f| %> + <%= form_for(@admin_messages, :html => {:id =>'system_message', :multipart => true}) do |f| %>
      <%= f.kindeditor :content, :edit_id => 'system_message', :width => '87%', @@ -11,9 +11,32 @@ :no_label => true %>
      +
      +

      +
      <%= f.submit l(:label_submit),:class => "small", :onclick => "system_message.sync;" %>
      <% end %>
      + diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c59930742..fdfa1eaf7 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -55,7 +55,13 @@
    • <%= link_to usm.content.html_safe, {:controller => 'system_messages', :action => 'index'}, :class =>"newsGrey", - :title => "#{usm.content.html_safe}" %>
    • + :onmouseover =>"message_titile_show($(this),event);", + :onmouseout => "message_titile_hide($(this));" + %> + +
    • <%= time_tag(usm.created_at).html_safe %>
    <% end %> @@ -325,7 +331,13 @@
  • <%= link_to ma.content.html_safe, {:controller => 'system_messages', :action => 'index'}, :class =>"newsGrey", - :title => "#{ma.content.html_safe}" %>
  • + :onmouseover =>"message_titile_show($(this),event);", + :onmouseout => "message_titile_hide($(this));" + %> + +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> From 4ea20b707cee1b81eb070ab31c8063127449a75e Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Sep 2015 09:53:18 +0800 Subject: [PATCH 29/46] =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E7=B1=BB=E5=9E=8B=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/users_helper.rb | 25 +++++++++++++++++++++++++ app/views/users/user_messages.html.erb | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index c806f3493..1ae6fbfb6 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -52,6 +52,31 @@ module UsersHelper end end + def title_for_message type + case type + when nil + '消息' + when 'unviewed' + '未读消息' + when 'apply' + '用户申请' + when 'system_message' + '系统消息' + when 'homework' + '作业消息' + when 'course_message' + '课程讨论' + when 'course_news' + '课程通知' + when 'issue' + '项目任务' + when 'forum' + '贴吧帖子' + when 'user_feedback' + '用户留言' + end + end + # 统计未读消息数 def unviewed_message(user) course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c59930742..5df911db6 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -1,5 +1,5 @@
    -
    消息
    +
    <%= title_for_message(params[:type]) %>
      • From 36e9c20e59c2faf4e34307053123bada3225e9ba Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 11 Sep 2015 10:30:01 +0800 Subject: [PATCH 30/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/messages.html.erb | 23 +++++++++++++++++------ app/views/users/user_messages.html.erb | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 03fa80e75..9f7784c67 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -1,9 +1,10 @@ +# encoding: utf-8 <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>

        <%=l(:label_system_message)%>


        - <%= form_for(@admin_messages, :html => {:id =>'system_message', :multipart => true}) do |f| %> + <%= form_for(@admin_messages, :html => {:id =>'system_message_form', :multipart => true}) do |f| %>
        <%= f.kindeditor :content, :edit_id => 'system_message', :width => '87%', @@ -20,23 +21,33 @@ <% end %>
        diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index fdfa1eaf7..03e9f487d 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -60,7 +60,7 @@ %>
      • <%= time_tag(usm.created_at).html_safe %>
      From bb3fc9752832027c2355cca961e2c7cba4ffeec3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Sep 2015 11:02:40 +0800 Subject: [PATCH 31/46] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=88=AA=E6=AD=A2?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=EF=BC=9A?= =?UTF-8?q?=201=E3=80=81=E6=97=B6=E9=97=B4=E5=8C=BA=E6=AE=B5=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BA24=E5=B0=8F=E6=97=B6=202=E3=80=81=E5=8F=AA?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=B8=80=E6=AC=A1=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/homework_endtime.rake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake index 9c7f54d75..9fef281a3 100644 --- a/lib/tasks/homework_endtime.rake +++ b/lib/tasks/homework_endtime.rake @@ -4,11 +4,13 @@ namespace :homework_endtime do desc "send a message for Job deadline" task :message => :environment do current_day = Date.today.day - homework_commons = HomeworkCommon.where("end_time >?",Date.today) + homework_commons = HomeworkCommon.where("end_time >=?",Date.today) homework_commons.each do |homework_common| - if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year - homework_common.course.student.each do |s| - homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true) + if CourseMessage.where("course_message_type =? and course_message_id =? and status =?", "HomeworkCommon", homework_common.id, 1).first.nil? + if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year + homework_common.course.student.each do |s| + homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true) + end end end end From 487f46bb3277c4e89fdec3acf63463995d610134 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 11:46:12 +0800 Subject: [PATCH 32/46] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=90=8E=E5=A4=A7=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/my/save_user_avatar.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/my/save_user_avatar.js.erb b/app/views/my/save_user_avatar.js.erb index 03608a768..1e24a4a7c 100644 --- a/app/views/my/save_user_avatar.js.erb +++ b/app/views/my/save_user_avatar.js.erb @@ -1,3 +1,3 @@ -$("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:90px;height:90px;overflow:hidden",:alt=>"头像") %>'); +$("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:78px;height:78px;overflow:hidden",:alt=>"头像") %>'); $("#nh_user_logo").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_logo',:width =>"40",:height => "40",:alt=>"头像") %>'); hideModal(); \ No newline at end of file From c0437ae99236af1b140b4c93e6a4d1805d9c5137 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Sep 2015 14:41:23 +0800 Subject: [PATCH 33/46] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=88=AA=E6=AD=A2?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=8F=90=E9=86=92=E7=95=8C=E9=9D=A2=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 3 ++- app/views/users/user_messages.html.erb | 21 +++++++++++++++++++-- public/stylesheets/new_user.css | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8b5951687..63811cd58 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -269,7 +269,8 @@ class User < Principal forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count end # 查询指派给我的缺陷记录 diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index ec2e4b748..b70eabd5c 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -6,8 +6,6 @@
    • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
    • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
    • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
    • - <%# 系统消息 %> -
    • <%= link_to "系统消息", user_message_path(User.current, :type => 'system_message'), :class => "resourcesGrey" %>
    • <%# 课程相关消息 %>
    • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
    • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
    • @@ -26,6 +24,8 @@
    • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
    • <%# 系统贴吧 %>
    • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
    • + <%# 系统消息 %> +
    • <%= link_to "系统消息", user_message_path(User.current, :type => 'system_message'), :class => "resourcesGrey" %>
    @@ -104,6 +104,23 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • <%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的作业:
    • + <% if ma.viewed == 0 %> +
    • + <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.course_message.name}" %> +
    • +
    •    截止时间快到了!
    • + <% else %> +
    • + <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.course_message.name}" %> +
    • + <% end %> +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> <% if ma.course_message_type == "Poll" %>
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index f8000f674..a233b6577 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -514,6 +514,9 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .homepageNewsType {width:110px; padding-left: 5px; font-size:12px; color:#888888; display:block;} .homepageNewsPubType {width:220px; font-size:12px; color:#888888; display: block;} .homepageNewsContent {width:365px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; } +.homepageHomeworkContentWarn {width:110px; max-width:365px; margin-right:10px; font-size:12px; color:red; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; } +.homepageHomeworkContent {width:245px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; } + .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} From 3044b07df7dd4629f547231a3425790aa8b7cbbd Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 11 Sep 2015 14:43:04 +0800 Subject: [PATCH 34/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 52 ++++++++++++++------------ public/stylesheets/new_user.css | 2 + 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 03e9f487d..e506b4a81 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -42,29 +42,33 @@
    <% end %> <%# 系统消息 %> - <% @user_system_messages.each do |usm| %> -
      -
    • - - - -
    • -
    • Trustie平台发布新消息:
    • -
    • - <%= link_to usm.content.html_safe, {:controller => 'system_messages', :action => 'index'}, - :class =>"newsGrey", - :onmouseover =>"message_titile_show($(this),event);", - :onmouseout => "message_titile_hide($(this));" - %> -
    • - -
    • <%= time_tag(usm.created_at).html_safe %>
    • -
    - <% end %> + <% if params[:type] != 'system_message' %> + <% @user_system_messages.each do |usm| %> + + <% end %> + <% end %> <%# 课程消息 %> <% unless @message_alls.nil? %> <% @message_alls.each do |ma| %> @@ -330,7 +334,7 @@
  • Trustie平台发布新消息:
  • <%= link_to ma.content.html_safe, {:controller => 'system_messages', :action => 'index'}, - :class =>"newsGrey", + :class => "#{params[:type]=="unviewed" ? "newsBlack" : "newsRed"}", :onmouseover =>"message_titile_show($(this),event);", :onmouseout => "message_titile_hide($(this));" %> diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index f8000f674..37af8ccea 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -519,6 +519,8 @@ a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} a.newsGrey {color:#4b4b4b;} a.newsGrey:hover {color:#000000;} +a.newsRed {color:red;} +a.newsRed:hovor {color:#888888;} a.replyGrey {color:#888888; display:inline-block;} a.replyGrey:hover {color:#4b4b4b;} a.replyGrey1 {color:#888888;} From 17b4b31449b2fc1bb28de0ef42b6072bfac319ad Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 11 Sep 2015 14:44:50 +0800 Subject: [PATCH 35/46] =?UTF-8?q?=E9=9A=90=E8=97=8F=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=9A=84=E5=9B=9E=E5=A4=8D=20textarea?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_message.html.erb | 2 +- app/views/users/_course_news.html.erb | 2 +- app/views/users/_project_issue.html.erb | 2 +- app/views/users/_project_message.html.erb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index eee272fe6..1587cbfb1 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -72,7 +72,7 @@ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> - +

    取消 diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index d2213c743..857ae3697 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -44,7 +44,7 @@
    <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - +

    取消 diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 04f541d77..e0e093f2d 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -82,7 +82,7 @@
    <%= form_for('new_form',:url => add_journal_issue_path(activity.id),:method => "post", :remote => true) do |f|%> - +

    取消 diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index 5fc10e48c..2c0dfeec0 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -58,7 +58,7 @@ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> - +

    取消 From 3bfdff81baa688511f7dab5c4d18ce8b50b472ac Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Sep 2015 14:53:42 +0800 Subject: [PATCH 36/46] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/_form.html.erb | 8 -------- app/views/projects/settings/_new_edit.html.erb | 5 ----- 2 files changed, 13 deletions(-) diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index 1e3f4b620..4df254fd0 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -12,14 +12,6 @@

    <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:0px;" %>

    -

    - <%#= f.text_field :enterprise_name, :size => 60, :style => "width:490px;" %> - - <%= select_tag :organization_id,options_for_select(project_organizations_id_option,@project.organization_id),{} %> -

    <%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH, value:"#{User.current.id.to_s + '_' +Time.now.to_s.gsub(' ','_').gsub(':','').gsub('+','')}" %> diff --git a/app/views/projects/settings/_new_edit.html.erb b/app/views/projects/settings/_new_edit.html.erb index a8998ece5..8de9b8229 100644 --- a/app/views/projects/settings/_new_edit.html.erb +++ b/app/views/projects/settings/_new_edit.html.erb @@ -19,11 +19,6 @@

  • -
  • - - <%= select_tag :organization_id,options_for_select(project_organizations_id_option,@project.organization_id),{} %> -
  • -
  • > From e9f9dd44b9f602e7d582277f56fdfa68bf809284 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 11 Sep 2015 14:59:30 +0800 Subject: [PATCH 37/46] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD=E6=90=9E=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 14 +++ app/models/homework_common.rb | 2 +- app/views/users/_user_homework_form.html.erb | 61 ++++++++---- public/javascripts/homework.js | 99 ++++++++++--------- 4 files changed, 106 insertions(+), 70 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index d4c02860e..71782ee28 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -154,7 +154,21 @@ class HomeworkCommonController < ApplicationController #编程作业相关属性 if @homework.homework_type == 2 + @homework.homework_detail_programing ||= HomeworkDetailPrograming.new + @homework_detail_programing = @homework.homework_detail_programing + @homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 + @homework_detail_programing.language = params[:language_type].to_i + @homework.homework_tests.delete_all + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + @homework.homework_tests << HomeworkTest.new( + input: val, + output: params[:program][:output][i] + ) + end + end end if @homework.save diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 0bff38558..c1e5666ac 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -60,6 +60,6 @@ class HomeworkCommon < ActiveRecord::Base self.homework_type == 2 && self.homework_detail_programing end - delegate :language_name, :to => :homework_detail_programing + delegate :language_name, :language, :to => :homework_detail_programing end diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index b4118bd2a..d221e50c8 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -1,6 +1,11 @@ <% content_for :header_tags do %> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> <%= javascript_include_tag 'homework','baiduTemplate' %> + <% end %>
    @@ -57,7 +62,7 @@
    - +
  • @@ -83,28 +88,42 @@ - diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 773a2c209..e07b6b979 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -58,10 +58,10 @@ $(function(){ ); }; - $('#test-program-btn').live('click', test_program); + $('#test-program-btn').on('click', test_program); - $('#commit-program-work-btn').live('click', function(){ + $('#commit-program-work-btn').on('click', function(){ if(!valid_form()){ return; } @@ -89,11 +89,10 @@ $(function(){ $(".HomeWorkCon form").submit(); }); - $('form.edit_student_work').live('keydown', '#program-src', function(){ + $('form.edit_student_work').on('keydown', '#program-src', function(){ tested = false; }); - //发布作业 $('#program-src').focus(function(){ @@ -104,70 +103,74 @@ $(function(){ $('input.date-input').datepicker(datepickerOptions); - $('a.pic_date').live('click', function(){ + $('a.pic_date').on('click', function(){ $(this).parent().prev().first().focus(); }) - $('a.ProBtn').live('click', function(){ - $("#BluePopupBox").dialog({ + $("#BluePopupBox").dialog({ modal: true, + autoOpen: false, dialogClass: 'BluePopupBox', minWidth: 753 - }); - $(".ui-dialog-titlebar").hide(); + }); - $("a.CloseBtn").live('click', function(){ + $('a.ProBtn').on('click', function(){ + $("#BluePopupBox").dialog("open"); + $(".ui-dialog-titlebar").hide(); + $("a.CloseBtn").on('click', function(){ $("#BluePopupBox" ).dialog("close"); }); $('#textarea_input_test').focus(); + }); - $("#BluePopupBox a.BlueCirBtn").live('click', function(){ - var test_numbers = 0; - var valid = true; - var input = null; - var output = null; - var input_groups = []; - $.each($('#BluePopupBox textarea.InputBox'), function(i, val){ - if ($(val).val().length<=0) { - $(val)[0].focus(); - valid =false; - return false; - } - if (test_numbers %2==0) { - input = $(val).val(); - } else { - output = $(val).val(); - input_groups.push({input: input, output: output}); - } - test_numbers += 1; - }); - - var language = $('select.language_type').val() == 1 ? 'C语言' : 'C++语言'; - - if (valid) { - $("input[name=homework_type]").val(2); - $('span.program_detail_info').text('('+language+','+test_numbers/2+'组测试)'); - //保存js值 - var data = { - language_type: $('select.language_type').val(), - input_groups: input_groups - }; - //构建到form中 - $('.program-input').remove(); - var html=bt('t:program-input-list',data); - $("input[name=homework_type]").after(html); - $("#BluePopupBox" ).dialog( "close" ); + $("#BluePopupBox a.BlueCirBtn").on('click', function(){ + var test_numbers = 0; + var valid = true; + var input = null; + var output = null; + var input_groups = []; + $.each($('#BluePopupBox textarea.InputBox'), function(i, val){ + if ($(val).val().length<=0) { + $(val)[0].focus(); + valid =false; + return false; } + if (test_numbers %2==0) { + input = $(val).val(); + } else { + output = $(val).val(); + input_groups.push({input: input, output: output}); + } + test_numbers += 1; }); + + var language = $('select.language_type').val() == 1 ? 'C语言' : 'C++语言'; + + if (valid) { + $("input[name=homework_type]").val(2); + $('span.program_detail_info').text('('+language+','+test_numbers/2+'组测试)'); + //保存js值 + var data = { + language_type: $('select.language_type').val(), + input_groups: input_groups + }; + //构建到form中 + $('.program-input').remove(); + var html=bt('t:program-input-list',data); + $("input[name=homework_type]").after(html); + if($( "#BluePopupBox" ).dialog( "isOpen" )){ + $("#BluePopupBox").dialog( "close" ); + } + } }); - $("#BluePopupBox").live('click', 'a.icon_add', function(){ + $("#BluePopupBox").on('click', 'a.icon_add', function(){ var html = bt('t:test-answer-list', null); $(this).parent('.mt10').after(html); }); - $("#BluePopupBox").live('click', 'a.icon_remove', function(){ + $("#BluePopupBox").on('click', 'a.icon_remove', function(){ $(this).parent('.mt10').remove(); }); }); \ No newline at end of file From 96405d7c0c4a735c1145c392a2df791c3029275f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 11 Sep 2015 15:38:58 +0800 Subject: [PATCH 38/46] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E7=BC=96=E7=A8=8B=E6=8C=89=E9=92=AE=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/homework.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index e07b6b979..9a5d6aa37 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -115,7 +115,7 @@ $(function(){ minWidth: 753 }); - $('a.ProBtn').on('click', function(){ + $('a.ProBtn').live('click', function(){ $("#BluePopupBox").dialog("open"); $(".ui-dialog-titlebar").hide(); $("a.CloseBtn").on('click', function(){ From 8c0f9d24f8e5f630852997ecfc35da0f3e884168 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Sep 2015 15:39:46 +0800 Subject: [PATCH 39/46] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=B2=A1=E4=BF=9D=E5=AD=98=E6=88=90=E5=8A=9F=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=20=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 7 ++++ app/models/system_message.rb | 2 + app/views/admin/messages.html.erb | 40 ++----------------- app/views/users/user_messages.html.erb | 6 +-- config/locales/admins/zh.yml | 2 + public/stylesheets/new_user.css | 2 + 6 files changed, 19 insertions(+), 40 deletions(-) diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index ae49b58a8..7b1fa33f8 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -44,6 +44,13 @@ class SystemMessagesController < ApplicationController if @system_messages.save format.html {redirect_to user_message_path(User.current, :type => "system_message")} flash[:notice] = l(:notice_successful_message) + else + if params[:system_message][:content].empty? + flash[:error] = l(:label_content_blank_fail) + else + flash[:error] = l(:label_admin_message_fail) + end + format.html {redirect_to admin_messages_path} end end end diff --git a/app/models/system_message.rb b/app/models/system_message.rb index 83e1ef615..92a989cb3 100644 --- a/app/models/system_message.rb +++ b/app/models/system_message.rb @@ -1,5 +1,7 @@ class SystemMessage < ActiveRecord::Base attr_accessible :content, :id, :user_id belongs_to :user + + validates :content, presence: true validates_length_of :content, maximum: 255 end diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 9f7784c67..918b09174 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -4,50 +4,16 @@ <%=l(:label_system_message)%>
    - <%= form_for(@admin_messages, :html => {:id =>'system_message_form', :multipart => true}) do |f| %> + <%= form_for(@admin_messages) do |f| %>
    - <%= f.kindeditor :content, :edit_id => 'system_message', - :width => '87%', - :resizeType => '0', - :no_label => true - %> + <%= f.kindeditor :content, :edit_id => 'system_message', :width => '87%', :resizeType => '0', :no_label => true %>

    - <%= f.submit l(:label_submit),:class => "small", :onclick => "system_message.sync;" %> + <%= f.submit l(:label_submit),:class => "small" %>
    <% end %>
    - diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index cb75132f0..e01cd3d09 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -57,12 +57,12 @@
  • <%= link_to usm.content.html_safe, {:controller => 'system_messages', :action => 'index'}, - :class => "newsGrey", + :class => "newsRed", :onmouseover => "message_titile_show($(this),event);", :onmouseout => "message_titile_hide($(this));" %>
  • -