From 828ac000e09686ff800257de16ed2ed24f227c88 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 09:11:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=90=88=E4=BD=9C=E4=BC=99=E4=BC=B4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 38 +++++++++ app/controllers/poll_controller.rb | 8 +- app/helpers/poll_helper.rb | 8 +- app/models/customer.rb | 2 +- app/views/courses/index.js.erb | 2 +- .../managements/_partner_addUnit.html.erb | 80 ++++++++++++------- .../managements/_profession_index.html.erb | 14 ++-- app/views/managements/partners.html.erb | 3 +- config/routes.rb | 2 + ...20180920093851_create_graduation_group.rb} | 0 lib/dalli-2.7.2/.rakeTasks | 4 +- lib/gitlab-cli/.rakeTasks | 4 +- lib/grack/.rakeTasks | 4 +- lib/grape-swagger-0.25.3/.rakeTasks | 4 +- lib/plugins/acts-as-taggable-on/.rakeTasks | 4 +- lib/rails_kindeditor/.rakeTasks | 4 +- lib/wechat/.rakeTasks | 4 +- 17 files changed, 122 insertions(+), 63 deletions(-) rename db/migrate/{20180920093851_create_graduation_groups.rb => 20180920093851_create_graduation_group.rb} (100%) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9a42aae4..95bf2f58 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,8 +1175,46 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school) + @schools = School.where("partner_id IS NULL").all + @page = (params['page'] || 1).to_i + @schools_count = @schools.count + @limit = 10 + @is_remote = true + @schools_pages = Paginator.new @schools_count, @limit, @page + @offset ||=@schools_pages.offset + @schools = paginateHelper @schools, @limit + end + + def all_partners + @schools = School.where("partner_id IS NULL").all + @page = (params['page'] || 1).to_i + @schools_count = @schools.count + @limit = 10 + @is_remote = true + @schools_pages = Paginator.new @schools_count, @limit, @page + @offset ||=@schools_pages.offset + @schools = paginateHelper @schools, @limit + render :json => @schools + end + + + def add_partner + school_ids = params[:ids] + if school_ids.count > 0 + print school_ids + school_ids.each do |s| + school = School.where("id = ?",s).first + @partner = Partner.new(name: school.name) + @partner.save + school.partner_id = @partner.id + school.save + end + render :json => {status: 1, message: "创建成功!"} + end end + + # 删除部门管理员 def delete_depart_member DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 78fb4a63..367b3e99 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -9,6 +9,7 @@ class PollController < ApplicationController before_filter :require_login, :only => [:student_poll_list, :show] include PollHelper include ApplicationHelper + def index if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 @@ -18,13 +19,13 @@ class PollController < ApplicationController if @is_teacher polls = @course.polls.order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") - elsif User.current.member_of_course?(@course) + elsif User.current.member_of_course?(@course) # 课堂成员显示为发布的和已发布的 member = @course.members.where(:user_id => User.current.id).first if member.try(:course_group_id).to_i == 0 polls = @course.polls.where("publish_time <= '#{Time.now}' and unified_setting = 1").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") - else + else # 已分班的成员 not_poll_ids = @course.poll_group_settings.where("course_group_id = #{member.try(:course_group_id)} and (publish_time > '#{Time.now}' or publish_time is null)") - not_poll_ids = not_poll_ids.blank? ? "(-1)" : "(" + not_poll_ids.map(&:poll_id).join(",") + ")" + not_poll_ids = not_poll_ids.blank? ? "(-1)" : "(" + not_poll_ids.map(&:poll_id).join(",") + ")" # 已分班,但是成员不再 polls = @course.polls.where("publish_time <= '#{Time.now}' and id not in #{not_poll_ids}").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") end else @@ -414,7 +415,6 @@ class PollController < ApplicationController def update_poll_question @poll_question = PollQuestion.find params[:poll_question] @poll = @poll_question.poll - @poll_question.is_necessary = params[:is_necessary] == "1" ? 1 : 0 @poll_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] @poll_question.max_choices = params[:max_choices].to_i || 0 @poll_question.min_choices = params[:min_choices].to_i || 0 diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 411fc3c3..1ac26aa6 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -20,11 +20,11 @@ module PollHelper def un_commit_num poll course = poll.course - member = course.members.where(:user_id => User.current.id).first - poll_users = poll.poll_users - student_count = course.student.count + member = course.members.where(:user_id => User.current.id).first ## 当前用户是否为课堂成员 + poll_users = poll.poll_users # 问卷的全部用户,包含已回答的/为回答,但是浏览的 + student_count = course.student.count # 课堂的学生数 if member.present? && member.teacher_course_groups.count > 0 - group_students = course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) + group_students = course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) ## 统计当前用户所在班级的全部学生 student_count = group_students.size poll_users = poll_users.where(:user_id => group_students) end diff --git a/app/models/customer.rb b/app/models/customer.rb index dab10ac9..bbfe45c6 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,5 @@ class Customer < ActiveRecord::Base belongs_to :partner - has_one :scholl + has_one :school has_many :users end diff --git a/app/views/courses/index.js.erb b/app/views/courses/index.js.erb index 7ed24fff..f211e3ae 100644 --- a/app/views/courses/index.js.erb +++ b/app/views/courses/index.js.erb @@ -1 +1 @@ -$("#intelligence_course_list").html("<%= j(render :partial => "courses/courseList") %>"); \ No newline at end of file +$("#intelligence_course_list").html("<%= j(render :partial => "courses/courseList") %>"); diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index 1001d32c..e18890dc 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -1,7 +1,7 @@
添加合作伙伴
-
+
地区: @@ -14,42 +14,26 @@
搜索
-
+

