From bdd2a60d00c481a4e7e74a61bb2de9136080e419 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 28 Dec 2016 11:30:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=EF=BC=9A=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E3=80=81=E5=8F=91=E5=B8=83=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E3=80=81=E5=8F=91=E5=B8=83=E9=80=9A=E7=9F=A5=E7=AD=89=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contest_members_controller.rb | 2 +- app/controllers/contests_controller.rb | 17 +- app/helpers/users_helper.rb | 16 ++ app/models/applied_contest.rb | 6 +- app/models/comment.rb | 11 ++ app/models/news.rb | 14 +- app/models/work.rb | 6 +- app/services/contests_service.rb | 11 +- .../_join_contest_applied_message.html.erb | 21 +-- .../users/_user_message_contest.html.erb | 158 +++++++++++++++++- app/views/users/_user_message_course.html.erb | 2 +- ...227085308_alter_applied_contest_message.rb | 9 + db/schema.rb | 117 +++++++------ lib/tasks/contest_work_endtime.rake | 20 +++ lib/tasks/contest_work_publichtime.rake | 4 +- public/stylesheets/css/structure.css | 2 +- 16 files changed, 321 insertions(+), 95 deletions(-) create mode 100644 db/migrate/20161227085308_alter_applied_contest_message.rb create mode 100644 lib/tasks/contest_work_endtime.rake diff --git a/app/controllers/contest_members_controller.rb b/app/controllers/contest_members_controller.rb index 99c63bfe2..c9760682b 100644 --- a/app/controllers/contest_members_controller.rb +++ b/app/controllers/contest_members_controller.rb @@ -38,7 +38,7 @@ class ContestMembersController < ApplicationController #status = 0 表示给学生发,status = 1表示给老师发 course_join = ContestMessage.new(:user_id =>user_id, :contest_message_id=>User.current.id,:contest_id => @contest.id,:contest_message_type=>"JoinContest", :content => role_ids, :viewed => false, :status => 0) course_join.save - ContestMessage.create(:user_id => User.current.id, :contest_message_id => user_id, :contest_message_id => @contest.id, :contest_message_type => "JoinContest",:content => role_ids, :viewed => false, :status => 1) + #ContestMessage.create(:user_id => User.current.id, :contest_message_id => user_id, :contest_message_id => @contest.id, :contest_message_type => "JoinContest",:content => role_ids, :viewed => false, :status => 1) end end @contest.contest_members << members diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index d3c1f9a4e..b17ca6f7f 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -3,6 +3,7 @@ class ContestsController < ApplicationController include ContestsHelper helper :contest_members + helper :users before_filter :find_contest, :only => [:show, :settings, :update, :contest_activities, :search_member, :private_or_public, :switch_role] before_filter :is_logged, :only => [:index, :new, :create] @@ -169,8 +170,12 @@ class ContestsController < ApplicationController end case params[:agree] when 'Y' - member = ContestMember.new(:user_id => apply_user.id) - Contest.find(applied_contest.contest_id).contest_members << member + if ContestMember.where(:user_id => apply_user.id).first.nil? + member = ContestMember.new(:user_id => apply_user.id) + Contest.find(applied_contest.contest_id).contest_members << member + else + member = ContestMember.where(:user_id => apply_user.id).first + end contest_member_roles = member.contest_member_roles if integer_ids.include?(14) && integer_ids.include?(13) @@ -181,8 +186,8 @@ class ContestsController < ApplicationController end ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>1) - applied_contest.applied_messages.update_all(:status => 1, :viewed => 1) - @msg.update_attributes(:status => 1, :viewed => 1) + applied_contest.applied_messages.update_all(:status => 1, :viewed => 1, :applied_user_id => User.current.id) + @msg.update_attributes(:status => 1, :viewed => 1, :applied_user_id => User.current.id) applied_contest.update_attributes(:status => 1) if integer_ids.include?(15) ContestantForContest.create(:student_id => apply_user.id, :contest_id =>applied_contest.contest_id) @@ -190,8 +195,8 @@ class ContestsController < ApplicationController when 'N' ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>2) - applied_contest.applied_messages.update_all(:status => 2, :viewed => 1) - @msg.update_attributes(:status => 2, :viewed => 1) + applied_contest.applied_messages.update_all(:status => 2, :viewed => 1, :applied_user_id => User.current.id) + @msg.update_attributes(:status => 2, :viewed => 1, :applied_user_id => User.current.id) applied_contest.update_attributes(:status => 2) end respond_to do |format| diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 651f3a811..8b2d7c73c 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -869,4 +869,20 @@ module UsersHelper end return user_ids end + + # 获取竞赛申请者的角色 + def get_role_str role + str = "" + case role + when 1 + str = "管理员" + when 2 + str = "评委" + when 3 + str = "参赛者" + when 4 + str = "管理员、评委" + end + str + end end diff --git a/app/models/applied_contest.rb b/app/models/applied_contest.rb index 1e26211c9..7c5e9ba7e 100644 --- a/app/models/applied_contest.rb +++ b/app/models/applied_contest.rb @@ -8,7 +8,7 @@ class AppliedContest < ActiveRecord::Base has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :dependent => :destroy after_create :send_appliled_message - # 仅仅给项目管理人员发送消息 + # 仅仅给竞赛管理人员发送消息 def send_appliled_message case self.role when '13' @@ -17,11 +17,9 @@ class AppliedContest < ActiveRecord::Base role = 2 when '15' role = 3 - else - role = 4 end contest_managers(self.contest).each do |member| - self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :applied_user_id => self.user_id, :role => role) + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :role => role) end # end end diff --git a/app/models/comment.rb b/app/models/comment.rb index f0add239f..e0563104e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -26,6 +26,7 @@ class Comment < ActiveRecord::Base # 课程/项目 消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy + has_many :contest_messages, :class_name => 'ContestMessage', :as => :contest_message, :dependent => :destroy #end has_many :praise_tread, as: :praise_tread_object, dependent: :destroy has_one :praise_tread_cache, as: :object, dependent: :destroy @@ -54,12 +55,22 @@ class Comment < ActiveRecord::Base # ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content # end end + elsif self.commented.contest + if self.author_id != self.commented.author_id + self.contest_messages << ContestMessage.new(:user_id => self.commented.author_id, :contest_id => self.commented.contest.id, :viewed => false) + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count + # if count == 0 + # content = strip_html self.comments.html_safe, 200 + # ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + # end + end else # 项目相关 # if self.author_id != self.commented.author_id # self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) # #content = strip_html self.comments.html_safe, 200 # #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content # end + end end diff --git a/app/models/news.rb b/app/models/news.rb index e06166494..4c0e58238 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -69,7 +69,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send + after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send, :act_as_contest_message after_update :update_activity after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score @@ -216,6 +216,16 @@ class News < ActiveRecord::Base end end + def act_as_contest_message + if self.contest_id + self.contest.contest_members.each do | m| + if m.user_id != self.author_id + self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false) + end + end + end + end + def delay_news_send if self.course @@ -240,7 +250,7 @@ class News < ActiveRecord::Base vs = [] self.contest.contest_members.each do | m| if m.user_id != self.author_id - vs << {course_message_type:'Contest',course_message_id:self.id, :user_id => m.user_id, + vs << {contest_message_type:'Contest',contest_message_id:self.id, :user_id => m.user_id, :contest_id => self.contest_id, :viewed => false} if vs.size >= 30 diff --git a/app/models/work.rb b/app/models/work.rb index 02c7b5a08..8e6eb3537 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -60,10 +60,8 @@ class Work < ActiveRecord::Base if self.work_status == 0 self.contest_messages.destroy_all else - self.contest.contest_members.each do |m| - if m.user_id != self.user_id - self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false) - end + self.contest.contestants.each do |m| + self.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => self.contest_id, :viewed => false) end end end diff --git a/app/services/contests_service.rb b/app/services/contests_service.rb index 10f1bb7e1..b4bb1acde 100644 --- a/app/services/contests_service.rb +++ b/app/services/contests_service.rb @@ -23,13 +23,18 @@ class ContestsService else if params[:invite_code].present? role_ids = params[:role] - role_str = role_ids.join(",").to_s #如果已经发送过消息了,那么就要给个提示 - if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0).count != 0 + if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :status => 0).count != 0 @state = 7 else - AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0) + if role_ids.size == 1 + AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_ids[0], :status => 0) + else + role_ids.each do |role_id| + AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_id, :status => 0) + end + end @state = 6 end else diff --git a/app/views/users/_join_contest_applied_message.html.erb b/app/views/users/_join_contest_applied_message.html.erb index 3a6b5f3d3..2baa3a9ea 100644 --- a/app/views/users/_join_contest_applied_message.html.erb +++ b/app/views/users/_join_contest_applied_message.html.erb @@ -13,23 +13,12 @@ :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - <% if applied_contest.role - role_str = "" - if applied_contest.role.include?('13') && applied_contest.role.include?('14') - role_str = "管理员、评委" - elsif applied_contest.role.include?('13') - role_str = "管理员" - elsif applied_contest.role.include?('14') - role_str = "评委" - elsif applied_contest.role.include?('15') - role_str = "参赛者" - end - end %> - 申请以<%= role_str %>的身份加入竞赛: + <%= message_user.user_extensions.school_id.blank? ? "" : "来自"+message_user.user_extensions.school.name+"," %> + 申请以"<%= get_role_str ma.role %>"的身份加入竞赛:
  • - <% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + role_str %> + <% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + get_role_str(ma.role) %> <%= link_to contest.name, contest_path(contest.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank', :title => "#{content}" %>
  • @@ -41,9 +30,9 @@ | <%= link_to '拒绝',dealwith_apply_request_contest_path(contest,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%> <% elsif ma.status == 1%> - 已同意申请 + <%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : "管理员" %>已同意 <% elsif ma.status == 2%> - 已拒绝申请 + <%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : "管理员" %>已拒绝 <%end %> diff --git a/app/views/users/_user_message_contest.html.erb b/app/views/users/_user_message_contest.html.erb index 21ab5b873..d807a80a9 100644 --- a/app/views/users/_user_message_contest.html.erb +++ b/app/views/users/_user_message_contest.html.erb @@ -32,5 +32,161 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • - <% end %> + + + <% elsif ma.contest_message_type == "JoinContest" and ma.status == 0 %> + + + + <% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %> + + + + <% elsif ma.contest_message_type == "RemoveFromContest" %> + + + + <% elsif ma.contest_message_type == "Work" && ma.status.nil? && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "Work" && ma.status == 1 && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "News" && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "Comment" && ma.contest_message %> + + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index edc94d6cc..9c0e61af6 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -66,7 +66,7 @@ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> 发布了班级作业: -
  • +
  • <% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %> <%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", diff --git a/db/migrate/20161227085308_alter_applied_contest_message.rb b/db/migrate/20161227085308_alter_applied_contest_message.rb new file mode 100644 index 000000000..cbbae7751 --- /dev/null +++ b/db/migrate/20161227085308_alter_applied_contest_message.rb @@ -0,0 +1,9 @@ +class AlterAppliedContestMessage < ActiveRecord::Migration + def up + applied_messages = AppliedMessage.where(:applied_type => 'AppliedContest') + applied_messages.update_all(:applied_user_id => nil) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 6e305986d..23d7fcd55 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 => 20161223030701) do +ActiveRecord::Schema.define(:version => 20161227085308) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -52,6 +52,18 @@ ActiveRecord::Schema.define(:version => 20161223030701) do add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + create_table "applied_contests", :force => true do |t| + t.integer "contest_id" + t.integer "user_id" + t.string "role" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "applied_contests", ["contest_id"], :name => "index_applied_contests_on_contest_id" + add_index "applied_contests", ["user_id"], :name => "index_applied_contests_on_user_id" + create_table "applied_messages", :force => true do |t| t.integer "user_id" t.integer "applied_id" @@ -325,16 +337,14 @@ ActiveRecord::Schema.define(:version => 20161223030701) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" t.date "commit_date" t.string "scmid" t.integer "user_id" - t.integer "project_id" - t.integer "type", :default => 0 end add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" @@ -485,12 +495,12 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.integer "user_id" t.integer "contest_id" t.integer "contest_message_id" - t.string "course_message_type" - t.boolean "viewed", :default => false + t.string "contest_message_type" + t.boolean "viewed", :default => false t.text "content" t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id" @@ -595,6 +605,20 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.integer "container_id", :default => 0 end + create_table "course_class_post", :id => false, :force => true do |t| + t.integer "班级id", :default => 0, :null => false + t.string "班级名" + t.integer "帖子id", :default => 0, :null => false + t.integer "主贴id" + t.string "帖子标题", :default => "", :null => false + t.text "帖子内容" + t.integer "帖子用户id" + t.integer "帖子回复数", :default => 0, :null => false + t.integer "最后回帖id" + t.datetime "发帖时间", :null => false + t.datetime "帖子更新时间", :null => false + end + create_table "course_contributor_scores", :force => true do |t| t.integer "course_id" t.integer "user_id" @@ -663,8 +687,8 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -674,28 +698,27 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.string "class_period" t.integer "school_id" t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 t.integer "lft" t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "is_delete", :default => 0 t.integer "end_time" t.string "end_term" - t.integer "is_excellent", :default => 0 - t.integer "excellent_option", :default => 0 - t.integer "is_copy", :default => 0 - t.integer "visits", :default => 0 + t.integer "is_excellent", :default => 0 + t.integer "excellent_option", :default => 0 + t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 t.integer "syllabus_id" t.string "invite_code" t.string "qrcode" - t.integer "qrcode_expiretime", :default => 0 - t.integer "professional_level_id", :limit => 1 - t.integer "invite_code_halt", :limit => 1, :default => 0 + t.integer "qrcode_expiretime", :default => 0 + t.integer "invite_code_halt", :limit => 1, :default => 0 end add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true @@ -770,11 +793,6 @@ ActiveRecord::Schema.define(:version => 20161223030701) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "disciplines", :force => true do |t| - t.string "name" - t.integer "professional_level_id", :limit => 1 - end - create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" @@ -900,11 +918,13 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.integer "exercise_status" t.integer "user_id" t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" t.integer "show_result" + t.integer "question_random", :default => 0 + t.integer "choice_random", :default => 0 end create_table "first_pages", :force => true do |t| @@ -1093,10 +1113,6 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.datetime "updated_at", :null => false end - create_table "innodb_monitor", :id => false, :force => true do |t| - t.integer "a" - end - create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1360,6 +1376,7 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.integer "course_id" t.integer "sticky", :default => 0 t.integer "org_subfield_id" + t.integer "contest_id" end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1628,12 +1645,9 @@ ActiveRecord::Schema.define(:version => 20161223030701) do end create_table "professional_levels", :force => true do |t| - t.integer "level" - end - - create_table "professions", :force => true do |t| - t.string "name" - t.integer "discipline_id", :limit => 1 + t.string "level" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "project_infos", :force => true do |t| @@ -1696,6 +1710,7 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.boolean "hidden_repo", :default => false, :null => false t.integer "attachmenttype", :default => 1 t.integer "user_id" + t.integer "dts_test", :default => 0 t.string "enterprise_name" t.integer "organization_id" t.integer "project_new_type" @@ -1703,11 +1718,6 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.integer "forked_from_project_id" t.integer "forked_count" t.integer "publish_resource", :default => 0 - t.integer "boards_count", :default => 0 - t.integer "news_count", :default => 0 - t.integer "acts_count", :default => 0 - t.integer "journals_count", :default => 0 - t.integer "boards_reply_count", :default => 0 t.integer "visits", :default => 0 t.integer "hot", :default => 0 t.string "invite_code" @@ -2105,8 +2115,8 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.string "title" t.text "description" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "eng_name" t.integer "syllabus_type" t.integer "credit" @@ -2115,9 +2125,8 @@ ActiveRecord::Schema.define(:version => 20161223030701) do t.integer "practice_hours" t.string "applicable_major" t.string "pre_course" - t.integer "visits", :default => 0 - t.integer "des_status", :default => 0 - t.integer "professional_level_id", :limit => 1 + t.integer "visits", :default => 0 + t.integer "des_status", :default => 0 end add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id" diff --git a/lib/tasks/contest_work_endtime.rake b/lib/tasks/contest_work_endtime.rake new file mode 100644 index 000000000..4b1fe88c8 --- /dev/null +++ b/lib/tasks/contest_work_endtime.rake @@ -0,0 +1,20 @@ +#coding=utf-8 + +namespace :contest_work_endtime do + desc "send a message for work deadline" + task :message => :environment do + puts "--------------------------------contest_work_endtime start" + contrast_time = Time.now - 86400 + homework_commons = Work.where("end_time >=? and end_time <=?",contrast_time, Time.now) + homework_commons.each do |homework_common| + if ContestMessage.where("contest_message_type =? and contest_message_id =? and status =?", "Work", homework_common.id, 1).first.nil? + homework_common.contest.contestants.each do |s| + homework_common.contest_messages << ContestMessage.new(:user_id => s.student_id, :contest_id => homework_common.contest_id, :viewed => false, :status => true) + # 发送邮件通知 + # Mailer.homework_endtime__added(homework_common, s.student_id).deliver + end + end + end + puts "--------------------------------contest_work_endtime end" + end +end diff --git a/lib/tasks/contest_work_publichtime.rake b/lib/tasks/contest_work_publichtime.rake index 9cf2ff1ba..2007ea2b5 100644 --- a/lib/tasks/contest_work_publichtime.rake +++ b/lib/tasks/contest_work_publichtime.rake @@ -11,8 +11,8 @@ namespace :contest_work_publishtime do homework.update_column('work_status', 1) contest = homework.contest - contest.contest_members.each do |m| - homework.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => nil) + contest.contestants.each do |m| + homework.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => contest.id, :viewed => false, :status => nil) end if homework.contest_acts.size == 0 homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id) diff --git a/public/stylesheets/css/structure.css b/public/stylesheets/css/structure.css index 4ddf55c6c..c03644356 100644 --- a/public/stylesheets/css/structure.css +++ b/public/stylesheets/css/structure.css @@ -97,7 +97,7 @@ div#menu ul ul ul li a{ width:185px; overflow:hidden; white-space: nowrap; text- .homepageNewsPortrait img:hover{border: 3px solid #e6e6e6;} .homepageNewsPortrait img { border: 3px solid #fff;-webkit-border-radius:30px;-moz-border-radius:30px;-o-border-radius:30px;border-radius:30px;} .homepageNewsPublisher { max-width:100px; font-size:12px; color:#269ac9; display:block; /*padding-left:5px;*/ overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; } -.homepageNewsType {max-width: 200px; padding-left: 5px; font-size:12px; color:#888888; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +.homepageNewsType {max-width: 320px; padding-left: 5px; font-size:12px; color:#888888; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .homepageNewsTypeHomework {width:160px; padding-left: 5px; font-size:12px; color:#888888; display:block; overflow:hidden; height:49px;word-break:break-all; word-wrap:break-word; text-overflow:ellipsis;} .homepageNewsPubType {auto-width:230px; font-size:12px; color:#888888; display: block;} .homepageNewsPubTypeHomework {width:270px; font-size:12px; color:#888888; display: block; white-space:nowrap;}