Merge branch 'szzh' into develop
This commit is contained in:
commit
cc7d75a046
|
@ -0,0 +1,18 @@
|
|||
class Secdomain < ActiveRecord::Base
|
||||
attr_accessible :pid, :subname, :sub_type, :desc
|
||||
|
||||
validates_presence_of :subname, :sub_type
|
||||
validates_uniqueness_of :subname
|
||||
|
||||
def controller
|
||||
return 'organizations' if sub_type == 2
|
||||
return 'users' if sub_type == 3
|
||||
nil
|
||||
end
|
||||
|
||||
def action
|
||||
return 'show' if sub_type == 2
|
||||
return 'show' if sub_type == 3
|
||||
nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
class CreateSecdomains < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :secdomains do |t|
|
||||
t.integer :sub_type #1.系统预留 2.Organization 3.users
|
||||
t.string :subname #子域名
|
||||
t.integer :pid, default: 0 #参数id
|
||||
t.string :desc
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
#系统保留
|
||||
Secdomain.create(sub_type: 1, subname: 'gitlab')
|
||||
Secdomain.create(sub_type: 1, subname: 'wechat')
|
||||
Secdomain.create(sub_type: 1, subname: 'judge')
|
||||
|
||||
#organization
|
||||
Secdomain.create(sub_type: 2, subname: 'micros', pid: 5)
|
||||
Secdomain.create(sub_type: 2, subname: 'nubot', pid: 23)
|
||||
Secdomain.create(sub_type: 2, subname: 'team', pid: 1)
|
||||
|
||||
#users
|
||||
Secdomain.create(sub_type: 3, subname: 'whm', pid: 7)
|
||||
Secdomain.create(sub_type: 3, subname: 'yg', pid: 5)
|
||||
Secdomain.create(sub_type: 3, subname: 'wt', pid: 11)
|
||||
|
||||
end
|
||||
end
|
|
@ -1,17 +1,11 @@
|
|||
namespace :importer do
|
||||
task :import_all => :environment do
|
||||
Rake::Task["importer:importuser"].execute
|
||||
Rake::Task["importer:importproject"].execute
|
||||
Rake::Task["importer:importcourse"].execute
|
||||
Rake::Task["importer:importattachment"].execute
|
||||
Rake::Task["importer:importmemo"].execute
|
||||
end
|
||||
|
||||
task :importuser => :environment do
|
||||
ENV['CLASS']='User'
|
||||
ENV['SCOPE']='indexable'
|
||||
ENV['FORCE']='y'
|
||||
ENV['BATCH']='1000'
|
||||
Rake::Task["elasticsearch:import:model"].invoke
|
||||
Rake::Task["elasticsearch:import:model"].execute
|
||||
end
|
||||
task :importproject => :environment do
|
||||
|
||||
|
@ -19,27 +13,30 @@ namespace :importer do
|
|||
ENV['SCOPE']='indexable'
|
||||
ENV['FORCE']='y'
|
||||
ENV['BATCH']='1000'
|
||||
Rake::Task["elasticsearch:import:model"].invoke
|
||||
Rake::Task["elasticsearch:import:model"].execute
|
||||
end
|
||||
task :importcourse => :environment do
|
||||
ENV['CLASS']='Course'
|
||||
ENV['SCOPE']='indexable'
|
||||
ENV['FORCE']='y'
|
||||
ENV['BATCH']='1000'
|
||||
Rake::Task["elasticsearch:import:model"].invoke
|
||||
Rake::Task["elasticsearch:import:model"].execute
|
||||
end
|
||||
task :importattachment => :environment do
|
||||
ENV['CLASS']='Attachment'
|
||||
ENV['SCOPE']='indexable'
|
||||
ENV['FORCE']='y'
|
||||
ENV['BATCH']='1000'
|
||||
Rake::Task["elasticsearch:import:model"].invoke
|
||||
Rake::Task["elasticsearch:import:model"].execute
|
||||
end
|
||||
task :importmemo => :environment do
|
||||
ENV['CLASS']='Memo'
|
||||
ENV['SCOPE']='indexable'
|
||||
ENV['FORCE']='y'
|
||||
ENV['BATCH']='1000'
|
||||
Rake::Task["elasticsearch:import:model"].invoke
|
||||
Rake::Task["elasticsearch:import:model"].execute
|
||||
end
|
||||
|
||||
desc "Run all tasks"
|
||||
task :all => [:importuser,:importproject,:importcourse,:importattachment,:importmemo]
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
namespace :import do
|
||||
desc "fix import name"
|
||||
task :fix => :environment do
|
||||
HomeworkCommon.find_each do |homework|
|
||||
name = homework.name.sub("\n", " ").sub("\r\n", " ")
|
||||
if name != homework.name
|
||||
homework.name = name
|
||||
homework.save!
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue