diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 90041420..50f97bc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -357,6 +357,7 @@ class ApplicationController < ActionController::Base end def require_login + logger.info("#########login?: #{User.current.id}") logger.info("#########login?: #{User.current.logged?}") logger.info("#########get?: #{request.get?}") if !User.current.logged? diff --git a/app/controllers/managements/video_applies_controller.rb b/app/controllers/managements/video_applies_controller.rb new file mode 100644 index 00000000..55c4c337 --- /dev/null +++ b/app/controllers/managements/video_applies_controller.rb @@ -0,0 +1,47 @@ +class Managements::VideoAppliesController < Managements::BaseController + before_filter :set_menu_type + + def index + applies = VideoApply.order('video_applies.updated_at desc') + + search = params[:search].to_s.strip + if search.present? + applies = applies.joins(:video) + .where('videos.title like :search', search: "%#{search}%") + end + + applies = applies.where(status: params[:status].presence || :pending) + + @video_applies = paginateHelper applies.includes(video: { user: :user_extensions }) + + respond_to do |format| + format.js + format.html + end + end + + def agree + Videos::AgreeApplyService.new(current_video_apply, current_user).call + render json: { status: 0 } + rescue Videos::AgreeApplyService::Error => e + render json: { status: -1, message: e.message } + end + + def refuse + Videos::RefuseApplyService.new(current_video_apply, current_user, reason: params[:reason]).call + render json: { status: 0 } + rescue Videos::RefuseApplyService::Error => e + render json: { status: -1, message: e.message } + end + + private + + def current_video_apply + @_current_video_apply ||= VideoApply.find(params[:id]) + end + + def set_menu_type + @menu_type = 10 + @sub_type = 10 + end +end \ No newline at end of file diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index d946c12b..cc896ef2 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2360,6 +2360,14 @@ end end end + # 实践课程的金课设置 + def excellent_subject_setting + if params[:subject_id] + subject = Subject.find params[:subject_id] + subject.update_attributes(:excellent => !subject.excellent) + end + end + # 已发布实训路径首页显示 def subject_homepage_show if params[:subject_id] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6a62503e..c497cb4e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -756,6 +756,7 @@ module ApplicationHelper when 7 then '职业认证' when 8 then '教学案例发布' when 9 then '众包需求发布' + when 10 then '视频发布' else '职业认证' end when 11 diff --git a/app/models/subject.rb b/app/models/subject.rb index 819d446c..77db603a 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -10,7 +10,7 @@ class Subject < ActiveRecord::Base belongs_to :major # score_count 只能适合在首页使用 attr_accessible :description, :name, :status, :visits, :user_id, :course_list_id, :major_id, :learning_notes, :introduction, - :homepage_show, :score_count, :publish_time, :updated_at + :homepage_show, :score_count, :publish_time, :updated_at, :excellent has_many :stages, :dependent => :destroy, :order => "stages.position ASC" has_many :stage_shixuns, :dependent => :destroy diff --git a/app/models/video.rb b/app/models/video.rb new file mode 100644 index 00000000..c849f1fa --- /dev/null +++ b/app/models/video.rb @@ -0,0 +1,36 @@ +class Video < ActiveRecord::Base + include AASM + + belongs_to :user + + has_many :video_applies, dependent: :destroy + has_one :processing_video_apply, conditions: { status: :pending }, class_name: 'VideoApply' + + aasm(:status) do + state :pending, initial: true + state :processing + state :refused + state :published + + event :apply_publish do + transitions from: :pending, to: :processing + end + + event :refuse do + transitions from: :processing, to: :refused + end + + event :publish do + transitions from: :processing, to: :published, guard: :vod_uploaded? + end + end + + aasm(:vod_status, namespace: :vod) do + state :uploading, initial: true + state :uploaded + + event :upload_success do + transitions from: :uploading, to: :uploaded + end + end +end \ No newline at end of file diff --git a/app/models/video_apply.rb b/app/models/video_apply.rb new file mode 100644 index 00000000..8d91bb7a --- /dev/null +++ b/app/models/video_apply.rb @@ -0,0 +1,19 @@ +class VideoApply < ActiveRecord::Base + include AASM + + belongs_to :video + + aasm(:status) do + state :pending, initial: true + state :refused + state :agreed + + event :refuse do + transitions from: :pending, to: :refused + end + + event :agree do + transitions from: :pending, to: :agreed + end + end +end \ No newline at end of file diff --git a/app/services/videos/agree_apply_service.rb b/app/services/videos/agree_apply_service.rb new file mode 100644 index 00000000..a317f8fa --- /dev/null +++ b/app/services/videos/agree_apply_service.rb @@ -0,0 +1,35 @@ +class Videos::AgreeApplyService + Error = Class.new(StandardError) + + attr_reader :video_apply, :video, :user + + def initialize(video_apply, user) + @video_apply = video_apply + @video = video_apply.video + @user = user + end + + def call + raise Error, '该状态下不能进行此操作' unless video_apply.may_agree? && video.may_publish? + + ActiveRecord::Base.transaction do + video_apply.agree! + + video.published_at = Time.now + video.publish + video.save! + + # 将消息改为已处理 + Tiding.where(container_id: video.id, container_type: 'Video', tiding_type: 'Apply', status: 0).update_all(status: 1) + notify_video_author! + end + end + + private + + def notify_video_author! + Tiding.create!(user_id: video.user_id, trigger_user_id: 1, + container_id: video.id, container_type: 'Video', + tiding_type: 'System', status: 1) + end +end \ No newline at end of file diff --git a/app/services/videos/refuse_apply_service.rb b/app/services/videos/refuse_apply_service.rb new file mode 100644 index 00000000..e6ef65dc --- /dev/null +++ b/app/services/videos/refuse_apply_service.rb @@ -0,0 +1,38 @@ +class Videos::RefuseApplyService + Error = Class.new(StandardError) + + attr_reader :video_apply, :video, :user, :params + + def initialize(video_apply, user, params) + @video_apply = video_apply + @video = video_apply.video + @user = user + @params = params + end + + def call + reason = params[:reason].to_s.strip + raise Error, '原因不能为空' if reason.blank? + raise Error, '该状态下不能进行此操作' unless video_apply.may_refuse? + + ActiveRecord::Base.transaction do + video_apply.reason = reason + video_apply.refuse + video_apply.save! + + video.refuse! + + # 将消息改为已处理 + Tiding.where(container_id: video.id, container_type: 'Video', tiding_type: 'Apply', status: 0).update_all(status: 1) + notify_video_author! + end + end + + private + + def notify_video_author! + Tiding.create!(user_id: video.user_id, trigger_user_id: 1, + container_id: video.id, container_type: 'Video', + tiding_type: 'System', status: 2, extra: video_apply.reason) + end +end \ No newline at end of file diff --git a/app/views/competitions/_gq_second_code_competition.html.erb b/app/views/competitions/_gq_second_code_competition.html.erb index bc54e485..1af1cf52 100644 --- a/app/views/competitions/_gq_second_code_competition.html.erb +++ b/app/views/competitions/_gq_second_code_competition.html.erb @@ -73,6 +73,21 @@ link_url: 'https://keras.io/layers/about-keras-layers/' }] ] + extra_data = [ + { + name: 'C++项目', + description: "本项目的paddle/fluid/operators/optimizers目录中包含了常见的优化器(如,Momentum,Adam等等)的c++实现。", + task: '标注../fluid/operators/optimizers/目录下的所有代码文件', + link_name: '官方,优化器', + link_url: 'https://www.paddlepaddle.org.cn/documentation/docs/zh/1.5/api_guides/low_level/optimizer.html' + },{ + name: 'Python项目', + description: "本项目的python/paddle/fluid/layers/nn.py中包含了神经网络中大量常见层和操作符的python实现,如fc、conv、gru等等。", + task: '标注../paddle/fluid/layers/nn.py代码文件', + link_name: '官方,nn', + link_url: 'https://www.paddlepaddle.org.cn/documentation/docs/zh/1.5/api_cn/layers_cn/nn_cn.html' + } + ] %> <% @competition.competition_stages.includes(:competition_stage_sections).each_with_index do |stage, i| %> @@ -97,9 +112,9 @@ 标注说明:每个小组选择一种编程语言的题目,针对标注任务中指定的标注模块,要求对代码模块、模块中的代码文件, 以及文件中的函数必须进行标注,关键代码块、代码行及关键变量等由参赛者自由选择进行标注。 正式赛第一阶段的比赛在标注阶段就开放查看所有人的标注,请大家根据个人理解,写出自己的风格。我们将综合考虑标注的原创性、准确性、 完整性和多样性等不同的维度对标注质量进行评分。<%= challenge_description_extra[i] %>