单位 地区

-

- - - - - - - 湖南 -

-

- - - - - - - 湖南 -

-

- - - - - - - 湖南 -

+

+
+
+
    + <%= pagination_links_full @schools_pages, @schools_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> +
+
+
+
+
+
  • 取消 确定 @@ -60,12 +44,46 @@ $(function() { unitDownOption(); showprovince("province"); - }) + get_schools() + + }); + function get_schools() { + $.getJSON("/managements/all_partners",function(schools){ + let s_html = ""; + $.each(schools,function (index,array) { + s_html =s_html+ "

    " + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " "+array["school"]["province"]+"" + + "

    " + }) + $("#serch_user_list").html(s_html) + }) + } function submit_add_partner(){ - if($("input[name='user_id[]']:checked").length==0){ + if($("input[name='school[id]']:checked").length==0){ $("#checkNotice").html("请选择需要添加的内容").removeClass("none"); return; + }else{ + let checked_array = []; + $("input[name='school[id]']:checked").each(function () { + checked_array.push($(this).val()) + }); + let check_ids = {ids:checked_array}; + $.ajax({ + url: "/managements/add_partner", + type: 'POST', + data: check_ids, + success: function (e) { + if(e.status === 1){} + $("#popupAll").remove() + } + }) } } \ No newline at end of file diff --git a/app/views/managements/_profession_index.html.erb b/app/views/managements/_profession_index.html.erb index 668aa0f1..f8f906b3 100644 --- a/app/views/managements/_profession_index.html.erb +++ b/app/views/managements/_profession_index.html.erb @@ -37,13 +37,13 @@ <%= format_time career.created_at %> <%= format_time career.published_at %> - <% if !career.status %> - 发布 - <% end %> - 编辑 - <% if !career.status %> - 删除 - <% end %> + <%# if !career.status %> + + <%# end %> + + <%# if !career.status %> + + <%# end %> <% end %> \ No newline at end of file diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index 049f1fdd..1d39b899 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -9,7 +9,7 @@ +添加
  • @@ -66,6 +66,7 @@ }) $(".manageList").on("click",".addManage",function(){ + var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; pop_box_new(html,572,500); }) diff --git a/config/routes.rb b/config/routes.rb index 57410238..f254f9b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -554,6 +554,8 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'import_departments' match 'departments', :via => [:get, :post] get 'partners' + get 'all_partners' + post 'add_partner' delete 'delete_depart_member' get 'add_depart_member_box' post 'add_depart_member' diff --git a/db/migrate/20180920093851_create_graduation_groups.rb b/db/migrate/20180920093851_create_graduation_group.rb similarity index 100% rename from db/migrate/20180920093851_create_graduation_groups.rb rename to db/migrate/20180920093851_create_graduation_group.rb diff --git a/lib/dalli-2.7.2/.rakeTasks b/lib/dalli-2.7.2/.rakeTasks index b6b932e2..c6865d9a 100644 --- a/lib/dalli-2.7.2/.rakeTasks +++ b/lib/dalli-2.7.2/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/gitlab-cli/.rakeTasks b/lib/gitlab-cli/.rakeTasks index afa9557a..f349995e 100644 --- a/lib/gitlab-cli/.rakeTasks +++ b/lib/gitlab-cli/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/grack/.rakeTasks b/lib/grack/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/grack/.rakeTasks +++ b/lib/grack/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/grape-swagger-0.25.3/.rakeTasks b/lib/grape-swagger-0.25.3/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/grape-swagger-0.25.3/.rakeTasks +++ b/lib/grape-swagger-0.25.3/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/plugins/acts-as-taggable-on/.rakeTasks b/lib/plugins/acts-as-taggable-on/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/plugins/acts-as-taggable-on/.rakeTasks +++ b/lib/plugins/acts-as-taggable-on/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/rails_kindeditor/.rakeTasks b/lib/rails_kindeditor/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/rails_kindeditor/.rakeTasks +++ b/lib/rails_kindeditor/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/wechat/.rakeTasks b/lib/wechat/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/wechat/.rakeTasks +++ b/lib/wechat/.rakeTasks @@ -1,7 +1,7 @@ - + +--> From 7af1176280371fb76a5ff91807d473f7ad2281f8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 09:26:46 +0800 Subject: [PATCH 2/2] partners --- app/controllers/managements_controller.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 95bf2f58..3259c66b 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,24 +1175,28 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school) - @schools = School.where("partner_id IS NULL").all - @page = (params['page'] || 1).to_i - @schools_count = @schools.count - @limit = 10 - @is_remote = true - @schools_pages = Paginator.new @schools_count, @limit, @page - @offset ||=@schools_pages.offset - @schools = paginateHelper @schools, @limit end def all_partners + @search = params[:search] + @province = params[:province] @schools = School.where("partner_id IS NULL").all + + + if params[:search] + @schools = @schools.where("name like ?", "%#{@search}%") + end + + if params[:province] + @schools = @schools.where("province like ?", "%#{@province}%") + end + @page = (params['page'] || 1).to_i @schools_count = @schools.count + @total_pages = (@schools_count / 10.0).ceil @limit = 10 @is_remote = true @schools_pages = Paginator.new @schools_count, @limit, @page - @offset ||=@schools_pages.offset @schools = paginateHelper @schools, @limit render :json => @schools end