From cbb648dd402b90c87deded756903fd1d9cf7c76b Mon Sep 17 00:00:00 2001 From: XuCheng642 <287102909@qq.com> Date: Fri, 29 Sep 2017 16:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8E=88=E6=9D=83=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 135 +++++++++- app/models/apply_action.rb | 1 - app/models/school.rb | 2 +- app/views/layouts/base_management.html.erb | 6 +- .../_add_auto_users_trial.html.erb | 91 +++++++ .../_auto_users_authorization_list.html.erb | 14 +- .../managements/_leave_message_list.html.erb | 4 +- .../managements/add_departments_part.html.erb | 70 ++++- .../managements/auto_users_trial.html.erb | 8 +- .../managements/departments_part.html.erb | 1 - .../identity_authentication.html.erb | 2 +- .../reject_authentication_pro.js.erb | 1 + app/views/managements/update_user.html.erb | 249 +++++++++++++----- app/views/my/account.js.erb | 1 - app/views/shixuns/_shixun_top.html.erb | 11 +- config/routes.rb | 4 + .../20170926012936_add_auto_users_trial.rb | 21 ++ public/stylesheets/css/edu-common.css | 9 +- public/stylesheets/css/project.css | 4 +- 19 files changed, 522 insertions(+), 112 deletions(-) create mode 100644 app/views/managements/_add_auto_users_trial.html.erb create mode 100644 app/views/managements/reject_authentication_pro.js.erb create mode 100644 db/migrate/20170926012936_add_auto_users_trial.rb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 32010e53f..8a7630134 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -7,6 +7,80 @@ class ManagementsController < ApplicationController include UsersHelper include ApplicationHelper + #用户修改 + def account + @user = User.find(params[:user_id]) + ue = @user.user_extensions + # @trail_authentication = ApplyAction.where(:user_id => @user.id, :container_type => "TrialAuthorization").order("created_at desc").first + # @authentication = @user.authentication + # if @user.nickname.nil? || @user.lastname.nil? || ue.try(:identity).nil? || ue.try(:location).nil? || ue.try(:location).nil? + # @require_auth = true + # else + # if User.current.certification != 1 && (@trail_authentication.blank? || (@trail_authentication.status == 2 && (@trail_authentication.updated_at.to_i + 5*60) < Time.now.to_i)) + # @require_trail_auth = true + # end + # end + # @s_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').first + # @d_message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').first + + # AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddSchools').update_all(:viewed => true) + # AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0, :applied_type => 'ApplyAddDepartment').update_all(:viewed => true) + + lg = @user.login + @pref = @user.pref + diskfile = disk_filename('User', @user.id) + diskfile1 = diskfile + 'temp' + begin + if request.post? + @user.nickname = params[:nickname] + @user.lastname = params[:lastname] + @user.firstname = "" + @user.show_realname = params[:show_realname] ? 0 : 1 + @user.pref.attributes = params[:pref] + @user.mail = params[:mail] + @user.phone = params[:phone] + @user.password = params[:new_password] + @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') + @se = @user.extensions + @se.school_id = params[:occupation] + @se.department_id = params[:department_id] + @se.gender = params[:sex] + @se.location = params[:province] if params[:province] + @se.location_city = params[:city] if params[:city] + @se.identity = params[:identity].to_i if params[:identity] + if @se.identity == 0 + @se.technical_title = params[:te_technical_title] if params[:te_technical_title] + @se.student_id = nil + elsif @se.identity == 1 + @se.student_id = params[:no] if params[:no] + @se.technical_title = nil + elsif @se.identity == 2 + @se.technical_title = params[:pro_technical_title] if params[:pro_technical_title] + @se.student_id = nil + end + @se.brief_introduction = params[:brief_introduction] + + if @user.save && @se.save + reward_grade(@user, @user.id, 'Account', 500) + # 头像保存 + FileUtils.mv diskfile1, diskfile, force: true if File.exist? diskfile1 + @user.pref.save + @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) + set_language_if_valid @user.language + flash[:notice] = l(:notice_account_updated) + return + else + @user.login = lg + end + + end + # 不管前面是否有异常,如果文件已存在就删除 + ensure + File.delete(diskfile1) if File.exist?(diskfile1) + end + @setting_type = 1 + end + # 镜像管理 def mirror_repository @menu_type = 3 @@ -480,15 +554,27 @@ end end def save_school - uploaded_io = params[:logo] + # uploaded_io = params[:logo] sl = School.create(:name => params[:schoolname],:province => params[:province],:city => params[:city],:address => params[:address]) - # sl = School.create(:name => params[:school],:province => params[:schollProvince],:city => params[:schoolCity],:address => params[:address]) - unless uploaded_io.nil? - File.new(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb').write(sl.id) + # unless uploaded_io.nil? + # File.new(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb').write(sl.id) # File.new(Rails.root.join('public', 'images', 'school', sl.id.to_s+'.png'), 'wb') do |file| # file.write(uploaded_io.read) # end - sl.logo_link = '/images/school/'+sl.id.to_s+'.png' + # sl.logo_link = '/images/school/'+sl.id.to_s+'.png' + # end + + @user = User.current + @se = @user.extensions + + if @user.save && @se.save + diskfile1 = disk_filename('school', sl.id , 'id') + diskfileID = diskfile1 + 'temp' + begin + FileUtils.mv diskfileID, diskfile1, force: true if File.exist? diskfileID + ensure + File.delete(diskfileID) if File.exist?(diskfileID) + end end redirect_to departments_part_managements_path end @@ -1105,19 +1191,31 @@ end def auto_users_trial @menu_type = 7 @sub_type = 3 - @schools = School.where("0=0") - @schools_count = @schools.count + @apply_action = School.where(:auto_users_trial => 1).order('updated_at desc') + @apply_action_count = @apply_action.count limit = 20 @is_remote = true - @schools_pages = Paginator.new @schools_count, limit, params['page'] || 1 - @offset ||= @schools_pages.offset - @schools = paginateHelper @schools, limit + @apply_action_pages = Paginator.new @apply_action_count, limit, params['page'] || 1 + @offset ||= @apply_action_pages.offset + @apply_action = paginateHelper @apply_action, limit respond_to do |format| format.html format.js end end + # 添加 + def create_auto_users_trial + School.where(:id => params[:school]).update_all(:auto_users_trial => 1) + redirect_to auto_users_trial_managements_path + end + + # 删除 + def update_auto_users_trial + School.where(:id => params[:school]).update_all(:auto_users_trial => 0) + redirect_to auto_users_trial_managements_path + end + def search_user =begin @@ -1358,7 +1456,14 @@ end user = User.find(apply_user.user_id) apply_user.update_attribute(:status, 1) user.update_attribute(:authentication, true) + @unapproved_user = ApplyUserAuthentication.where(:status => 0, :auth_type => 1).order("updated_at desc") + @unapproved_user_count = @unapproved_user.count + @limit = 15 + @is_remote = true + @unapproved_user_pages = Paginator.new @unapproved_user_count, @limit, params['page'] || 1 + @offset ||= @unapproved_user_pages.offset + @unapproved_user = paginateHelper @unapproved_user, @limit respond_to do |format| format.js end @@ -1369,6 +1474,7 @@ end apply_user = ApplyUserAuthentication.where(:id => params[:apply_id], :auth_type => 2).first reason = apply_user.update_attributes(:status => 2, :remarks => params[:reject_reason]) render :json => {success: reason} + end # 同意职业认证 @@ -1378,6 +1484,12 @@ end apply_user.update_attribute(:status, 1) user.update_attribute(:professional_certification, true) @unapproved_user = ApplyUserAuthentication.where(:status => 0, :auth_type => 2).order("updated_at desc") + @unapproved_user_count = @unapproved_user.count + @limit = 15 + @is_remote = true + @unapproved_user_pages = Paginator.new @unapproved_user_count, @limit, params['page'] || 1 + @offset ||= @unapproved_user_pages.offset + @unapproved_user = paginateHelper @unapproved_user, @limit respond_to do |format| format.js end @@ -1406,7 +1518,8 @@ end @menu_type = 10 @sub_type = 5 @type = trial_authorization_status params[:type] - @authorizations = ApplyAction.where(:container_type => "ApplyShixun", :status => @type).order("created_at desc") + # sql = select * from apply_actions where dealer_id is null + @authorizations = ApplyAction.where(:container_type => "ApplyShixun", :status => @type,:dealer_id =>'').order("created_at desc") search = params[:search] unless search.blank? @authorizations = @authorizations.where(:container_id => Shixun.where(:id => @authorizations.map(&:container_id)).where("name like '%#{search}%'").map(&:id)).order("created_at desc") diff --git a/app/models/apply_action.rb b/app/models/apply_action.rb index 508371521..af19e832b 100644 --- a/app/models/apply_action.rb +++ b/app/models/apply_action.rb @@ -2,6 +2,5 @@ class ApplyAction < ActiveRecord::Base default_scope :order => 'updated_at desc' attr_accessible :container_id, :container_type, :dealer_id, :reason, :user_id, :status, :apply_reason - belongs_to :user end diff --git a/app/models/school.rb b/app/models/school.rb index 6dc909229..d07303e09 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -1,6 +1,6 @@ class School < ActiveRecord::Base default_scope :order => 'created_at desc' - attr_accessible :name, :province, :pinyin, :city, :address, :logo_link + attr_accessible :name, :province, :pinyin, :city, :address, :logo_link,:auto_users_trial has_many :courses has_many :departments, :dependent => :destroy diff --git a/app/views/layouts/base_management.html.erb b/app/views/layouts/base_management.html.erb index a61425574..57d2fc743 100644 --- a/app/views/layouts/base_management.html.erb +++ b/app/views/layouts/base_management.html.erb @@ -100,9 +100,9 @@