实训编程流程问题

dev_jupyter
daiao 6 years ago
parent 3c206b52e3
commit e9ce9ad97c

@ -1,11 +1,22 @@
module Admins::SubjectsHelper module Admins::SubjectsHelper
def display_subject_status(subject) def display_subject_status(subject)
style = style =
case subject.status case subject.public
when 0 then 'text-secondary' when 0 then 'text-secondary'
when 1 then 'text-warning' when 1 then 'text-warning'
when 2 then 'text-success' when 2 then 'text-success'
end 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
end end

@ -17,11 +17,13 @@ class Admins::SubjectQuery < ApplicationQuery
# 状态过滤 # 状态过滤
status = status =
case params[:status].to_s.strip case params[:status].to_s.strip
when 'pending' then 0 when "editing" then {status: 0}
when 'applying' then 1 when "processed" then {status: 2, public: 0}
when 'published' then 2 when "pending" then {public: 1}
when "publiced" then {public: 2}
end end
subjects = subjects.where(public: status) if status
subjects = subjects.where(status) if status
# 创建者单位 # 创建者单位
if params[:school_id].present? if params[:school_id].present?

@ -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) } } { 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 when 'subject' then
{ where: { id: Laboratory.current.subjects.where(public: 2, status: 2) { 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 when 'course' then
{ where: { id: Laboratory.current.all_courses.pluck(:id) } } { where: { id: Laboratory.current.all_courses.pluck(:id) } }
else else

@ -6,7 +6,7 @@
<%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> <%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-1"> <div class="form-group mr-1">
<label for="status">状态:</label> <label for="status">状态:</label>
<% status_options = [['全部', ''], ['编辑中', 'pending'], ['审核中', 'applying'], ['已发布', 'published']] %> <% status_options = [['全部', ''], ["编辑中", "editing"], ["已发布", 'processed'], ["待审核", 'pending'], ["已公开", 'publiced']] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %> <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
</div> </div>

@ -5,6 +5,7 @@
'1': 审核中 '1': 审核中
'2': 已发布 '2': 已发布
public: public:
'0': 编辑中 'editing': 编辑中
'1': 审核中 'processed': 已发布未审核
'2': 已发布 'pending': 审核中
'publiced': 已发布
Loading…
Cancel
Save