-
  • 认证+ diff --git a/app/views/managements/_subject_list.html.erb b/app/views/managements/_subject_list.html.erb index 40a3b0c4..3299af10 100644 --- a/app/views/managements/_subject_list.html.erb +++ b/app/views/managements/_subject_list.html.erb @@ -3,7 +3,7 @@ ID - 实训套件名称 + 实训套件名称 阶段 技术体系 等级体系 @@ -75,6 +75,10 @@ value="<%= c_shixun.id %>" <%= c_shixun.homepage_show ? "checked" : "" %> class="ml-3 mr5 magic-checkbox" id="homepage_show_<%= c_shixun.id %>"> + + value="<%= c_shixun.id %>" <%= c_shixun.excellent ? "checked" : "" %> class="ml-3 mr5 magic-checkbox" id="excellent_<%= c_shixun.id %>"> + + <% end %> @@ -131,7 +135,16 @@ type: 'post', dateType: "script" }); - }) + }); + $("input[name='excellent']").click(function(){ + var subject_id = $(this).val(); + $.ajax({ + url:"<%= excellent_subject_setting_managements_path %>", + data: {subject_id: subject_id}, + type: 'post', + dateType: "script" + }); + }); }); function select_repertoire(subject_id, rep_id){ $.ajax({ diff --git a/app/views/managements/excellent_subject_setting.js.erb b/app/views/managements/excellent_subject_setting.js.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/managements/video_applies/_video_apply_list.html.erb b/app/views/managements/video_applies/_video_apply_list.html.erb new file mode 100644 index 00000000..d3cfc50d --- /dev/null +++ b/app/views/managements/video_applies/_video_apply_list.html.erb @@ -0,0 +1,77 @@ +<% if @video_applies.present? %> + <% @video_applies.each do |apply| %> + <% user = apply.video.user %> + <% video = apply.video %> +
    + + <%= image_tag(url_to_avatar(user), :class => "fl with10 edu-ad-user", :alt => "头像", :width => "50", :height => "50" ) %> + +
    + +
    +
    + <% end %> +
    +
    +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> +
    +
    +
    +
    +<% else %> + <%= render :partial => "welcome/no_data" %> +<% end %> + + \ No newline at end of file diff --git a/app/views/managements/video_applies/index.html.erb b/app/views/managements/video_applies/index.html.erb new file mode 100644 index 00000000..9a371e6c --- /dev/null +++ b/app/views/managements/video_applies/index.html.erb @@ -0,0 +1,120 @@ +
    +
    +

    视频发布

    +
    +
    +
    +
      +
    • + <%= link_to "待审批", video_applies_path(status: :pending), class: 'tab_type', remote: true %> +
    • +
    • + <%= link_to "已审批", video_applies_path(status: [:refused, :agreed]), class: 'tab_type', remote: true %> +
    • +
    +
    +
    +
    +
    + + +
    +
    +
    + <%= render :partial => "managements/video_applies/video_apply_list"%> +
    +
    +
    + +
    +
    +

    + <%= link_to "全部", video_applies_path(status: [:refused, :agreed]), :class => "edu-filter-cir-grey mr5 fl font-12 active", :id => "video_all_authentication", :remote => true %> + <%= link_to "同意", video_applies_path(status: :agreed), :class => "edu-filter-cir-grey mr5 fl font-12", :id => "video_agree_authentication", :remote => true %> + <%= link_to "拒绝", video_applies_path(status: :refused), :class => "edu-filter-cir-grey mr5 fl font-12", :id => "video_reject_authentication", :remote => true %> +

    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/app/views/managements/video_applies/index.js.erb b/app/views/managements/video_applies/index.js.erb new file mode 100644 index 00000000..ea991c14 --- /dev/null +++ b/app/views/managements/video_applies/index.js.erb @@ -0,0 +1,30 @@ +var nTabIcon_1 = $("#edu-tab-con-1"); +var nTabIcon_2 = $("#edu-tab-con-2"); +var nTabNav_1 = $("#edu-tab-nav-1"); +var nTabNav_2 = $("#edu-tab-nav-2"); +var nAudit = $("#video_all_authentication").parent(); + +<% if params[:status].to_s == 'pending' %> +$("#authentication_list").html("<%= j( render :partial => "managements/video_applies/video_apply_list" ) %>"); +nTabNav_1.addClass("background-orange"); +nTabNav_2.removeClass("background-orange"); +nTabIcon_1.show(); +nTabIcon_2.hide(); +<% else %> +$("#video_authentication_list").html("<%= j( render :partial => "managements/video_applies/video_apply_list" ) %>"); +nTabNav_1.removeClass("background-orange"); +nTabNav_2.addClass("background-orange"); +nTabIcon_1.hide(); +nTabIcon_2.show(); +/* -------------------------- 未审批(全部、同意、拒绝点击时动态样式) ------------------------------ */ +if(<%= params[:status].to_s == 'agreed' %>){ + nAudit.find(".active").removeClass("active"); + $("#video_agree_authentication").addClass("active"); +}else if(<%= params[:status].to_s == 'refused' %>){ + nAudit.find(".active").removeClass("active"); + $("#video_reject_authentication").addClass("active"); +}else{ + nAudit.find(".active").removeClass("active"); + $("#video_all_authentication").addClass("active"); +} +<% end %> \ No newline at end of file diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index d94a99c9..ae084e0f 100755 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1 +1 @@ -Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all +Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 24.hours, :key => '_educoder_session', :domain => :all diff --git a/config/routes.rb b/config/routes.rb index 1df0c29c..22ea0bc4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -626,6 +626,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'update_shixun_code_hidden' get 'update_shixun_excute_time' post 'subject_homepage_show' + post 'excellent_subject_setting' post 'support_shixun' post 'add_course' match 'add_major',:via=>[:get,:post] @@ -765,6 +766,13 @@ RedmineApp::Application.routes.draw do ## oauth相关 post :refuse end end + + resources :video_applies, only: [:index] do + member do + post :agree + post :refuse + end + end end end end diff --git a/db/migrate/20190813070926_add_excellent_to_subject.rb b/db/migrate/20190813070926_add_excellent_to_subject.rb new file mode 100644 index 00000000..6da01be3 --- /dev/null +++ b/db/migrate/20190813070926_add_excellent_to_subject.rb @@ -0,0 +1,5 @@ +class AddExcellentToSubject < ActiveRecord::Migration + def change + add_column :subjects, :excellent, :boolean, :default => false + end +end diff --git a/public/react/src/modules/ec/ecStudentList/ecStudentList.js b/public/react/src/modules/ec/ecStudentList/ecStudentList.js index 4208b2bc..b60ab2ee 100644 --- a/public/react/src/modules/ec/ecStudentList/ecStudentList.js +++ b/public/react/src/modules/ec/ecStudentList/ecStudentList.js @@ -242,7 +242,7 @@ class ecStudentList extends Component { } } } - let url ='/ec_major_schools/'+major_id+'/academic_years/'+year_id+'/destroy_students.json' + let url ='/ec_major_schools/'+major_id+'/academic_years/'+year_id+'/destroy_students' axios.delete(url,{data:{ all:studentall, student_ids:newstudent_id, diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index c9879352..6947ac54 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -669,7 +669,7 @@ a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important; .second_code_2{min-height: 436px;} .second_code_3{min-height: 1460px;padding-top: 190px;box-sizing: border-box;position: relative} .second_code_4{min-height: 1459px;padding-top: 190px;box-sizing: border-box;position: relative} -.second_code_5{min-height: 1464px;padding-top: 190px;box-sizing: border-box;position: relative} +.second_code_5{min-height: 2314px;padding-top: 190px;box-sizing: border-box;position: relative} .second_code_6{min-height: 1060px;} .second_code_7{min-height: 1116px;} .second_code_8{min-height: 711px;}