diff --git a/app/assets/javascripts/admins/project_package_applies/project_package_applies.js b/app/assets/javascripts/admins/project_package_applies/project_package_applies.js
new file mode 100644
index 000000000..153ad1f66
--- /dev/null
+++ b/app/assets/javascripts/admins/project_package_applies/project_package_applies.js
@@ -0,0 +1,20 @@
+$(document).on('turbolinks:load', function() {
+ if ($('body.admins-project-package-applies-index-page').length > 0) {
+ var $searchFrom = $('.project-package-applies-form');
+ $searchFrom.find('select[name="status"]').val('pending');
+
+ $searchFrom.on('click', '.search-form-tab', function(){
+ var $link = $(this);
+
+ $searchFrom.find('input[name="keyword"]').val('');
+ $searchFrom.find('select[name="status"]').val('all');
+
+ if($link.data('value') === 'all'){
+ $searchFrom.find('.status-filter').show();
+ } else {
+ $searchFrom.find('.status-filter').hide();
+ $searchFrom.find('select[name="status"]').val('pending');
+ }
+ });
+ }
+})
\ No newline at end of file
diff --git a/app/assets/javascripts/admins/video_applies/index.js b/app/assets/javascripts/admins/video_applies/index.js
new file mode 100644
index 000000000..2e72acd97
--- /dev/null
+++ b/app/assets/javascripts/admins/video_applies/index.js
@@ -0,0 +1,20 @@
+$(document).on('turbolinks:load', function() {
+ if ($('body.admins-video-applies-index-page').length > 0) {
+ var $searchFrom = $('.video-applies-form');
+ $searchFrom.find('select[name="status"]').val('pending');
+
+ $searchFrom.on('click', '.search-form-tab', function(){
+ var $link = $(this);
+
+ $searchFrom.find('input[name="keyword"]').val('');
+ $searchFrom.find('select[name="status"]').val('all');
+
+ if($link.data('value') === 'all'){
+ $searchFrom.find('.status-filter').show();
+ } else {
+ $searchFrom.find('.status-filter').hide();
+ $searchFrom.find('select[name="status"]').val('pending');
+ }
+ });
+ }
+})
\ No newline at end of file
diff --git a/app/assets/stylesheets/admins/project_package_apply.scss b/app/assets/stylesheets/admins/project_package_apply.scss
new file mode 100644
index 000000000..a6daac205
--- /dev/null
+++ b/app/assets/stylesheets/admins/project_package_apply.scss
@@ -0,0 +1,9 @@
+.admins-project-package-applies-index-page {
+ .project-package-applies-list-container {
+ span {
+ &.apply-status-agreed { color: #28a745; }
+ &.apply-status-refused { color: #dc3545; }
+ &.apply-status-processed { color: #6c757d; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/assets/stylesheets/admins/video_apply.scss b/app/assets/stylesheets/admins/video_apply.scss
new file mode 100644
index 000000000..993ea1b8f
--- /dev/null
+++ b/app/assets/stylesheets/admins/video_apply.scss
@@ -0,0 +1,9 @@
+.admins-video-applies-index-page {
+ .video-applies-list-container {
+ span {
+ &.apply-status-agreed { color: #28a745; }
+ &.apply-status-refused { color: #dc3545; }
+ &.apply-status-processed { color: #6c757d; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/controllers/admins/project_package_applies_controller.rb b/app/controllers/admins/project_package_applies_controller.rb
new file mode 100644
index 000000000..12347d30c
--- /dev/null
+++ b/app/controllers/admins/project_package_applies_controller.rb
@@ -0,0 +1,37 @@
+class Admins::ProjectPackageAppliesController < Admins::BaseController
+ before_action :current_apply,only: [:agree,:refuse]
+
+ def index
+ params[:status] ||= 'pending'
+ status = params[:status]
+ if status == 'all'
+ status = %w(agreed refused)
+ end
+ package_applies = ProjectPackageApply.where(status: status)
+ keyword = params[:keyword].to_s.strip || ""
+ if keyword.present?
+ package_applies = package_applies.joins(:project_package).where("project_packages.title like ?","%#{keyword}%")
+ end
+ @package_applies = paginate package_applies.includes(project_package: { creator: :user_extension })
+ end
+
+ def agree
+ ProjectPackages::AgreeApplyService.new(current_apply).call
+ render_success_js
+ rescue ProjectPackages::AgreeApplyService::Error => e
+ render json: { status: -1, message: e.message }
+ end
+
+ def refuse
+ ProjectPackages::RefuseApplyService.new(current_apply, reason: params[:reason]).call
+ render_success_js
+ rescue ProjectPackages::RefuseApplyService::Error => e
+ render json: { status: -1, message: e.message }
+ end
+
+ private
+
+ def current_apply
+ @_current_apply ||= ProjectPackageApply.find(params[:id])
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/admins/video_applies_controller.rb b/app/controllers/admins/video_applies_controller.rb
new file mode 100644
index 000000000..2aef602a8
--- /dev/null
+++ b/app/controllers/admins/video_applies_controller.rb
@@ -0,0 +1,41 @@
+class Admins::VideoAppliesController < Admins::BaseController
+
+ def index
+ params[:status] ||= 'pending'
+ status = params[:status]
+ if status == 'all'
+ status = %w(agreed refused)
+ end
+
+ applies = VideoApply.where(status: status).order('video_applies.updated_at desc')
+
+ search = params[:keyword].to_s.strip
+ if search.present?
+ applies = applies.joins(:video)
+ .where('videos.title like :search', search: "%#{search}%")
+ end
+
+ @video_applies = paginate applies.includes(video: { user: :user_extension })
+ end
+
+ def agree
+ Videos::AgreeApplyService.new(current_video_apply, current_user).call
+ render_success_js
+ 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_success_js
+ 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
+end
+
diff --git a/app/views/admins/project_package_applies/index.html.erb b/app/views/admins/project_package_applies/index.html.erb
new file mode 100644
index 000000000..912ea3e59
--- /dev/null
+++ b/app/views/admins/project_package_applies/index.html.erb
@@ -0,0 +1,32 @@
+<% define_admin_breadcrumbs do %>
+ <% add_admin_breadcrumb('众包需求发布') %>
+<% end %>
+
+
+
+
+ <%= render(partial: 'admins/project_package_applies/shared/list', locals: { applies: @package_applies}) %>
+
+
+<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
\ No newline at end of file
diff --git a/app/views/admins/project_package_applies/index.js.erb b/app/views/admins/project_package_applies/index.js.erb
new file mode 100644
index 000000000..fe4d5c782
--- /dev/null
+++ b/app/views/admins/project_package_applies/index.js.erb
@@ -0,0 +1 @@
+$('.project-package-applies-list-container').html("<%= j( render partial: 'admins/project_package_applies/shared/list', locals: { applies: @package_applies } ) %>");
\ No newline at end of file
diff --git a/app/views/admins/project_package_applies/shared/_list.html.erb b/app/views/admins/project_package_applies/shared/_list.html.erb
new file mode 100644
index 000000000..30980d5e5
--- /dev/null
+++ b/app/views/admins/project_package_applies/shared/_list.html.erb
@@ -0,0 +1,56 @@
+<% is_processed = params[:status].to_s != 'pending' %>
+
+
+
+
+ 头像 |
+ 姓名 |
+ 众包需求 |
+ 需求描述 |
+ 时间 |
+ <% if is_processed %>
+ 拒绝原因 |
+ 状态 |
+ <% else %>
+ 操作 |
+ <% end %>
+
+
+
+ <% if applies.present? %>
+ <% applies.each do |apply| %>
+ <% package = apply.project_package %>
+ <% user = package.creator %>
+
+
+ <%= link_to "/users/#{user.login}", class: 'professional-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
+
+ <% end %>
+ |
+ <%= user.real_name %> |
+ <%= link_to package.title, "/crowdsourcing/#{package.id}", :target => "_blank" %> |
+ <%= overflow_hidden_span package.content[0..50] + "..."%> |
+ <%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %> |
+
+ <% if is_processed %>
+ <%= overflow_hidden_span apply.reason %> |
+ <%= t("admins_apply_status.status.#{apply.status}") %> |
+ <% else %>
+
+ <%= agree_link '同意', agree_admins_project_package_apply_path(apply, element: ".project_package_applies-#{apply.id}"), 'data-confirm': '确认审核通过?' %>
+ <%= javascript_void_link('拒绝', class: 'action refuse-action',
+ data: {
+ toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id,
+ url: refuse_admins_project_package_apply_path(apply, element: ".project_package_applies-#{apply.id}")
+ }) %>
+ |
+ <% end %>
+
+ <% end %>
+ <% else %>
+ <%= render 'admins/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>
\ 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 52bbaf76a..a0e26d84e 100644
--- a/app/views/admins/shared/_sidebar.html.erb
+++ b/app/views/admins/shared/_sidebar.html.erb
@@ -59,7 +59,10 @@
<%= sidebar_item(admins_shixun_authorizations_path, '实训发布', icon: 'object-ungroup', controller: 'admins-shixun_authorizations') %>
<%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %>
<%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %>
- <% end %>
+ <%= sidebar_item(admins_project_package_applies_path, '众包需求发布', icon: 'joomla', controller: 'admins-project_package_applies') %>
+ <%= sidebar_item(admins_video_applies_path, '视频发布', icon: 'film', controller: 'admins-video_applies') %>
+
+ <% end %>
<%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %>
diff --git a/app/views/admins/video_applies/index.html.erb b/app/views/admins/video_applies/index.html.erb
new file mode 100644
index 000000000..fcc2ad34c
--- /dev/null
+++ b/app/views/admins/video_applies/index.html.erb
@@ -0,0 +1,32 @@
+<% define_admin_breadcrumbs do %>
+ <% add_admin_breadcrumb('视频发布') %>
+<% end %>
+
+
+
+
+ <%= render(partial: 'admins/video_applies/shared/list', locals: { applies: @video_applies}) %>
+
+
+<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
\ No newline at end of file
diff --git a/app/views/admins/video_applies/index.js.erb b/app/views/admins/video_applies/index.js.erb
new file mode 100644
index 000000000..570f88c62
--- /dev/null
+++ b/app/views/admins/video_applies/index.js.erb
@@ -0,0 +1 @@
+$('.video-applies-list-container').html("<%= j( render partial: 'admins/video_applies/shared/list', locals: { applies: @video_applies } ) %>");
\ No newline at end of file
diff --git a/app/views/admins/video_applies/shared/_list.html.erb b/app/views/admins/video_applies/shared/_list.html.erb
new file mode 100644
index 000000000..ff9e0f06e
--- /dev/null
+++ b/app/views/admins/video_applies/shared/_list.html.erb
@@ -0,0 +1,56 @@
+<% is_processed = params[:status].to_s != 'pending' %>
+
+
+
+
+ 头像 |
+ 姓名 |
+ 视频名称 |
+ 播放链接 |
+ 时间 |
+ <% if is_processed %>
+ 拒绝原因 |
+ 状态 |
+ <% else %>
+ 操作 |
+ <% end %>
+
+
+
+ <% if applies.present? %>
+ <% applies.each do |v| %>
+ <% video = v.video %>
+ <% user = video.user %>
+
+
+ <%= link_to "/users/#{user.login}", class: 'professional-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
+
+ <% end %>
+ |
+ <%= user.real_name %> |
+ <%= link_to video.title, video.file_url, :target => "_blank" %> |
+ <%= link_to "播放视频",video.file_url, target: "_blank" %> |
+ <%= v.updated_at.strftime('%Y-%m-%d %H:%M') %> |
+
+ <% if is_processed %>
+ <%= overflow_hidden_span v.reason %> |
+ <%= t("admins_apply_status.status.#{v.status}") %> |
+ <% else %>
+
+ <%= agree_link '同意', agree_admins_video_apply_path(v, element: ".video_applies-#{v.id}"), 'data-confirm': '确认审核通过?' %>
+ <%= javascript_void_link('拒绝', class: 'action refuse-action',
+ data: {
+ toggle: 'modal', target: '.admin-common-refuse-modal', id: v.id,
+ url: refuse_admins_video_apply_path(v, element: ".video_applies-#{v.id}")
+ }) %>
+ |
+ <% end %>
+
+ <% end %>
+ <% else %>
+ <%= render 'admins/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>
\ No newline at end of file
diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml
index fcd92d851..f11271ff5 100644
--- a/config/locales/zh-CN.yml
+++ b/config/locales/zh-CN.yml
@@ -6,4 +6,11 @@ zh-CN:
button_test: 测试
button_edit: 编辑
- button_delete: 删除
\ No newline at end of file
+ button_delete: 删除
+
+ admins_apply_status:
+ status:
+ 'pending': '待审批'
+ 'processed': '已审批'
+ 'refused': '已拒绝'
+ 'agreed': '已同意'
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index a5d9905d0..c95cab648 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -804,6 +804,12 @@ Rails.application.routes.draw do
post :refuse
end
end
+ resources :video_applies, only: [:index] do
+ member do
+ post :agree
+ post :refuse
+ end
+ end
resources :identity_authentications, only: [:index] do
member do
post :agree
diff --git a/db/seeds.rb b/db/seeds.rb
index bc60c4ac6..c5169d6bb 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -15,4 +15,17 @@
# t.text :actual_output
#
# t.timestamps
-# end
\ No newline at end of file
+# end
+#
+
+# video_p = {
+# user_id: 1,
+# title: "第一个测试的.mp4",
+# uuid: "748fa8165062433781ccd87f1f815403",
+# cover_url: "http://outin-396971199eed11e991a100163e1c7426.oss-cn-shanghai.aliyuncs.com/sv/30ec9167-16ca9111f7d/30ec9167-16ca9111f7d.mp4",
+# file_url: "http://outin-396971199eed11e991a100163e1c7426.oss-cn-shanghai.aliyuncs.com/sv/30ec9167-16ca9111f7d/30ec9167-16ca9111f7d.mp4",
+# status: "pending",
+# vod_status: "uploaded",
+# published_at: nil,
+# filesize: 14877403
+# }
\ No newline at end of file