diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 4f2a19536..c641231a6 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -19,7 +19,7 @@ class ShixunsController < ApplicationController :add_file, :jupyter_exec] before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public, - :shixun_members_added, :change_manager, :collaborators_delete, + :shixun_members_added, :change_manager, :collaborators_delete, :upload_git_file, :cancel_apply_public, :cancel_publish, :add_collaborators, :add_file] before_action :portion_allowed, only: [:copy] @@ -883,7 +883,18 @@ class ShixunsController < ApplicationController author_name = current_user.real_name author_email = current_user.git_mail @content = update_file_content content, @repo_path, @path, author_email, author_name, "Edit by browser" - end + end + + def upload_git_file + upload_file = params["file"] + uid_logger("#########################file_params####{params["#{params[:file]}"]}") + raise "未上传文件" unless upload_file + content = upload_file.tempfile.read + author_name = current_user.real_name + author_email = current_user.git_mail + update_file_content(content, @repo_path, author_email, author_name, "upload by browser") + render_ok + end def add_collaborators member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" diff --git a/app/controllers/tag_disciplines_controller.rb b/app/controllers/tag_disciplines_controller.rb new file mode 100644 index 000000000..2650f51eb --- /dev/null +++ b/app/controllers/tag_disciplines_controller.rb @@ -0,0 +1,9 @@ +class TagDisciplinesController < ApplicationController + before_action :require_login + + def create + sub_discipline = SubDiscipline.find_by!(id: params[:sub_discipline_id]) + tag_discipline = TagDiscipline.create!(name: params[:name].to_s.strip, sub_discipline: sub_discipline, user_id: current_user.id) + render_ok({tag_discipline_id: tag_discipline.id}) + end +end \ No newline at end of file diff --git a/app/models/tag_discipline.rb b/app/models/tag_discipline.rb index 24567505e..6be032a58 100644 --- a/app/models/tag_discipline.rb +++ b/app/models/tag_discipline.rb @@ -1,8 +1,10 @@ class TagDiscipline < ApplicationRecord belongs_to :sub_discipline - belongs_to :user + belongs_to :user, optional: true has_many :tag_discipline_containers, dependent: :destroy + validates_presence_of :name + def discipline sub_discipline&.discipline end diff --git a/app/views/hacks/edit.json.jbuilder b/app/views/hacks/edit.json.jbuilder index e6fee65b8..8e58569bc 100644 --- a/app/views/hacks/edit.json.jbuilder +++ b/app/views/hacks/edit.json.jbuilder @@ -1,5 +1,8 @@ # 编程内容 -json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not, :status) +json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not, :status, :sub_discipline_id) + +# 课程 +json.tag_discipline_id @hack.tag_discipline_containers.pluck(:tag_discipline_id) # 代码 json.language @hack.language diff --git a/config/routes.rb b/config/routes.rb index 24edd4109..77ffdfc2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -56,6 +56,7 @@ Rails.application.routes.draw do end resources :disciplines, only: [:index] + resources :tag_disciplines, only: [:create] resources :item_banks do member do @@ -301,6 +302,7 @@ Rails.application.routes.draw do post :set_secret_dir post :commits post :file_content + post :upload_git_file post :update_file post :close post :add_file diff --git a/db/migrate/20200102020737_migrate_item_type.rb b/db/migrate/20200102020737_migrate_item_type.rb new file mode 100644 index 000000000..d5a247926 --- /dev/null +++ b/db/migrate/20200102020737_migrate_item_type.rb @@ -0,0 +1,6 @@ +class MigrateItemType < ActiveRecord::Migration[5.2] + def change + add_column :item_banks, :container_id, :integer + add_column :item_banks, :container_type, :string + end +end diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index d60f68b22..35b2a1ee8 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -403,7 +403,8 @@ class CommonWorkList extends Component{ left_time: {}, category: {}, b_order: 'desc', - searchtypes:false + searchtypes:false, + loadingstate:false } } onTablePagination = (page) => { @@ -420,9 +421,11 @@ class CommonWorkList extends Component{ }) }else{ this.setState({ - searchtypes:true + searchtypes:true, + loadingstate:true }) } + this.fetchList() } onSearchValueInput = (e) => { @@ -482,7 +485,8 @@ class CommonWorkList extends Component{ if (response.data) { this.setState({ ...response.data, - isSpin:false + isSpin:false, + loadingstate:false }) this.props.initWorkDetailCommonState && this.props.initWorkDetailCommonState( Object.assign({...response.data}, { @@ -492,7 +496,8 @@ class CommonWorkList extends Component{ }).catch((error)=>{ console.log(error) this.setState({ - isSpin:false + isSpin:false, + loadingstate:false }) }) @@ -850,9 +855,9 @@ class CommonWorkList extends Component{