From e9ce9ad97c234185a032324eab4d6dcbfb3c6153 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 20 Feb 2020 20:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E7=BC=96=E7=A8=8B=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/admins/subjects_helper.rb | 15 +++++++++++++-- app/queries/admins/subject_query.rb | 14 ++++++++------ app/services/search_service.rb | 2 +- app/views/admins/subjects/index.html.erb | 2 +- config/locales/subjects/zh-CN.yml | 7 ++++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/helpers/admins/subjects_helper.rb b/app/helpers/admins/subjects_helper.rb index b2c1dbd55..236bf723f 100644 --- a/app/helpers/admins/subjects_helper.rb +++ b/app/helpers/admins/subjects_helper.rb @@ -1,11 +1,22 @@ module Admins::SubjectsHelper def display_subject_status(subject) style = - case subject.status + case subject.public when 0 then 'text-secondary' when 1 then 'text-warning' when 2 then 'text-success' end - raw content_tag(:span, t("subject.public.#{subject.public}"), class: style) + + status = + if subject.public == 2 + "publiced" + elsif subject.public == 1 + "pending" + elsif subject.status == 2 + "processed" + else + "editing" + end + raw content_tag(:span, t("subject.public.#{status}"), class: style) end end \ No newline at end of file diff --git a/app/queries/admins/subject_query.rb b/app/queries/admins/subject_query.rb index ba410312f..dc459885b 100644 --- a/app/queries/admins/subject_query.rb +++ b/app/queries/admins/subject_query.rb @@ -16,12 +16,14 @@ class Admins::SubjectQuery < ApplicationQuery # 状态过滤 status = - case params[:status].to_s.strip - when 'pending' then 0 - when 'applying' then 1 - when 'published' then 2 - end - subjects = subjects.where(public: status) if status + case params[:status].to_s.strip + when "editing" then {status: 0} + when "processed" then {status: 2, public: 0} + when "pending" then {public: 1} + when "publiced" then {public: 2} + end + + subjects = subjects.where(status) if status # 创建者单位 if params[:school_id].present? diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 72cd49c14..703f6dc1a 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -42,7 +42,7 @@ class SearchService < ApplicationService { where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns)).pluck(:id) } } when 'subject' then { where: { id: Laboratory.current.subjects.where(public: 2, status: 2) - .or( Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns).pluck(:id)) } } + .or( Laboratory.current.subjects.where(status: 2, id: User.current.subjects).pluck(:id)) } } when 'course' then { where: { id: Laboratory.current.all_courses.pluck(:id) } } else diff --git a/app/views/admins/subjects/index.html.erb b/app/views/admins/subjects/index.html.erb index 8b5569761..39c4a349b 100644 --- a/app/views/admins/subjects/index.html.erb +++ b/app/views/admins/subjects/index.html.erb @@ -6,7 +6,7 @@ <%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
- <% status_options = [['全部', ''], ['编辑中', 'pending'], ['审核中', 'applying'], ['已发布', 'published']] %> + <% status_options = [['全部', ''], ["编辑中", "editing"], ["已发布", 'processed'], ["待审核", 'pending'], ["已公开", 'publiced']] %> <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
diff --git a/config/locales/subjects/zh-CN.yml b/config/locales/subjects/zh-CN.yml index 55d3dd9c0..fa560a930 100644 --- a/config/locales/subjects/zh-CN.yml +++ b/config/locales/subjects/zh-CN.yml @@ -5,6 +5,7 @@ '1': 审核中 '2': 已发布 public: - '0': 编辑中 - '1': 审核中 - '2': 已发布 \ No newline at end of file + 'editing': 编辑中 + 'processed': 已发布未审核 + 'pending': 审核中 + 'publiced': 已发布 \ No newline at end of file