From 89782ffabde12b3d07db370305d86e275b5fe853 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 14 Oct 2019 16:04:24 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/competitions/competitions/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competitions/competitions/index.json.jbuilder b/app/views/competitions/competitions/index.json.jbuilder index f0d70f69e..400f17379 100644 --- a/app/views/competitions/competitions/index.json.jbuilder +++ b/app/views/competitions/competitions/index.json.jbuilder @@ -20,7 +20,7 @@ json.competitions do if section json.current_stage do - json.name = section.competition_stage.name + json.name section.competition_stage.name json.start_time section.display_start_time json.end_time section.display_end_time end From f35bc5f18d06478b2d66247816067d1e9347bcff Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 10:20:30 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E7=AB=9E=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition_mode_setting.rb | 3 +++ .../20191015013924_add_new_column_to_competitions.rb | 6 ++++++ ...20191015015723_create_competition_mode_settings.rb | 11 +++++++++++ spec/models/competition_mode_setting_spec.rb | 5 +++++ 4 files changed, 25 insertions(+) create mode 100644 app/models/competition_mode_setting.rb create mode 100644 db/migrate/20191015013924_add_new_column_to_competitions.rb create mode 100644 db/migrate/20191015015723_create_competition_mode_settings.rb create mode 100644 spec/models/competition_mode_setting_spec.rb diff --git a/app/models/competition_mode_setting.rb b/app/models/competition_mode_setting.rb new file mode 100644 index 000000000..b6bafa7c3 --- /dev/null +++ b/app/models/competition_mode_setting.rb @@ -0,0 +1,3 @@ +class CompetitionModeSetting < ApplicationRecord + belongs_to :course +end diff --git a/db/migrate/20191015013924_add_new_column_to_competitions.rb b/db/migrate/20191015013924_add_new_column_to_competitions.rb new file mode 100644 index 000000000..616a46059 --- /dev/null +++ b/db/migrate/20191015013924_add_new_column_to_competitions.rb @@ -0,0 +1,6 @@ +class AddNewColumnToCompetitions < ActiveRecord::Migration[5.2] + def change + add_column :competitions, :bonus, :integer, default: 0 + add_column :competitions, :mode, :integer, default: 0 + end +end diff --git a/db/migrate/20191015015723_create_competition_mode_settings.rb b/db/migrate/20191015015723_create_competition_mode_settings.rb new file mode 100644 index 000000000..5d170eeab --- /dev/null +++ b/db/migrate/20191015015723_create_competition_mode_settings.rb @@ -0,0 +1,11 @@ +class CreateCompetitionModeSettings < ActiveRecord::Migration[5.2] + def change + create_table :competition_mode_settings do |t| + t.references :course + t.datetime :start_time + t.datetime :end_time + + t.timestamps + end + end +end diff --git a/spec/models/competition_mode_setting_spec.rb b/spec/models/competition_mode_setting_spec.rb new file mode 100644 index 000000000..535767880 --- /dev/null +++ b/spec/models/competition_mode_setting_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CompetitionModeSetting, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 2587be26b374f285677c92e60535a233b2a84e1e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 16:05:31 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E7=AB=9E=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/competitions_controller.rb | 6 ++++++ app/views/admins/shared/_sidebar.html.erb | 2 ++ config/routes.rb | 2 ++ 3 files changed, 10 insertions(+) create mode 100644 app/controllers/admins/competitions_controller.rb diff --git a/app/controllers/admins/competitions_controller.rb b/app/controllers/admins/competitions_controller.rb new file mode 100644 index 000000000..0e17993da --- /dev/null +++ b/app/controllers/admins/competitions_controller.rb @@ -0,0 +1,6 @@ +class Admins::CompetitionController < Admins::BaseController + + def index + + end +end \ No newline at end of file diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index 145910928..ca6fb2a46 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -66,6 +66,8 @@ <% end %> +
  • <%= sidebar_item(admins_competitions_path, '竞赛', icon: 'trophy', controller: 'admins-competitions') %>
  • +
  • <%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
  • <%= sidebar_item(admins_carousels_path, '轮播图', icon: 'image', controller: 'admins-carousels') %>
  • diff --git a/config/routes.rb b/config/routes.rb index 32725e8e9..f6f8db066 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -980,6 +980,8 @@ Rails.application.routes.draw do resource :laboratory_setting, only: [:show, :update] resource :laboratory_user, only: [:create, :destroy] end + + resources :competitions, only: [:index, :destroy] end resources :colleges, only: [] do From 45f337e66fb2ed11ea1240c5fc689379eb42820b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 17:08:29 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E7=AB=9E=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/competitions_controller.rb | 11 ++++++- app/views/admins/competitions/index.html.erb | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/views/admins/competitions/index.html.erb diff --git a/app/controllers/admins/competitions_controller.rb b/app/controllers/admins/competitions_controller.rb index 0e17993da..3d6bef819 100644 --- a/app/controllers/admins/competitions_controller.rb +++ b/app/controllers/admins/competitions_controller.rb @@ -1,6 +1,15 @@ -class Admins::CompetitionController < Admins::BaseController +class Admins::CompetitionsController < Admins::BaseController def index + params[:sort_by] = params[:sort_by].presence || 'created_on' + params[:sort_direction] = params[:sort_direction].presence || 'desc' + @competitions = custom_sort Competition.all, params[:sort_by], params[:sort_direction] + @params_page = params[:page] || 1 + @competitions = paginate @competitions + respond_to do |format| + format.js + format.html + end end end \ No newline at end of file diff --git a/app/views/admins/competitions/index.html.erb b/app/views/admins/competitions/index.html.erb new file mode 100644 index 000000000..adcee53b1 --- /dev/null +++ b/app/views/admins/competitions/index.html.erb @@ -0,0 +1,32 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('竞赛列表', admins_competitions_path) %> +<% end %> + +
    + <%= form_tag(admins_shixuns_path, method: :get, class: 'form-inline search-form',id:"shixuns-search-form",remote:true) do %> +
    + + <% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["待审核(#{@pending_shixuns})", 'pending'], ["已发布(#{@processed_shixuns})", 'processed'],["已关闭(#{@closed_shixuns})",'closed']] %> + <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %> +
    + +
    + + <%= select_tag(:tag, options_for_select(@shixuns_type_check.unshift(["",nil])), class: 'form-control',id:"tag-choosed") %> +
    + +
    + + <% auto_trial_options = [['创建者姓名', 0], ['实训名称', 1], ['学校名称', 2]] %> + <%= select_tag(:search_type, options_for_select(auto_trial_options), class: 'form-control') %> +
    + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '输入关键字搜索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with': '搜索中...') %> + <%= link_to "清除",admins_shixuns_path,class: "btn btn-default",id:"shixuns-clear-search",'data-disable-with': '清除中...' %> + <% end %> + 导出 +
    + +
    + <%= render partial: 'admins/shixuns/shared/list', locals: { shixuns: @shixuns } %> +
    From da2bf0bbad1449267c14f9f3b5645087cce83816 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 17:23:58 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=8A=A9=E6=95=99=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admins/competitions/index.html.erb | 27 +------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/app/views/admins/competitions/index.html.erb b/app/views/admins/competitions/index.html.erb index adcee53b1..8fa238181 100644 --- a/app/views/admins/competitions/index.html.erb +++ b/app/views/admins/competitions/index.html.erb @@ -2,31 +2,6 @@ <% add_admin_breadcrumb('竞赛列表', admins_competitions_path) %> <% end %> -
    - <%= form_tag(admins_shixuns_path, method: :get, class: 'form-inline search-form',id:"shixuns-search-form",remote:true) do %> -
    - - <% status_options = [['全部', ''], ["编辑中(#{@editing_shixuns})", "editing"], ["待审核(#{@pending_shixuns})", 'pending'], ["已发布(#{@processed_shixuns})", 'processed'],["已关闭(#{@closed_shixuns})",'closed']] %> - <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %> -
    - -
    - - <%= select_tag(:tag, options_for_select(@shixuns_type_check.unshift(["",nil])), class: 'form-control',id:"tag-choosed") %> -
    - -
    - - <% auto_trial_options = [['创建者姓名', 0], ['实训名称', 1], ['学校名称', 2]] %> - <%= select_tag(:search_type, options_for_select(auto_trial_options), class: 'form-control') %> -
    - <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '输入关键字搜索') %> - <%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with': '搜索中...') %> - <%= link_to "清除",admins_shixuns_path,class: "btn btn-default",id:"shixuns-clear-search",'data-disable-with': '清除中...' %> - <% end %> - 导出 -
    - -
    +
    <%= render partial: 'admins/shixuns/shared/list', locals: { shixuns: @shixuns } %>
    From f55ca78bc9db50c9f5657e1bc65bf2cb4bcdc75e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 17:35:51 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/mine.json.jbuilder | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/courses/mine.json.jbuilder b/app/views/courses/mine.json.jbuilder index 41368d883..fc6a5becc 100644 --- a/app/views/courses/mine.json.jbuilder +++ b/app/views/courses/mine.json.jbuilder @@ -1,5 +1,6 @@ json.partial! "commons/success" -json.data do - json.array! @courses, :id, :name, :updated_at, :created_at, :end_date +json.data @courses do |course| + json.(course, :id, :name, :updated_at, :end_date) + json.created_at course.created_at.strftime("%Y-%m-%d") end From dd562543ba2a361ebbee3f74d0fff087333d394b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 17:39:18 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/course_modules_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/course_modules_controller.rb b/app/controllers/course_modules_controller.rb index fccc28f6d..0bef519fd 100644 --- a/app/controllers/course_modules_controller.rb +++ b/app/controllers/course_modules_controller.rb @@ -2,7 +2,8 @@ class CourseModulesController < ApplicationController before_action :require_login, :check_auth before_action :set_module, except: [:unhidden_modules] before_action :find_course, only: [:unhidden_modules] - before_action :teacher_or_admin_allowed + before_action :teacher_or_admin_allowed, except: [:add_second_category] + before_action :teacher_allowed, only: [:add_second_category] # 模块置顶 def sticky_module From 7303a7e626bce985e359f7b22a635a79876ccfbb Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 15 Oct 2019 17:50:56 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 9c60317bd..8b7034ab9 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -98,7 +98,7 @@ class Attachment < ApplicationRecord def become_history history = self.attachment_histories.first - new_attachment_history = AttachmentHistory.new(self.attributes.except("id", "resource_bank_id", "unified_setting", "course_second_category_id").merge( + new_attachment_history = AttachmentHistory.new(self.attributes.except("id", "resource_bank_id", "unified_setting", "course_second_category_id", "delay_publish").merge( attachment_id: self.id, version: history.nil? ? 1 : history.version + 1, )) @@ -106,7 +106,7 @@ class Attachment < ApplicationRecord end def copy_attributes_from_new_attachment(new_attachment) - self.attributes = new_attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes",'is_publish','publish_time') + self.attributes = new_attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes",'is_publish','publish_time', "delay_publish") end def set_public(is_public)