commit
f6440a2c9c
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-abouts-edit-page, body.admins-abouts-update-page').length > 0) {
|
||||
createMDEditor('about-us-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-agreements-edit-page, body.admins-agreements-update-page').length > 0) {
|
||||
createMDEditor('agreement-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,6 @@
|
||||
|
||||
function show_add_manager(id) {
|
||||
$(".auth-schools-user-add").modal("show");
|
||||
|
||||
$(".auth-schools-user-add").find("#school_id_input").val(id)
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-cooperatives-index-page').length > 0) {
|
||||
// ------------ 保存链接 -----------
|
||||
$('.coo-img-card').on('click', '.save-url-btn', function(){
|
||||
var $link = $(this);
|
||||
var cooId = $link.data('id');
|
||||
var url = $('.coo-img-item-' + cooId).find('.url-input').val();
|
||||
$link.attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/cooperatives/' + cooId,
|
||||
method: 'PATCH',
|
||||
dataType: 'json',
|
||||
data: { url: url },
|
||||
success: function(data){
|
||||
$.notify({ message: '保存成功' });
|
||||
},
|
||||
error: ajaxErrorNotifyHandler,
|
||||
complete: function(){
|
||||
$link.removeAttr('disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// ------------ 拖拽 -------------
|
||||
var onDropFunc = function(el, _target, _source, sibling){
|
||||
var moveId = $(el).data('id');
|
||||
var insertId = $(sibling).data('id') || '';
|
||||
|
||||
$.ajax({
|
||||
url: '/admins/cooperatives/drag',
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
data: { move_id: moveId, after_id: insertId },
|
||||
success: function(data){
|
||||
},
|
||||
error: function(res){
|
||||
var data = res.responseJSON;
|
||||
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
|
||||
}
|
||||
})
|
||||
};
|
||||
var ele1 = document.getElementById('coo-img-container-alliance_coop');
|
||||
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
|
||||
var ele2 = document.getElementById('coo-img-container-com_coop');
|
||||
dragula([ele2], { mirrorContainer: ele2 }).on('drop', onDropFunc);
|
||||
var ele3 = document.getElementById('coo-img-container-edu_coop');
|
||||
dragula([ele3], { mirrorContainer: ele3 }).on('drop', onDropFunc);
|
||||
|
||||
|
||||
// ----------- 新增 --------------
|
||||
var $createModal = $('.modal.admin-add-cooperative-modal');
|
||||
var $createForm = $createModal.find('form.admin-add-cooperative-form');
|
||||
|
||||
$createForm.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"coo_img[image]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$createModal.on('show.bs.modal', function(event){
|
||||
resetFileInputFunc($createModal.find('.img-file-input'));
|
||||
$createModal.find('.file-names').html('选择文件');
|
||||
|
||||
var $link = $(event.relatedTarget);
|
||||
var imgType = $link.data('imgType');
|
||||
$createForm.find('input[name="coo_img[img_type]"]').val(imgType);
|
||||
});
|
||||
|
||||
$createModal.on('click', '.submit-btn', function() {
|
||||
$createForm.find('.error').html('');
|
||||
|
||||
if ($createForm.valid()) {
|
||||
$createForm.submit();
|
||||
} else {
|
||||
$createForm.find('.error').html('请选择图片');
|
||||
}
|
||||
});
|
||||
$createModal.on('change', '.img-file-input', function(){
|
||||
var file = $(this)[0].files[0];
|
||||
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||
})
|
||||
|
||||
// -------------- 重新上传图片 --------------
|
||||
//replace_image_url
|
||||
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
|
||||
var $cooImgItem = $('.coo-img-item-' + data.source_id);
|
||||
$.post('/admins/cooperatives/'+ data.source_id + '/replace_image_url');
|
||||
$cooImgItem.find('.coo-img-item-img img').attr('src', data.url);
|
||||
})
|
||||
}
|
||||
})
|
@ -1,22 +0,0 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $editModal = $('.department-apply-edit-modal');
|
||||
if($editModal.length > 0){
|
||||
var $form = $editModal.find('form.department-apply-form');
|
||||
var $applyIdInput = $form.find('input[name="id"]');
|
||||
$editModal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
var applyId = $link.data('id');
|
||||
$applyIdInput.val(applyId);
|
||||
});
|
||||
$editModal.on('click', '.submit-btn', function(){
|
||||
$.ajax({
|
||||
method: "PUT",
|
||||
dataType: 'script',
|
||||
url: "/admins/department_applies/"+ $applyIdInput.val(),
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$editModal.modal('hide');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,70 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-ec-templates-index-page').length > 0) {
|
||||
var add_modal = $(".ec-templates-new-add");
|
||||
var template_file_name = add_modal.find(".template-file-upload");
|
||||
var attachment_id_input = add_modal.find(".template_attachment_id");
|
||||
var template_container = $(".ec-templates-list-container");
|
||||
|
||||
//编辑附件
|
||||
template_container.on("click", ".edit-template-content", function () {
|
||||
var t_id = $(this).attr("data-id");
|
||||
var t_name = $(this).attr("data-name");
|
||||
var template_name = $(this).attr("data-template-name");
|
||||
var t_msg = $(this).attr("data-msg");
|
||||
var template_id = $(this).attr("data-template-id");
|
||||
add_modal.modal("show");
|
||||
add_modal.find(".template_add_title").html(t_msg);
|
||||
attachment_id_input.val(template_id);
|
||||
add_modal.find(".template_show_id").val(t_id);
|
||||
add_modal.find("input[name='name']").val(t_name);
|
||||
add_modal.find("i.delete-template-icon").attr("data-id", template_id);
|
||||
if(template_id !== "-1"){
|
||||
template_file_name.find("span.template-file-input").hide();
|
||||
template_file_name.find("span.template_file_show").show();
|
||||
template_file_name.find("span.template_file_show_title").html(template_name);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//删除附件
|
||||
add_modal.on("click",".delete-template-icon",function () {
|
||||
var attachment_id = $(this).attr("data-id");
|
||||
$.ajax({
|
||||
url: "/api/attachments/" + attachment_id,
|
||||
type: "delete",
|
||||
contentType:"application/json",
|
||||
dataType:"json",
|
||||
success: function (data) {
|
||||
template_file_name.find("span.template-file-input").show();
|
||||
template_file_name.find("span.template_file_show").hide();
|
||||
attachment_id_input.attr("value","-1")
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
//上传附件
|
||||
add_modal.on("change", "#upload_template_file",function () {
|
||||
|
||||
var template = document.getElementById('upload_template_file').files[0];
|
||||
|
||||
var file_content = new FormData();
|
||||
|
||||
file_content.append("file", template);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/api/attachments",
|
||||
data:file_content,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
template_file_name.find("span.template-file-input").hide();
|
||||
template_file_name.find("span.template_file_show").show();
|
||||
template_file_name.find("span.template_file_show_title").html(template.name);
|
||||
template_file_name.find("i.delete-template-icon").attr("data-id",data.id);
|
||||
attachment_id_input.val(data.id)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if($(".admins-graduation-standards-index-page").length > 0){
|
||||
$(".admin-body-container").on("click", ".standard-create-modal", function () {
|
||||
var content = $(this).attr("data-content");
|
||||
var g_id = $(this).attr("data-id");
|
||||
var g_msg = $(this).attr("data-msg");
|
||||
|
||||
$("#graduation-modal-type").html(g_msg);
|
||||
$("#graduation_standard_id").val(g_id);
|
||||
$("textarea[name='content']").val(content);
|
||||
})
|
||||
}
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-help-centers-edit-page, body.admins-help-centers-update-page').length > 0) {
|
||||
createMDEditor('help-center-editor', {});
|
||||
}
|
||||
})
|
@ -0,0 +1,13 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-major-informations-index-page').length > 0) {
|
||||
var box_contain = $(".major-informations-list-container");
|
||||
box_contain.on("click",".collapse-item",function () {
|
||||
var a_fa = $(this).find("i");
|
||||
if(a_fa.hasClass("fa-caret-right")){
|
||||
a_fa.removeClass("fa-caret-right").addClass("fa-caret-down");
|
||||
}else{
|
||||
a_fa.removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,66 @@
|
||||
.admins-auth-schools-index-page{
|
||||
.list-item-title{
|
||||
padding-bottom:5px;
|
||||
padding-left: 33px;
|
||||
color: #555;
|
||||
}
|
||||
.list-item-title-1{
|
||||
width: 100px;
|
||||
display: inline-block;
|
||||
}
|
||||
.list-item-title-2{
|
||||
width: 200px;
|
||||
display: inline-block;
|
||||
}
|
||||
.collegeManage{
|
||||
float: left;
|
||||
padding: 0px 8px;
|
||||
border-radius: 6px;
|
||||
background-color: #f5f5f5;
|
||||
margin: 3px 0px 3px 10px;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
a{
|
||||
color: #05101a;
|
||||
}
|
||||
a:hover{
|
||||
color: #007bff;
|
||||
}
|
||||
}
|
||||
i:hover{
|
||||
color: #333;
|
||||
}
|
||||
.add-manager-i{
|
||||
float: left;
|
||||
i{
|
||||
padding: 10px 5px;
|
||||
}
|
||||
}
|
||||
.auth-schools-new-add, .auth-schools-user-add{
|
||||
.flex-column{
|
||||
input{
|
||||
height: 38px;
|
||||
}
|
||||
}
|
||||
.search-school{
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
}
|
||||
.school-search-list{
|
||||
background: #F4FAFF;
|
||||
height: 280px;
|
||||
overflow-y: scroll;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.school-list-item{
|
||||
padding: 2px 10px;
|
||||
input{
|
||||
font-size: 20px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
.admins-cooperatives-index-page {
|
||||
.coo-img-card {
|
||||
.coo-img-item {
|
||||
& > .drag {
|
||||
cursor: move;
|
||||
background: #fff;
|
||||
box-shadow: 1px 2px 5px 3px #f0f0f0;
|
||||
}
|
||||
|
||||
&-img {
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
& > img {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 20px;
|
||||
color: red;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.save-url-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
.admins-ec-templates-index-page{
|
||||
.template-file-upload{
|
||||
padding: 10px;
|
||||
background: #fafafa;
|
||||
border: 1px dashed #ccc;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
input[name='file']{
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
left: 0;
|
||||
height: 43px;
|
||||
top: 0;
|
||||
width:100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
.admins-major-informations-index-page{
|
||||
.fr{
|
||||
float:right;
|
||||
}
|
||||
.panel-default{
|
||||
margin-bottom: 10px;
|
||||
background-color: rgb(245, 245, 245);
|
||||
.panel-heading{
|
||||
i{
|
||||
margin-right:15px;
|
||||
font-size:16px;
|
||||
color:rgb(204, 204, 204);
|
||||
}
|
||||
a{
|
||||
padding: 8px 10px;
|
||||
display: inline-block;
|
||||
width:100%;
|
||||
color:rgb(102, 102, 102);
|
||||
}
|
||||
}
|
||||
.panel-collapse{
|
||||
padding-top: 10px;
|
||||
background: #fff;
|
||||
table{
|
||||
text-align:center;
|
||||
th,td{
|
||||
padding: 8px;
|
||||
}
|
||||
td{
|
||||
color:#888;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the course_stages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,18 @@
|
||||
class Admins::AboutsController < Admins::BaseController
|
||||
def edit
|
||||
current_doc
|
||||
end
|
||||
|
||||
def update
|
||||
current_doc.update!(about_us: params[:about_us])
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_about_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_doc
|
||||
@doc ||= Help.first || Help.create
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
class Admins::AgreementsController < Admins::BaseController
|
||||
def edit
|
||||
current_doc
|
||||
end
|
||||
|
||||
def update
|
||||
current_doc.update!(agreement: params[:agreement])
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_agreement_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_doc
|
||||
@doc ||= Help.first || Help.create
|
||||
end
|
||||
end
|
@ -0,0 +1,58 @@
|
||||
class Admins::AuthSchoolsController < Admins::BaseController
|
||||
|
||||
def index
|
||||
schools = School.where(ec_auth: 1).includes(:users).order("updated_at desc")
|
||||
@params_page = params[:page] || 1
|
||||
@schools = paginate schools
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
school = School.where(id: params[:id]).first
|
||||
school.destroy
|
||||
render_success_js
|
||||
end
|
||||
end
|
||||
|
||||
# 工程认证单位列表搜索学校
|
||||
def search_school
|
||||
@schools = School.where("ec_auth != 1 and name like '%#{params[:name]}%'").limit(10)
|
||||
end
|
||||
|
||||
# 添加认证学校
|
||||
def add_school
|
||||
all_schools = School.all
|
||||
all_schools.where(id: params[:school_id]).update_all(ec_auth: 1)
|
||||
schools = all_schools.where(ec_auth: 1).order("updated_at desc")
|
||||
@params_page = params[:page] || 1
|
||||
@schools = paginate schools
|
||||
end
|
||||
|
||||
# 搜索用户
|
||||
def search_manager
|
||||
school = School.find_by(id: params[:school_id])
|
||||
user_ids = school&.ec_school_users&.pluck(:user_id)
|
||||
@users = User.where.not(id: user_ids).where("concat(lastname, firstname) like ?", "%#{params[:name].strip.to_s}%").limit(10)
|
||||
end
|
||||
|
||||
# 添加认证学校管理员
|
||||
def add_manager
|
||||
ActiveRecord::Base.transaction do
|
||||
user_ids = params[:user_id]
|
||||
@school_id = params[:school_id]
|
||||
user_ids.each do |id|
|
||||
EcSchoolUser.create(user_id: id, school_id: @school_id)
|
||||
end
|
||||
@school_users = User.where(id: user_ids)
|
||||
end
|
||||
end
|
||||
|
||||
# 删除学校管理员
|
||||
def remove_manager
|
||||
ActiveRecord::Base.transaction do
|
||||
manager = EcSchoolUser.where(school_id: params[:school_id], user_id: params[:user_id]).first
|
||||
manager&.destroy
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
class Admins::ContactUsController < Admins::BaseController
|
||||
def edit
|
||||
@cooperations = Cooperation.all.group(:user_type)
|
||||
@help = Help.first
|
||||
end
|
||||
|
||||
def update
|
||||
cooperation = Cooperation.find(params[:id])
|
||||
cooperation.update!(update_cooperation_params)
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_contact_us_path
|
||||
end
|
||||
|
||||
def update_address
|
||||
help = Help.first || Help.create
|
||||
help.update!(status: params.dig('help', 'status'))
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_contact_us_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_cooperation_params
|
||||
params.require(:cooperation).permit(:name, :qq, :mail)
|
||||
end
|
||||
end
|
@ -0,0 +1,84 @@
|
||||
class Admins::CooperativesController < Admins::BaseController
|
||||
before_action :convert_file!, only: [:create]
|
||||
|
||||
def index
|
||||
@data = { 'alliance_coop' => [], 'com_coop' => [], 'edu_coop' => [] }
|
||||
@data = @data.merge CooImg.all.group_by(&:img_type)
|
||||
end
|
||||
|
||||
def create
|
||||
position = CooImg.where(img_type: create_params[:img_type]).count + 1
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
coo = CooImg.create!(create_params.merge(position: position))
|
||||
|
||||
file_path = Util::FileManage.disk_filename('CooImg', coo.id)
|
||||
File.delete(file_path) if File.exist?(file_path) # 删除之前的文件
|
||||
Util.write_file(@file, file_path)
|
||||
|
||||
coo.update!(url_states: Util::FileManage.disk_file_url('CooImg', coo.id))
|
||||
end
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to admins_cooperatives_path
|
||||
end
|
||||
|
||||
def update
|
||||
current_coo.update!(src_states: params[:url])
|
||||
render_ok
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
current_coo.destroy!
|
||||
# 前移
|
||||
CooImg.where(img_type: current_coo.img_type).where('position > ?', current_coo.position)
|
||||
.update_all('position = position - 1')
|
||||
|
||||
file_path = Util::FileManage.disk_filename('CooImg', current_coo.id)
|
||||
File.delete(file_path) if File.exist?(file_path)
|
||||
end
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
def drag
|
||||
move = CooImg.find_by(id: params[:move_id])
|
||||
after = CooImg.find_by(id: params[:after_id])
|
||||
|
||||
Admins::DragCooperativeService.call(move, after)
|
||||
render_ok
|
||||
rescue Admins::DragCooperativeService::Error => e
|
||||
render_error(e.message)
|
||||
end
|
||||
|
||||
def replace_image_url
|
||||
current_coo.update!(url_states: Util::FileManage.disk_file_url('CooImg', current_coo.id))
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_coo
|
||||
@_current_coo ||= CooImg.find(params[:id])
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:coo_img).permit(:img_type, :src_states)
|
||||
end
|
||||
|
||||
def convert_file!
|
||||
max_size = 10 * 1024 * 1024 # 10M
|
||||
file = params.dig('coo_img', 'image')
|
||||
if file.class == ActionDispatch::Http::UploadedFile
|
||||
@file = file
|
||||
render_error('请上传文件') if @file.size.zero?
|
||||
render_error('文件大小超过限制') if @file.size > max_size
|
||||
else
|
||||
file = file.to_s.strip
|
||||
return render_error('请上传正确的图片') if file.blank?
|
||||
@file = Util.convert_base64_image(file, max_size: max_size)
|
||||
end
|
||||
rescue Base64ImageConverter::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
@ -0,0 +1,41 @@
|
||||
class Admins::EcTemplatesController < Admins::BaseController
|
||||
|
||||
def index
|
||||
@params_page = params[:page] || 1
|
||||
templates = EcTemplate.where(nil).includes(:attachments).order("updated_at desc")
|
||||
@templates = paginate templates
|
||||
end
|
||||
|
||||
def create_template
|
||||
ActiveRecord::Base.transaction do
|
||||
if params[:template_id] == "-1"
|
||||
ec_template = EcTemplate.new(name: params[:name])
|
||||
ec_template.save
|
||||
else
|
||||
ec_template = EcTemplate.find_by(id: params[:template_id])
|
||||
end
|
||||
|
||||
if params[:attachment_id] != "-1"
|
||||
attachment_id = params[:attachment_id]
|
||||
attachment_tem = Attachment.find_by(id: attachment_id)
|
||||
|
||||
unless attachment_tem.container_id.present? && attachment_tem.container_id == ec_template&.id
|
||||
attachment_tem.update_attributes(container_id: ec_template&.id, container_type: "EcTemplate")
|
||||
end
|
||||
end
|
||||
|
||||
@params_page = params[:page] || 1
|
||||
templates = EcTemplate.where(nil).includes(:attachments).order("updated_at desc")
|
||||
@templates = paginate templates
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
template = EcTemplate.find_by(id: params[:id])
|
||||
template.destroy
|
||||
render_success_js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
class Admins::GraduationStandardsController < Admins::BaseController
|
||||
|
||||
def index
|
||||
standards = EcGraduationStandard.all.order("updated_at desc")
|
||||
@params_page = params[:page] || 1
|
||||
@standards = paginate standards
|
||||
end
|
||||
|
||||
def create_standard
|
||||
ActiveRecord::Base.transaction do
|
||||
if params[:graduation_id] == "-1"
|
||||
content = params[:content]
|
||||
EcGraduationStandard.create(:content => content)
|
||||
else
|
||||
graduation = EcGraduationStandard.find_by(id: params[:graduation_id])
|
||||
graduation.update_attribute(:content, params[:content])
|
||||
end
|
||||
|
||||
standards = EcGraduationStandard.all.order("updated_at desc")
|
||||
@params_page = params[:page] || 1
|
||||
@standards = paginate standards
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
@graduation = EcGraduationStandard.find_by(id: params[:id])
|
||||
@graduation.destroy
|
||||
render_success_js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
class Admins::HelpCentersController < Admins::BaseController
|
||||
def edit
|
||||
current_doc
|
||||
end
|
||||
|
||||
def update
|
||||
current_doc.update!(help_center: params[:help_center])
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_help_center_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_doc
|
||||
@doc ||= Help.first || Help.create
|
||||
end
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
class Admins::MajorInformationsController < Admins::BaseController
|
||||
|
||||
def index
|
||||
disciplines = EcDiscipline.includes(ec_discipline_firsts: {ec_majors: :schools}).order("ec_disciplines.code asc")
|
||||
@disciplines = paginate disciplines
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,122 @@
|
||||
class Admins::UnitAppliesController < Admins::BaseController
|
||||
before_action :get_apply,only: [:agree,:destroy,:edit,:update]
|
||||
|
||||
def index
|
||||
params[:sort_by] ||= 'created_at'
|
||||
params[:sort_direction] ||= 'desc'
|
||||
unit_applies = Admins::UnitApplyQuery.call(params)
|
||||
@unit_applies = paginate unit_applies.preload(:school, :user)
|
||||
end
|
||||
|
||||
def agree
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
@unit_apply.update_attribute("status",1)
|
||||
@unit_apply&.applied_messages&.update_all(status:1)
|
||||
@unit_apply&.school&.update_attribute("province",@unit_apply.province)
|
||||
|
||||
# #申请信息的创建
|
||||
apply_message_params = {
|
||||
user_id: @unit_apply&.user_id,
|
||||
status: 1,
|
||||
viewed: 0,
|
||||
applied_id: @unit_apply.school_id,
|
||||
applied_type: "ApplyAddSchools",
|
||||
name: @unit_apply.name,
|
||||
}
|
||||
AppliedMessage.new(apply_message_params).save(validate: false)
|
||||
|
||||
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
|
||||
#消息的创建
|
||||
tiding_params = {
|
||||
user_id: @unit_apply.user_id,
|
||||
trigger_user_id: 0,
|
||||
container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools',
|
||||
belong_container_id: @unit_apply.school_id,
|
||||
belong_container_type: "School",
|
||||
tiding_type: "System",
|
||||
status: 1
|
||||
}
|
||||
Tiding.create(tiding_params)
|
||||
render_success_js
|
||||
rescue Exception => e
|
||||
Rails.logger.info("############_________________#########{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
Admins::DeleteUnitApplyService.call(@unit_apply, params)
|
||||
render_success_js
|
||||
end
|
||||
|
||||
def edit
|
||||
@all_schools = School.where.not(id: @unit_apply.school_id).pluck("name","id")
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
school = School.find_by(id: params[:school_id])
|
||||
ActiveRecord::Base.transaction do
|
||||
@unit_apply&.applied_messages&.update_all(status:4)
|
||||
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
|
||||
|
||||
#消息的创建
|
||||
tiding_params = {
|
||||
user_id: @unit_apply.user_id,
|
||||
trigger_user_id: 0,
|
||||
container_id: @unit_apply.id,
|
||||
container_type: 'ApplyAddSchools',
|
||||
belong_container_id: params[:school_id],
|
||||
belong_container_type: "School",
|
||||
tiding_type: "System",
|
||||
status: 3,
|
||||
extra: school.try(:name).to_s
|
||||
}
|
||||
Tiding.create(tiding_params)
|
||||
|
||||
UserExtension.where(school_id: @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
|
||||
ApplyAddDepartment.where(:school_id => @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
|
||||
|
||||
# 判断重复
|
||||
before_apply_departments = Department.where(school_id: @unit_apply.school_id)
|
||||
before_apply_departments.each do |department|
|
||||
after_dep = Department.where(school_id: params[:school_id].to_i, name: department.name)&.first
|
||||
if after_dep.present?
|
||||
UserExtension.where(school_id: @unit_apply.school_id, department_id: department.id).update_all(department_id: after_dep.id)
|
||||
department.destroy
|
||||
department.apply_add_departments.destroy_all
|
||||
else
|
||||
department.apply_add_departments.update_all(school_id: school.id)
|
||||
department.update_attribute(:school_id, school.id)
|
||||
end
|
||||
end
|
||||
|
||||
@unit_apply&.school&.destroy
|
||||
apply_params = {
|
||||
status: 2,
|
||||
name: school&.name.to_s,
|
||||
school_id: params[:school_id],
|
||||
province: params[:province],
|
||||
city: params[:city],
|
||||
address: params[:address]
|
||||
}
|
||||
@unit_apply.update_attributes(apply_params)
|
||||
# render_success_js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_apply
|
||||
@unit_apply = ApplyAddSchool.find_by(id:params[:id])
|
||||
end
|
||||
|
||||
def disk_auth_filename(source_type, source_id, type)
|
||||
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,105 @@
|
||||
class CourseStagesController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :find_course, only: [:create]
|
||||
before_action :find_course_stage, only: [:update, :destroy, :edit, :up_position, :down_position]
|
||||
before_action :user_course_identity, :teacher_allowed
|
||||
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
@stage = CourseStage.new(stage_params)
|
||||
@stage.course_id = @course.id
|
||||
@stage.position = @course.course_stages.count + 1
|
||||
@stage.save!
|
||||
unless params[:shixun_id].blank?
|
||||
shixuns = Shixun.where(id: params[:shixun_id]).order("field(id, #{params[:shixun_id].join(",")})")
|
||||
shixuns.each do |shixun|
|
||||
CourseStageShixun.create!(course_stage_id: @stage.id, course_id: @course.id, shixun_id: shixun.id, position: @stage.course_stage_shixuns.count + 1)
|
||||
end
|
||||
end
|
||||
normal_status("创建成功")
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
@stage.update_attributes!(stage_params)
|
||||
@stage.course_stage_shixuns.destroy_all
|
||||
unless params[:shixun_id].blank?
|
||||
params[:shixun_id].each do |shixun_id|
|
||||
shixun = Shixun.where(id: shixun_id).first
|
||||
@stage.course_stage_shixuns.create!(course_id: @course.id, shixun_id: shixun.id, position: @stage.course_stage_shixuns.count + 1) if shixun.present?
|
||||
end
|
||||
end
|
||||
normal_status("更新成功")
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
@course.course_stages.where("position > ?", @stage.position).update_all("position = position - 1")
|
||||
@stage.destroy!
|
||||
normal_status("删除成功")
|
||||
end
|
||||
end
|
||||
|
||||
def up_position
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
position = @stage.position
|
||||
tip_exception("第一章不能向上移动") if @stage.position == 1
|
||||
pre_stage = @course.course_stages.where(position: position - 1).first
|
||||
pre_stage.update_attributes(position: position)
|
||||
@stage.update_attributes(position: position - 1)
|
||||
normal_status("更新成功")
|
||||
rescue Exception => e
|
||||
uid_logger("stage up failed: #{e.message}")
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down_position
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
position = @stage.position
|
||||
rails "最后一章不能向下移动" if @stage.position == @course.course_stages.count
|
||||
next_stage = @course.course_stages.where(position: position + 1).first
|
||||
next_stage.update_attributes(position: position)
|
||||
@stage.update_attributes(position: position + 1)
|
||||
normal_status("更新成功")
|
||||
rescue Exception => e
|
||||
uid_logger("stage up failed: #{e.message}")
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_course_stage
|
||||
@stage = CourseStage.find_by!(id: params[:id])
|
||||
@course = @stage.course
|
||||
end
|
||||
|
||||
def stage_params
|
||||
tip_exception("章节名称不能为空") if params[:name].blank?
|
||||
params.permit(:name, :description)
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,44 @@
|
||||
class HelpsController < ApplicationController
|
||||
before_action :require_login, only: [:feedback]
|
||||
|
||||
helper_method :current_help
|
||||
|
||||
def about
|
||||
render_ok(content: current_help&.about_us)
|
||||
end
|
||||
|
||||
def contact
|
||||
@cooperations = Cooperation.all.group(:user_type)
|
||||
end
|
||||
|
||||
def cooperatives
|
||||
@data = { 'alliance_coop' => [], 'com_coop' => [], 'edu_coop' => [] }
|
||||
@data = @data.merge CooImg.all.group_by(&:img_type)
|
||||
end
|
||||
|
||||
def agreement
|
||||
render_ok(content: current_help&.agreement)
|
||||
end
|
||||
|
||||
def help_center
|
||||
render_ok(content: current_help&.help_center)
|
||||
end
|
||||
|
||||
def feedback
|
||||
content = "<p>[#{params[:question_kind]}]</p><p>问题页面网址:#{params[:url]}</p>#{params[:description]}"
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
attr = { sender_id: User.current.id, receiver_id: 1, content: content, send_time: Time.now }
|
||||
PrivateMessage.create!(attr.merge(user_id: User.current.id, target_id: 1, status: 1))
|
||||
PrivateMessage.create!(attr.merge(user_id: 1, target_id: User.current.id, status: 0))
|
||||
end
|
||||
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_help
|
||||
@_current_help ||= Help.first
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
class ShixunListsController < ApplicationController
|
||||
def index
|
||||
@results = ShixunSearchService.call(search_params)
|
||||
end
|
||||
|
||||
private
|
||||
def search_params
|
||||
params.permit(:keyword, :type, :page, :limit, :order, :type, :status, :diff)
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module CourseStagesHelper
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class CooImg < ApplicationRecord
|
||||
extend Enumerize
|
||||
|
||||
enumerize :img_type, in: %i[com_coop edu_coop alliance_coop]
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class Cooperation < ApplicationRecord
|
||||
def user_type_text
|
||||
case user_type.to_i
|
||||
when 1 then '高校合作'
|
||||
when 2 then '企业合作'
|
||||
when 3 then '实训投稿'
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
class CourseStage < ApplicationRecord
|
||||
belongs_to :course
|
||||
|
||||
has_many :course_stage_shixuns, -> { order("course_stage_shixuns.position ASC") }, dependent: :destroy
|
||||
has_many :shixuns, :through => :course_stage_shixuns
|
||||
|
||||
validates :name, length: { maximum: 60 }
|
||||
validates :description, length: { maximum: 300 }
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class CourseStageShixun < ApplicationRecord
|
||||
belongs_to :course
|
||||
belongs_to :course_stage, counter_cache: :shixuns_count
|
||||
belongs_to :shixun
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class EcDiscipline < ActiveRecord::Base
|
||||
validates_presence_of :code, :name
|
||||
|
||||
has_many :ec_discipline_firsts
|
||||
|
||||
# 专业数目
|
||||
def major_count
|
||||
count = 0
|
||||
self.ec_discipline_firsts.map{|f| count += f.ec_majors.count}
|
||||
count
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class EcDisciplineFirst < ActiveRecord::Base
|
||||
validates_presence_of :code, :name
|
||||
|
||||
has_many :ec_majors
|
||||
belongs_to :ec_discipline
|
||||
end
|
@ -1,7 +1,10 @@
|
||||
class EcMajor < ApplicationRecord
|
||||
# 主页对应的学校,不同学校可以选用同样的专业,而每个专业又各具特色
|
||||
has_many :schools, through: :ec_major_schools
|
||||
has_many :ec_major_schools, dependent: :destroy
|
||||
has_many :schools, through: :ec_major_schools
|
||||
|
||||
# 一级专业
|
||||
belongs_to :ec_discipline_first
|
||||
|
||||
scope :search_name_or_code, -> (keyword) { where('name LIKE :keyword OR code LIKE :keyword', keyword: "%#{keyword.strip}%") }
|
||||
end
|
||||
|
@ -0,0 +1,6 @@
|
||||
class EcTemplate < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
# acts_as_attachable
|
||||
has_many :attachments, as: :container
|
||||
|
||||
end
|
@ -0,0 +1,3 @@
|
||||
class Help < ApplicationRecord
|
||||
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
class ShixunSecretRepository < ApplicationRecord
|
||||
# repo_name: 仓库名
|
||||
# secret_dir_name: 在tpm仓库的那个目录下
|
||||
|
||||
belongs_to :shixun
|
||||
|
||||
def repo_path
|
||||
"#{repo_name}.git"
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class ShixunWorkComment < ApplicationRecord
|
||||
belongs_to :student_work
|
||||
belongs_to :user
|
||||
belongs_to :challenge, optional: true
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue