Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
	
		
	
				
					
				
			
						commit
						5782207a05
					
				| @ -0,0 +1,57 @@ | ||||
| $(document).on('turbolinks:load', function() { | ||||
|   if ($('body.admins-courses-index-page').length > 0) { | ||||
|     let searchContainer = $(".course-list-form"); | ||||
|     let searchForm = $("form.search-form",searchContainer); | ||||
| 
 | ||||
|     searchContainer.on('change', '.course-homepage-show', function(){ | ||||
|       searchForm.find('input[type="submit"]').trigger('click'); | ||||
|     }); | ||||
| 
 | ||||
|     //导出
 | ||||
|     searchContainer.on('click', "#course-export", function () { | ||||
|       window.location.href = "/admins/courses.xlsx?" + searchForm.serialize(); | ||||
|     }); | ||||
| 
 | ||||
|    $(".course-list-container").on("change", '.course-setting-form', function () { | ||||
|      var s_id = $(this).attr("data-id"); | ||||
|      var s_value = $(this).val(); | ||||
|      var s_name = $(this).attr("name"); | ||||
|      var json = {}; | ||||
|      json[s_name] = s_value; | ||||
|      $.ajax({ | ||||
|        url: "/admins/courses/" + s_id, | ||||
|        type: "PUT", | ||||
|        dataType:'script', | ||||
|        data: json | ||||
|      }); | ||||
|    }); | ||||
| 
 | ||||
|   // ************** 学校选择 *************
 | ||||
|   searchForm.find('.school-select').select2({ | ||||
|       theme: 'bootstrap4', | ||||
|       placeholder: '请选择单位', | ||||
|       minimumInputLength: 1, | ||||
|       ajax: { | ||||
|           delay: 500, | ||||
|           url: '/api/schools/search.json', | ||||
|           dataType: 'json', | ||||
|           data: function (params) { | ||||
|               return {keyword: params.term}; | ||||
|           }, | ||||
|           processResults: function (data) { | ||||
|               return {results: data.schools} | ||||
|           } | ||||
|       }, | ||||
|       templateResult: function (item) { | ||||
|           if (!item.id || item.id === '') return item.text; | ||||
|           return item.name; | ||||
|       }, | ||||
|       templateSelection: function (item) { | ||||
|           if (item.id) { | ||||
|           } | ||||
|           return item.name || item.text; | ||||
|       } | ||||
|   }); | ||||
|   } | ||||
| }); | ||||
| 
 | ||||
