Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
690d346ed6
@ -0,0 +1,4 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-schools-index-page').length > 0) {
|
||||
}
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
.admins-schools-index-page {
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
class Admins::SchoolsController < Admins::BaseController
|
||||
def index
|
||||
params[:sort_by] ||= 'created_at'
|
||||
params[:sort_direction] ||= 'desc'
|
||||
|
||||
schools = Admins::SchoolQuery.call(params)
|
||||
|
||||
@schools = paginate schools
|
||||
|
||||
school_ids = @schools.map(&:id)
|
||||
@department_count = Department.where(school_id: school_ids).group(:school_id).count
|
||||
end
|
||||
|
||||
def destroy
|
||||
users = User.joins(:user_extension).where(user_extensions: { school_id: current_school.id })
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
users.update_all(profile_completed: false)
|
||||
current_school.destroy!
|
||||
end
|
||||
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_school
|
||||
@_current_school ||= School.find(params[:id])
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class Ecs::GraduationSubitemsController < Ecs::BaseController
|
||||
def index
|
||||
subitems = current_year.ec_graduation_subitems.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC')
|
||||
@graduation_subitems = subitems.includes(:ec_graduation_requirement)
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
class Ecs::UsersController < Ecs::BaseController
|
||||
skip_before_action :check_user_permission!
|
||||
before_action :check_manager_permission!
|
||||
|
||||
def index
|
||||
users = UserQuery.call(params)
|
||||
|
||||
@count = users.count
|
||||
@users = paginate users.includes(user_extension: [:school, :department])
|
||||
@manager_ids = current_major_school.ec_major_school_users.pluck(:user_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_major_school
|
||||
@_ec_major_school ||= EcMajorSchool.find(params[:ec_major_school_id])
|
||||
end
|
||||
|
||||
def current_school
|
||||
@_current_school ||= current_major_school.school
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
module Ecs::EcYearsHelper
|
||||
def achieved_graduation_course_count(ec_year)
|
||||
return 0 if ec_year.ec_courses.count.zero?
|
||||
|
||||
course_ids = ec_year.ec_courses.map(&:id)
|
||||
target_count_map = EcCourseTarget.where(ec_course_id: course_ids).group(:ec_course_id).count
|
||||
|
||||
ec_year.ec_courses.sum { |course| course.complete_target_count == target_count_map[course.id] ? 1 : 0 }
|
||||
end
|
||||
|
||||
def achieved_graduation_objective_count(ec_year)
|
||||
return 0 if ec_year.ec_graduation_subitems.count.zero?
|
||||
|
||||
subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id)
|
||||
|
||||
relations = EcGraduationRequirementCalculation.joins(:ec_course_support).where(ec_course_supports: { ec_graduation_subitem_id: subitem_ids })
|
||||
|
||||
reached_map = relations.where(status: true).group('ec_graduation_subitem_id').count
|
||||
|
||||
reached_map.keys.size
|
||||
end
|
||||
end
|
@ -1,7 +1,6 @@
|
||||
class EcCourseStudentScore < ApplicationRecord
|
||||
belongs_to :ec_year_student
|
||||
belongs_to :ec_course
|
||||
belongs_to :ec_course_target
|
||||
|
||||
has_many :ec_student_score_targets, dependent: :delete_all
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
class Admins::SchoolQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :users_count, :created_at, default_by: :created_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
schools = School.all
|
||||
|
||||
keyword = strip_param(:keyword)
|
||||
schools = schools.where('schools.name LIKE ?', "%#{keyword}%") if keyword
|
||||
|
||||
schools = schools.joins(:user_extensions).group(:id)
|
||||
schools = schools.select('schools.*, COUNT(*) AS users_count')
|
||||
|
||||
custom_sort schools, params[:sort_by], params[:sort_direction]
|
||||
end
|
||||
end
|
@ -1,3 +1,9 @@
|
||||
class ApplicationQuery
|
||||
include Callable
|
||||
|
||||
private
|
||||
|
||||
def strip_param(key)
|
||||
params[key].to_s.strip.presence
|
||||
end
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
class UserQuery < ApplicationQuery
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
users = User.where(type: 'User')
|
||||
|
||||
# 真实姓名
|
||||
if name = strip_param(:name)
|
||||
users = users.where('LOWER(CONCAT(users.lastname, users.firstname)) LIKE ?', "%#{name.downcase}%")
|
||||
end
|
||||
|
||||
# 单位名称
|
||||
if school = strip_param(:school)
|
||||
users = users.joins(user_extension: :school).where('schools.name LIKE ?', "%#{school}%")
|
||||
end
|
||||
|
||||
# 职业
|
||||
if (identity = strip_param(:identity)) && UserExtension.identities.keys.include?(identity)
|
||||
users = users.joins(:user_extension).where(user_extensions: { identity: identity })
|
||||
end
|
||||
|
||||
users
|
||||
end
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('单位列表') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container school-list-form">
|
||||
<%= form_tag(admins_schools_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '部门名称检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
|
||||
<%#= javascript_void_link '新建单位', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-school-modal' } %>
|
||||
</div>
|
||||
|
||||
<div class="box school-list-container">
|
||||
<%= render partial: 'admins/schools/shared/list', locals: { schools: @schools } %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.school-list-container').html("<%= j(render partial: 'admins/schools/shared/list', locals: { schools: @schools }) %>");
|
@ -0,0 +1,48 @@
|
||||
<table class="table table-hover text-center school-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="6%">ID</th>
|
||||
<th width="6%">LOGO</th>
|
||||
<th width="8%">标识码</th>
|
||||
<th width="14%" class="text-left">单位名称</th>
|
||||
<th width="6%">地区</th>
|
||||
<th width="6%">城市</th>
|
||||
<th width="16%">详细地址</th>
|
||||
<th width="6%"><%= sort_tag('用户数', name: 'users_count', path: admins_schools_path) %></th>
|
||||
<th width="6%">部门数</th>
|
||||
<th width="12%"><%= sort_tag('创建时间', name: 'created_at', path: admins_schools_path) %></th>
|
||||
<th width="14%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if schools.present? %>
|
||||
<% schools.each do |school| %>
|
||||
<tr class="school-item-<%= school.id %>">
|
||||
<td><%= school.id %></td>
|
||||
<td>
|
||||
<% if Util::FileManage.exists?(school) %>
|
||||
<%= image_tag(Util::FileManage.source_disk_file_url(school).to_s + "?#{Time.now.to_i}", width: 40, height: 40, class: 'preview-image') %>
|
||||
<% else %>
|
||||
<%= content_tag(:span, '--', class: 'text-secondary') %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= display_text school.identifier %></td>
|
||||
<td class="text-left"><%= school.name %></td>
|
||||
<td><%= school.province %></td>
|
||||
<td><%= school.city %></td>
|
||||
<td class="text-left"><%= school.address %></td>
|
||||
<td><%= school.users_count %></td>
|
||||
<td><%= @department_count.fetch(school.id, 0) %></td>
|
||||
<td><%= school.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
<td>
|
||||
<%= delete_link '删除', admins_school_path(school, element: ".school-item-#{school.id}"), class: 'delete-school-action' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: schools } %>
|
@ -1 +1 @@
|
||||
json.course_evaluations @course_evaluations, partial: 'shared/ec_course_evaluation', as: :ec_course_evaluation
|
||||
json.course_evaluations @course_evaluations, partial: 'ecs/course_evaluations/shared/ec_course_evaluation', as: :ec_course_evaluation
|
||||
|
@ -1 +1 @@
|
||||
json.partial! 'shared/ec_course_evaluation', ec_course_evaluation: @course_evaluation
|
||||
json.partial! 'ecs/course_evaluations/shared/ec_course_evaluation', ec_course_evaluation: @course_evaluation
|
||||
|
@ -1 +1 @@
|
||||
json.course_evaluations @course_evaluations, partial: 'shared/ec_course_evaluation_slim', as: :ec_course_evaluation
|
||||
json.course_evaluations @course_evaluations, partial: 'ecs/course_evaluations/shared/ec_course_evaluation_slim', as: :ec_course_evaluation
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
json.course_targets @course_targets, partial: 'shared/course_target', as: :ec_course_target
|
||||
json.course_targets @course_targets, partial: 'ecs/course_targets/shared/course_target', as: :ec_course_target
|
||||
|
@ -1,2 +1,2 @@
|
||||
json.count @count
|
||||
json.ec_courses @ec_courses, partial: 'shared/ec_course_slim', as: :ec_course
|
||||
json.ec_courses @ec_courses, partial: 'ecs/ec_courses/shared/ec_course_slim', as: :ec_course
|
@ -1,3 +1,3 @@
|
||||
|
||||
json.count @graduation_requirements.size
|
||||
json.graduation_requirements @graduation_requirements, partial: 'shared/ec_graduation_requirement', as: :ec_graduation_requirement
|
||||
json.graduation_requirements @graduation_requirements, partial: '/ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement
|
||||
|
@ -1,2 +1,2 @@
|
||||
|
||||
json.partial! 'shared/ec_graduation_requirement', ec_graduation_requirement: @graduation_requirement
|
||||
json.partial! 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', ec_graduation_requirement: @graduation_requirement
|
||||
|
@ -0,0 +1,6 @@
|
||||
json.extract! @major, :id, :code, :name, :template_major
|
||||
json.school_id @major.school.id
|
||||
json.school_name @major.school.name
|
||||
|
||||
can_manager = @major.manager?(current_user) || @major.school.manager?(current_user) || current_user.admin_or_business?
|
||||
json.can_manager can_manager
|
@ -1,2 +1,7 @@
|
||||
json.count @count
|
||||
json.es_majors @ec_majors, partial: 'ecs/majors/shared/ec_major', as: :ec_major
|
||||
json.ec_majors do
|
||||
json.array! @ec_majors.each do |major|
|
||||
json.extract! major, :id, :name, :code
|
||||
json.selected @major_ids.include?(major.id)
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,3 @@
|
||||
json.extract! ec_training_objective, :id, :content
|
||||
|
||||
json.ec_training_items ec_training_objective.ec_training_subitems, partial: 'ec_training_subitem', as: :ec_training_subitem
|
||||
json.ec_training_items ec_training_objective.ec_training_subitems, partial: '/ecs/ec_training_objectives/shared/ec_training_subitem', as: :ec_training_subitem
|
||||
|
@ -1 +1 @@
|
||||
json.partial! 'shared/ec_training_objective', ec_training_objective: @training_objective
|
||||
json.partial! '/ecs/ec_training_objectives/shared/ec_training_objective', ec_training_objective: @training_objective
|
||||
|
@ -0,0 +1,13 @@
|
||||
json.extract! @year, :id, :year
|
||||
|
||||
major = @year.ec_major_school
|
||||
json.major_id major.id
|
||||
json.major_name major.name
|
||||
json.major_code major.code
|
||||
|
||||
school = major.school
|
||||
json.school_id school.id
|
||||
json.school_name school.name
|
||||
|
||||
can_manager = major.manager?(current_user) || school.manager?(current_user) || current_user.admin_or_business?
|
||||
json.can_manager can_manager
|
@ -1 +1 @@
|
||||
json.partial! 'shared/ec_graduation_subitem', ec_graduation_subitem: @graduation_subitem
|
||||
json.partial! 'ecs/graduation_course_supports/shared/ec_graduation_subitem', ec_graduation_subitem: @graduation_subitem
|
||||
|
@ -1,3 +1,3 @@
|
||||
json.course_count @course_count
|
||||
json.graduation_subitems @graduation_subitems, partial: 'shared/ec_graduation_subitem', as: :ec_graduation_subitem
|
||||
json.graduation_subitems @graduation_subitems, partial: 'ecs/graduation_course_supports/shared/ec_graduation_subitem', as: :ec_graduation_subitem
|
||||
json.count @graduation_subitems.size
|
||||
|
@ -0,0 +1,8 @@
|
||||
json.graduation_subitems do
|
||||
json.array! @graduation_subitems do |graduation_subitem|
|
||||
json.extract! graduation_subitem, :id, :position, :content
|
||||
json.graduation_requirement_position graduation_subitem.ec_graduation_requirement.position
|
||||
end
|
||||
end
|
||||
|
||||
json.count @graduation_subitems.size
|
@ -1 +0,0 @@
|
||||
json.partial! 'ecs/shared/user', user: @user
|
@ -1,4 +1,4 @@
|
||||
|
||||
json.graduation_requirements @graduation_requirements, partial: 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement
|
||||
json.training_subitems @training_subitems, partial: 'ecs/ec_training_subitems/shared/ec_training_subitem', as: :ec_training_subitem
|
||||
json.requirement_support_objectives @requirement_support_objectives, partial: 'shared/requirement_support_objective', as: :requirement_support_objective
|
||||
json.requirement_support_objectives @requirement_support_objectives, partial: 'ecs/requirement_support_objectives/shared/requirement_support_objective', as: :requirement_support_objective
|
||||
|
@ -1 +1 @@
|
||||
json.score_levels @score_levels, partial: 'shared/ec_score_level', as: :ec_score_level
|
||||
json.score_levels @score_levels, partial: 'ecs/score_levels/shared/ec_score_level', as: :ec_score_level
|
||||
|
@ -1,2 +1,2 @@
|
||||
json.count @count
|
||||
json.students @students, partial: 'shared/ec_year_student', as: :ec_year_student
|
||||
json.students @students, partial: 'ecs/students/shared/ec_year_student', as: :ec_year_student
|
@ -1,4 +1,4 @@
|
||||
|
||||
json.graduation_standards @graduation_standards, partial: 'ecs/shared/ec_graduation_standard', as: :ec_graduation_standard
|
||||
json.graduation_subitems @graduation_subitems, partial: 'ecs/shared/ec_graduation_subitem', as: :ec_graduation_subitem
|
||||
json.subitem_support_standards @subitem_support_standards, partial: 'shared/subitem_support_standard', as: :subitem_support_standard
|
||||
json.subitem_support_standards @subitem_support_standards, partial: 'ecs/subitem_support_standards/shared/subitem_support_standard', as: :subitem_support_standard
|
||||
|
@ -0,0 +1,12 @@
|
||||
json.count @count
|
||||
json.users do
|
||||
json.array! @users.each do |user|
|
||||
json.id user.id
|
||||
json.name user.real_name
|
||||
json.identity user.identity
|
||||
json.school_name user.school_name
|
||||
json.department_name user.department_name
|
||||
json.phone Util.conceal(user.phone, :phone)
|
||||
json.manager @manager_ids.include?(user.id)
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue