实训编程流程问题

dev_jupyter
daiao 5 years ago
parent 3c206b52e3
commit e9ce9ad97c

@ -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

@ -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?

@ -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

@ -6,7 +6,7 @@
<%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-1">
<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') %>
</div>

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