| @ -0,0 +1,60 @@ | ||||
| $(document).on('turbolinks:load', function() { | ||||
|   var $modal = $('.modal.admin-merge-course-list-modal'); | ||||
|   if ($modal.length > 0) { | ||||
|     var $form = $modal.find('form.admin-merge-course-list-form'); | ||||
|     var $originCourseListIdInput = $form.find('input[name="origin_course_list_id"]'); | ||||
| 
 | ||||
|     $form.validate({ | ||||
|       errorElement: 'span', | ||||
|       errorClass: 'danger text-danger', | ||||
|       rules: { | ||||
|           course_list_name: { | ||||
|           required: true | ||||
|         } | ||||
|       }, | ||||
|       messages: { | ||||
|           course_list_name: { | ||||
|           required: '请输入课程名称' | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
| 
 | ||||
|     // modal ready fire
 | ||||
|     $modal.on('show.bs.modal', function (event) { | ||||
|       var $link = $(event.relatedTarget); | ||||
| 
 | ||||
|       var couresListId = $link.data('courseListId'); | ||||
|       var url = $link.data('url'); | ||||
| 
 | ||||
|       $originCourseListIdInput.val(couresListId); | ||||
|       $form.data('url', url); | ||||
|     }); | ||||
| 
 | ||||
|     $modal.on('click', '.submit-btn', function(){ | ||||
|       $form.find('.error').html(''); | ||||
| 
 | ||||
|       if ($form.valid()) { | ||||
|         var url = $form.data('url'); | ||||
| 
 | ||||
|         $.ajax({ | ||||
|           method: 'POST', | ||||
|           dataType: 'json', | ||||
|           url: url, | ||||
|           data: $form.serialize(), | ||||
|           success: function(){ | ||||
|             $.notify({ message: '操作成功' }); | ||||
|             $modal.modal('hide'); | ||||
| 
 | ||||
|             setTimeout(function(){ | ||||
|               window.location.reload(); | ||||
|             }, 500); | ||||
|           }, | ||||
|           error: function(res){ | ||||
|             var data = res.responseJSON; | ||||
|             $form.find('.error').html(data.message); | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| }); | ||||
| @ -0,0 +1,35 @@ | ||||
| class Admins::CourseListsController < Admins::BaseController | ||||
| 
 | ||||
|   def index | ||||
|     course_lists = Admins::CourseListQuery.call(params) | ||||
|     @course_lists = paginate course_lists.preload(:courses, :user) | ||||
|     @params_page = params[:page] || 1 | ||||
|     respond_to do |format| | ||||
|       format.js | ||||
|       format.html | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def destroy | ||||
|     CourseList.find(params[:id]).destroy! | ||||
| 
 | ||||
|     render_delete_success | ||||
|   end | ||||
| 
 | ||||
|   def merge | ||||
|     origin_course_list = CourseList.find_by!(id: params[:origin_course_list_id]) | ||||
|     o_courselist = CourseList.find_by(name: params[:course_list_name]) | ||||
|     if o_courselist | ||||
|       origin_course_list.courses.each do |course| | ||||
|         course.update!(name: course.name.sub(origin_course_list.name, params[:course_list_name]), course_list_id: o_courselist.id) | ||||
|       end | ||||
|       origin_course_list.destroy | ||||
|     else | ||||
|       origin_course_list.courses.each do |course| | ||||
|         course.update!(name: course.name.sub(origin_course_list.name, params[:course_list_name])) | ||||
|       end | ||||
|       origin_course_list.update!(name: params[:course_list_name]) | ||||
|     end | ||||
|     render_ok | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,49 @@ | ||||
| class Admins::CoursesController < Admins::BaseController | ||||
|   before_action :find_course, except: [:index] | ||||
| 
 | ||||
|   def index | ||||
|     default_sort('created_at', 'desc') | ||||
| 
 | ||||
|     courses = Admins::CourseQuery.call(params) | ||||
|     @ended_courses = courses.where(is_end: 1).size | ||||
|     @processed_courses = courses.where(is_end: 0).size | ||||
|     @courses = paginate courses.includes(:school, :students, :attachments, :homework_commons, teacher: :user_extension) | ||||
| 
 | ||||
|     respond_to do |format| | ||||
|       format.js | ||||
|       format.html | ||||
|       format.xlsx do | ||||
|         @courses = courses.includes(:school, :students, :attachments, :homework_commons, :course_acts, teacher: :user_extension) | ||||
|         filename = "课堂列表_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx" | ||||
|         render xlsx: 'index', filename: filename | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def destroy | ||||
|     if @course.is_delete == 0 | ||||
|       @course.delete! | ||||
|       Tiding.create!(user_id: current_user.id, trigger_user_id: current_user.id, container_id: @course.id, | ||||
|                      container_type: 'DeleteCourse', tiding_type: 'System', belong_container: @course, extra: @course.name) | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def update | ||||
|     if @course.update_attributes(setting_params) | ||||
|       render_ok | ||||
|     else | ||||
|       redirect_to admins_courses_path | ||||
|       flash[:danger] = "更新失败" | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   private | ||||
| 
 | ||||
|   def find_course | ||||
|     @course = Course.find_by!(id: params[:id]) | ||||
|   end | ||||
| 
 | ||||
|   def setting_params | ||||
|     params.permit(:homepage_show, :email_notify) | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,25 @@ | ||||
| class Admins::ProjectsController < Admins::BaseController | ||||
| 
 | ||||
|   def index | ||||
|     default_sort('created_at', 'desc') | ||||
| 
 | ||||
|     search = params[:search].to_s.strip | ||||
|     projects = Project.where("name like ?", "%#{search}%") | ||||
|     @projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score) | ||||
|   end | ||||
| 
 | ||||
|   def destroy | ||||
|     project = Project.find_by!(id: params[:id]) | ||||
|     ActiveRecord::Base.transaction do | ||||
|       g = Gitlab.client | ||||
|       g.delete_project(project.gpid) | ||||
|       # 删除Trustie版本库记录 | ||||
|       repoisitory = Repository.where(project_id: project.id, type: "Repository::Gitlab").first | ||||
|       repoisitory.destroy! | ||||
|       Tiding.where(container_id: project.id, container_type: ["JoinProject", "DealProject", "ReporterJoinProject", "ManagerJoinProject"]).destroy_all | ||||
|       project.destroy! | ||||
|       render_delete_success | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
| end | ||||
| @ -0,0 +1,3 @@ | ||||
| class Version < ApplicationRecord | ||||
|   belongs_to :project | ||||
| end | ||||
| @ -0,0 +1,30 @@ | ||||
| class Admins::CourseListQuery < ApplicationQuery | ||||
|   include CustomSortable | ||||
| 
 | ||||
|   attr_reader :params | ||||
| 
 | ||||
|   sort_columns :created_at, default_by: :created_at, default_direction: :desc | ||||
| 
 | ||||
|   def initialize(params) | ||||
|     @params = params | ||||
|   end | ||||
| 
 | ||||
|   def call | ||||
|     course_lists = CourseList.all | ||||
| 
 | ||||
|     # 关键字模糊查询 | ||||
|     keyword = params[:keyword].to_s.strip | ||||
|     if keyword.present? | ||||
|       search_type = params[:search_type] || "0" | ||||
|       case search_type | ||||
|       when "0" | ||||
|         course_lists = course_lists.joins(:user) | ||||
|                       .where('CONCAT(lastname, firstname) like :keyword', keyword: "%#{keyword}%") | ||||
|       when "1" | ||||
|         course_lists = course_lists.where('name like :keyword', keyword: "%#{keyword}%") | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     custom_sort(course_lists, params[:sort_by], params[:sort_direction]) | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,44 @@ | ||||
| class Admins::CourseQuery < ApplicationQuery | ||||
|   include CustomSortable | ||||
| 
 | ||||
|   attr_reader :params | ||||
| 
 | ||||
|   sort_columns :created_at, default_by: :created_at, default_direction: :desc, default_table: 'courses' | ||||
| 
 | ||||
|   def initialize(params) | ||||
|     @params = params | ||||
|   end | ||||
| 
 | ||||
|   def call | ||||
|     courses = Course.all | ||||
| 
 | ||||
|     courses = courses.where(id: params[:id]) if params[:id].present? | ||||
| 
 | ||||
|     # 状态过滤 | ||||
|     status = | ||||
|       case params[:status].to_s.strip | ||||
|       when 'processing'   then 0 | ||||
|       when 'ended'  then 1 | ||||
|       end | ||||
|     courses = courses.where(is_end: status) if status | ||||
| 
 | ||||
|     # 单位 | ||||
|     if params[:school_id].present? | ||||
|       courses = courses.where(school_id: params[:school_id]) | ||||
|     end | ||||
| 
 | ||||
|     # 首页展示 | ||||
|     if params[:homepage_show].present? && params[:homepage_show].to_s == 'true' | ||||
|       courses = courses.where(homepage_show: true) | ||||
|     end | ||||
| 
 | ||||
|     # 关键字 | ||||
|     keyword = params[:keyword].to_s.strip | ||||
|     if keyword | ||||
|       sql = 'CONCAT(lastname, firstname) LIKE :keyword OR courses.name LIKE :keyword OR course_lists.name LIKE :keyword' | ||||
|       courses = courses.joins(:teacher, :course_list).where(sql, keyword: "%#{keyword}%") | ||||
|     end | ||||
| 
 | ||||
|     custom_sort(courses, params[:sort_by], params[:sort_direction]) | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,22 @@ | ||||
| <% define_admin_breadcrumbs do %> | ||||
|   <% add_admin_breadcrumb('课程列表') %> | ||||
| <% end %> | ||||
| 
 | ||||
| <div class="box search-form-container course-list-list-form"> | ||||
|   <%= form_tag(admins_course_lists_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> | ||||
|     <div class="form-group"> | ||||
|       <label>搜索类型:</label> | ||||
|       <% auto_trial_options = [['创建者姓名', 0], ['课程名称', 1]] %> | ||||
|       <%= select_tag(:search_type, options_for_select(auto_trial_options), class: 'form-control') %> | ||||
|     </div> | ||||
|     <%= 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': '搜索中...') %> | ||||
|     <%= link_to "清除",admins_course_lists_path,class: "btn btn-default",id:"course-lists-clear-search",'data-disable-with': '清除中...' %> | ||||
|   <% end %> | ||||
| </div> | ||||
| 
 | ||||
| <div class="box admin-list-container course-list-list-container"> | ||||
|   <%= render partial: 'admins/course_lists/shared/list', locals: { courses: @course_lists } %> | ||||
| </div> | ||||
| 
 | ||||
| <%= render 'admins/course_lists/shared/merge_course_list_modal' %> | ||||
| @ -0,0 +1 @@ | ||||
| $(".course-list-list-container").html("<%= j render partial: 'admins/course_lists/shared/list', locals: { courses: @course_lists }%>"); | ||||
| @ -0,0 +1,37 @@ | ||||
| <table class="table table-hover text-center shixuns-list-table"> | ||||
|   <thead class="thead-light"> | ||||
|   <th width="4%">序号</th> | ||||
|   <th width="8%">ID</th> | ||||
|   <th width="38%" class="text-left">课程名称</th> | ||||
|   <th width="10%">课堂数</th> | ||||
|   <th width="10%">创建者</th> | ||||
|   <th width="12%"><%= sort_tag('创建时间', name: 'created_at', path: admins_course_lists_path) %></th> | ||||
|   <th width="18%">操作</th> | ||||
|   </thead> | ||||
|   <tbody> | ||||
|   <% if courses.present? %> | ||||
|     <% courses.each_with_index do |course_list,index| %> | ||||
|       <tr id="course-list-item-<%= course_list.id %>"> | ||||
|         <td><%= list_index_no(@params_page.to_i, index) %></td> | ||||
|         <td><%= course_list.id %></td> | ||||
|         <td class="text-left"><%= course_list.name %></td> | ||||
|         <% course_count = course_list.courses.size %> | ||||
|         <td><%= course_count %></td> | ||||
|         <td><%= link_to course_list.user.try(:real_name),"/users/#{course_list.user.try(:login)}",target:'_blank' %></td> | ||||
|         <td><%= format_time course_list.created_at %></td> | ||||
|         <td class="operate"> | ||||
|           <% if course_count == 0 %> | ||||
|             <%= delete_link '删除', admins_course_list_path(course_list, element: ".course-list-item-#{course_list.id}"), class: 'delete-department-action' %> | ||||
|           <% end %> | ||||
|           <%= javascript_void_link '修改', class: 'action', data: { course_list_id: course_list.id, | ||||
|                                                                   toggle: 'modal', target: '.admin-merge-course-list-modal', url: merge_admins_course_lists_path } %> | ||||
|         </td> | ||||
|       </tr> | ||||
|     <% end %> | ||||
|   <% else %> | ||||
|     <%= render 'admins/shared/no_data_for_table' %> | ||||
|   <% end %> | ||||
|   </tbody> | ||||
| </table> | ||||
| 
 | ||||
| <%= render partial: 'admins/shared/paginate', locals: { objects: courses } %> | ||||
| @ -0,0 +1,29 @@ | ||||
| <div class="modal fade admin-merge-course-list-modal" tabindex="-1" role="dialog" aria-hidden="true"> | ||||
|   <div class="modal-dialog modal-dialog-centered" role="document"> | ||||
|     <div class="modal-content"> | ||||
|       <div class="modal-header"> | ||||
|         <h5 class="modal-title">修改课程</h5> | ||||
|         <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||||
|           <span aria-hidden="true">×</span> | ||||
|         </button> | ||||
|       </div> | ||||
|       <div class="modal-body"> | ||||
|         <form class="admin-merge-course-list-form" data-url="<%= merge_admins_course_lists_path %>"> | ||||
|           <%= hidden_field_tag(:origin_course_list_id, nil) %> | ||||
| 
 | ||||
|           <div class="form-group d-flex"> | ||||
|             <label for="course_list_id" class="col-form-label">更改为:</label> | ||||
|             <div class="d-flex flex-column-reverse w-75"> | ||||
|               <input id="course_list_name" name="course_list_name" placeholder="请输入课程名称" class="form-control"> | ||||
|             </div> | ||||
|           </div> | ||||
|           <div class="error text-danger"></div> | ||||
|         </form> | ||||
|       </div> | ||||
|       <div class="modal-footer"> | ||||
|         <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> | ||||
|         <button type="button" class="btn btn-primary submit-btn">确认</button> | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
| </div> | ||||
| @ -0,0 +1,2 @@ | ||||
| alert("删除成功"); | ||||
| $(".course-item-<%= @course.id %>").find(".delete-course-action").remove(); | ||||
| @ -0,0 +1,34 @@ | ||||
| <% define_admin_breadcrumbs do %> | ||||
|   <% add_admin_breadcrumb('课堂列表') %> | ||||
| <% end %> | ||||
| 
 | ||||
| <div class="box search-form-container course-list-form"> | ||||
|   <%= form_tag(admins_courses_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 = [['全部', ''], ["正在进行(#{@processed_courses})", 'processing'], ["已结束#{@ended_courses}", 'ended']] %> | ||||
|       <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="form-group col-12 col-md-3"> | ||||
|       <label for="school_name">单位:</label> | ||||
|       <%= select_tag :school_id, options_for_select([''], params[:school_id]), class: 'form-control school-select flex-1' %> | ||||
|     </div> | ||||
| 
 | ||||
|     <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-12 col-md-2 mr-3', placeholder: '创建者/课堂名称/课程名称检索') %> | ||||
| 
 | ||||
|     <div class="form-check mr-2"> | ||||
|       <%= hidden_field_tag(:homepage_show, false, id:'') %> | ||||
|       <%= check_box_tag(:homepage_show, true, params[:homepage_show].to_s == 'true', class: 'form-check-input course-homepage-show') %> | ||||
|       <label class="form-check-label" for="homepage_show">只看首页展示</label> | ||||
|     </div> | ||||
| 
 | ||||
|     <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> | ||||
|     <input type="reset" class="btn btn-secondary clear-btn" value="清空"/> | ||||
|   <% end %> | ||||
|   <a href="javascript:void(0)" class="btn btn-primary" id="course-export" data-disable-with = '导出中...'>导出</a> | ||||
| </div> | ||||
| 
 | ||||
| <div class="box admin-list-container course-list-container"> | ||||
|   <%= render partial: 'admins/courses/shared/list', locals: { courses: @courses } %> | ||||
| </div> | ||||
| @ -0,0 +1 @@ | ||||
| $('.course-list-container').html("<%= j( render partial: 'admins/courses/shared/list', locals: { courses: @courses } ) %>"); | ||||
| @ -0,0 +1,29 @@ | ||||
| wb = xlsx_package.workbook | ||||
| 
 | ||||
| wb.styles do |s| | ||||
|   blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center} | ||||
|   wb.add_worksheet(name: "课堂列表") do |sheet| | ||||
|     sheet.add_row %w(ID 课堂名称 成员 资源 普通作业 分组作业 实训作业 试卷 评测次数 私有 状态 单位 创建者 创建时间 动态时间), :height => 25,:style => blue_cell | ||||
| 
 | ||||
|     @courses.each do |course| | ||||
|       data = [ | ||||
|         course.id, | ||||
|         course.name, | ||||
|         course.course_members_count, | ||||
|         get_attachment_count(course, 0), | ||||
|         course.course_homework_count(1), | ||||
|         course.course_homework_count(3), | ||||
|         course.course_homework_count(4), | ||||
|         course.exercises_count, | ||||
|         course.evaluate_count, | ||||
|         course.is_public == 1 ? "--" : "√", | ||||
|         course.is_end ? "已结束" : "正在进行", | ||||
|         course.school&.name, | ||||
|         course.teacher&.real_name, | ||||
|         course.created_at&.strftime('%Y-%m-%d %H:%M'), | ||||
|         course.max_activity_time ? course.max_activity_time&.strftime('%Y-%m-%d %H:%M') : "--" | ||||
|       ] | ||||
|       sheet.add_row(data) | ||||
|     end | ||||
|   end | ||||
| end | ||||
| @ -0,0 +1,62 @@ | ||||
| <table class="table table-hover text-center subject-list-table"> | ||||
|   <thead class="thead-light"> | ||||
|   <tr> | ||||
|     <th width="4%">ID</th> | ||||
|     <th width="10%" class="text-left">课堂名称</th> | ||||
|     <th width="6%">成员</th> | ||||
|     <th width="4%">资源</th> | ||||
|     <th width="4%">普通作业</th> | ||||
|     <th width="4%">分组作业</th> | ||||
|     <th width="4%">实训作业</th> | ||||
|     <th width="4%">试卷</th> | ||||
|     <th width="7%">评测次数</th> | ||||
|     <th width="4%">私有</th> | ||||
|     <th width="6%">状态</th> | ||||
|     <th width="10%">单位</th> | ||||
|     <th width="7%">创建者</th> | ||||
|     <th width="10%"><%= sort_tag('创建时间', name: 'created_at', path: admins_courses_path) %></th> | ||||
|     <th width="4%">首页</th> | ||||
|     <th width="6%">邮件通知</th> | ||||
|     <th width="6%">操作</th> | ||||
|   </tr> | ||||
|   </thead> | ||||
|   <tbody> | ||||
|   <% if courses.present? %> | ||||
|     <% courses.each do |course| %> | ||||
|       <tr class="course-item-<%= course.id %>"> | ||||
|         <td><%= course.id %></td> | ||||
|         <td class="text-left"> | ||||
|           <%= link_to(course.name, "/courses/#{course.id}", target: '_blank') %> | ||||
|         </td> | ||||
|         <td><%= course.course_members_count %></td> | ||||
|         <td><%= get_attachment_count(course, 0) %></td> | ||||
|         <td><%= course.course_homework_count(1) %></td> | ||||
|         <td><%= course.course_homework_count(3) %></td> | ||||
|         <td><%= course.course_homework_count(4) %></td> | ||||
|         <td><%= course.exercises_count %></td> | ||||
|         <td><%= course.evaluate_count %></td> | ||||
|         <td><%= course.is_public == 1 ? "--" : "√" %></td> | ||||
|         <td><%= course.is_end ? "已结束" : "正在进行" %></td> | ||||
|         <td><%= course.school&.name %></td> | ||||
|         <td><%= course.teacher&.real_name %></td> | ||||
|         <td><%= course.created_at&.strftime('%Y-%m-%d %H:%M') %></td> | ||||
|         <td> | ||||
|           <%= check_box_tag :homepage_show,!course.homepage_show,course.homepage_show,remote:true,data:{id:course.id},class:"course-setting-form" %> | ||||
|         </td> | ||||
|         <td> | ||||
|           <%= check_box_tag :email_notify,!course.email_notify,course.email_notify,remote:true,data:{id:course.id},class:"course-setting-form" %> | ||||
|         </td> | ||||
|         <td class="action-container"> | ||||
|           <% if course.is_delete == 0 %> | ||||
|             <%= delete_link '删除', admins_course_path(course, element: ".course-item-#{course.id}"), class: 'delete-course-action' %> | ||||
|           <% end %> | ||||
|         </td> | ||||
|       </tr> | ||||
|     <% end %> | ||||
|   <% else %> | ||||
|     <%= render 'admins/shared/no_data_for_table' %> | ||||
|   <% end %> | ||||
|   </tbody> | ||||
| </table> | ||||
| 
 | ||||
| <%= render partial: 'admins/shared/paginate', locals: { objects: courses } %> | ||||
| @ -0,0 +1,2 @@ | ||||
| alert("删除成功"); | ||||
| $(".course-item-<%= @course.id %>").find(".delete-course-action").remove(); | ||||
| @ -0,0 +1,15 @@ | ||||
| <% define_admin_breadcrumbs do %> | ||||
|   <% add_admin_breadcrumb('项目列表') %> | ||||
| <% end %> | ||||
| 
 | ||||
| <div class="box search-form-container project-list-form"> | ||||
|   <%= form_tag(admins_projects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> | ||||
|     <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '项目名称检索') %> | ||||
|     <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> | ||||
|     <input type="reset" class="btn btn-secondary clear-btn" value="清空"/> | ||||
|   <% end %> | ||||
| </div> | ||||
| 
 | ||||
| <div class="box admin-list-container project-list-container"> | ||||
|   <%= render partial: 'admins/projects/shared/list', locals: { projects: @projects } %> | ||||
| </div> | ||||
| @ -0,0 +1 @@ | ||||
| $('.project-list-container').html("<%= j( render partial: 'admins/projects/shared/list', locals: { projects: @projects } ) %>"); | ||||
| @ -0,0 +1,48 @@ | ||||
| <table class="table table-hover text-center subject-list-table"> | ||||
|   <thead class="thead-light"> | ||||
|   <tr> | ||||
|     <th width="4%">ID</th> | ||||
|     <th width="15%" class="text-left">项目名称</th> | ||||
|     <th width="6%">公开</th> | ||||
|     <th width="5%">issue</th> | ||||
|     <th width="5%">资源</th> | ||||
|     <th width="6%">版本库</th> | ||||
|     <th width="8%">PullRequest</th> | ||||
|     <th width="6%">里程碑</th> | ||||
|     <th width="10%">成员</th> | ||||
|     <th width="10%">管理员</th> | ||||
|     <th width="15%"><%= sort_tag('创建时间', name: 'created_at', path: admins_projects_path) %></th> | ||||
|     <th width="10%">操作</th> | ||||
|   </tr> | ||||
|   </thead> | ||||
|   <tbody> | ||||
|   <% if projects.present? %> | ||||
|     <% projects.each do |project| %> | ||||
|       <tr class="project-item-<%= project.id %>"> | ||||
|         <td><%= project.id %></td> | ||||
|         <td class="text-left"> | ||||
|           <%= link_to(project.name, "/projects/#{project.id}", target: '_blank') %> | ||||
|         </td> | ||||
|         <td><%= project.is_public ? '√' : '' %></td> | ||||
|         <td><%= project.issues.size %></td> | ||||
|         <td><%= project.attachments.size %></td> | ||||
|         <td><%= project.project_score.try(:changeset_num).to_i %></td> | ||||
|         <td><%= project.project_score.try(:pull_request_num).to_i %></td> | ||||
|         <td><%= project.versions.size %></td> | ||||
|         <td><%= project.members.size %></td> | ||||
|         <td> | ||||
|           <%= project.owner ? link_to(project.owner&.real_name, "/users/#{project.owner&.login}", target: '_blank') : "" %> | ||||
|         </td> | ||||
|         <td><%= project.created_on&.strftime('%Y-%m-%d %H:%M') %></td> | ||||
|         <td class="action-container"> | ||||
|           <%= delete_link '删除', admins_project_path(project, element: ".project-item-#{project.id}"), class: 'delete-project-action' %> | ||||
|         </td> | ||||
|       </tr> | ||||
|     <% end %> | ||||
|   <% else %> | ||||
|     <%= render 'admins/shared/no_data_for_table' %> | ||||
|   <% end %> | ||||
|   </tbody> | ||||
| </table> | ||||
| 
 | ||||
| <%= render partial: 'admins/shared/paginate', locals: { objects: projects } %> | ||||
| @ -1,3 +1,3 @@ | ||||
| json.partial! 'attachments/attachment', attachment: @file | ||||
| # json.partial! "files/course_groups", attachment_group_settings: @file.attachment_group_settings | ||||
| json.partial! "files/course_groups", attachment_group_settings: @file.attachment_group_settings | ||||
| json.partial! "attachment_histories/list", attachment_histories: @attachment_histories | ||||
| After Width: | Height: | Size: 218 KiB | 
| @ -0,0 +1,5 @@ | ||||
| require 'rails_helper' | ||||
| 
 | ||||
| RSpec.describe Version, type: :model do | ||||
|   pending "add some examples to (or delete) #{__FILE__}" | ||||
| end | ||||
					Loading…
					
					
				
		Reference in new issue