dev_partners
p31729568 6 years ago
commit 88431ecd73

@ -60,6 +60,8 @@ gem 'kaminari'
gem 'elasticsearch-model' gem 'elasticsearch-model'
gem 'elasticsearch-rails' gem 'elasticsearch-rails'
gem 'oauth2'
# cronjob # cronjob
gem 'whenever', require: false gem 'whenever', require: false

@ -362,6 +362,13 @@ class ApplicationController < ActionController::Base
true true
end end
# 运营人员
def require_business
unless (User.current.business? || User.current.admin?)
render_403
end
end
def deny_access def deny_access
User.current.logged? ? render_403 : require_login User.current.logged? ? render_403 : require_login
end end
@ -1120,4 +1127,25 @@ class ApplicationController < ActionController::Base
Time.now < Time.new(2019, 4, 23, 2) Time.now < Time.new(2019, 4, 23, 2)
end end
# 获取Oauth Client
def get_client(site)
client_id = Redmine::Configuration['client_id']
client_secret = Redmine::Configuration['client_secret']
OAuth2::Client.new(client_id, client_secret, site: site)
end
def handle_openi_request
site = Redmine::Configuration['openi_domain']
root_url = Redmine::Configuration['educoder_domain']
get_code_url = "/oauth/get_code"
original_url = request.original_url
client = get_client(site)
redirect_uri = "#{root_url}#{get_code_url}"
authorize_url = client.auth_code.authorize_url(redirect_uri: redirect_uri)
authorize_url = authorize_url + "&gen_code=true&state=1&original_url=#{original_url}"
redirect_to authorize_url
end
end end

@ -1635,7 +1635,7 @@ class CoursesController < ApplicationController
@course_modules = @course.course_modules.where(:hidden => 0) @course_modules = @course.course_modules.where(:hidden => 0)
course_module_type = @course_modules.map(&:module_type) course_module_type = @course_modules.map(&:module_type)
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? || User.current.business?
if User.current.member_of_course?(@course) && !@is_teacher if User.current.member_of_course?(@course) && !@is_teacher
member = @course.members.where(:user_id => User.current.id).first member = @course.members.where(:user_id => User.current.id).first
if member.try(:course_group_id).to_i == 0 if member.try(:course_group_id).to_i == 0

@ -1,6 +1,6 @@
# encoding: utf-8 # encoding: utf-8
class ManagementsController < ApplicationController class ManagementsController < ApplicationController
before_filter :require_admin before_filter :require_business
layout 'base_management' layout 'base_management'
include ManagementsHelper include ManagementsHelper
include SortHelper include SortHelper
@ -63,7 +63,6 @@ class ManagementsController < ApplicationController
# 工程认证视频导入模板 # 工程认证视频导入模板
def ec_template def ec_template
@template = EcTemplate.where(nil) @template = EcTemplate.where(nil)
end end
def add_template def add_template
@ -1191,7 +1190,7 @@ end
if params[:search].blank? if params[:search].blank?
@partners = Partner.includes(:school).order("partners.created_at desc") @partners = Partner.includes(:school).order("partners.created_at desc")
else else
@partners = Partner.where("name like ? ", "%#{params[:search]}%").includes(:school).order("partners.created_at desc") @partners = Partner.includes(:school).where("schools.name like ? ", "%#{params[:search]}%").order("partners.created_at desc")
end end
@current_partner = nil @current_partner = nil
@ -1212,6 +1211,14 @@ end
end end
def delete_partner
partner = Partner.find params[:partner_id]
partner.destroy
@partners = Partner.includes(:school).order("partners.created_at desc")
@current_partner = nil
end
# 添加客户 # 添加客户
def customers_list def customers_list
@search = params[:search] @search = params[:search]
@ -1219,11 +1226,10 @@ end
partner_id = params[:partner_id] partner_id = params[:partner_id]
@partner = Partner.find partner_id @partner = Partner.find partner_id
@customers = @partner.customers @customers = @partner.customers
if @customers.present? existed_school_ids = @customers.pluck(:school_id)
@schools = School.where("(partner_id != ? or partner_id is NULL) and customer_id is NULL", @partner.id) existed_school_ids = existed_school_ids.present? ? existed_school_ids.join(",") : -1
else @schools = School.where("id not in (#{existed_school_ids})")
@schools = School.where("customer_id is null and (partner_id != ? or partner_id is NULL)", @partner.id)
end
if params[:search] if params[:search]
@schools = @schools.where("name like ?", "%#{@search}%") @schools = @schools.where("name like ?", "%#{@search}%")
end end
@ -1247,13 +1253,14 @@ end
def add_customers def add_customers
school_ids = params[:school_ids] school_ids = params[:school_ids]
if school_ids.length > 0 partner_id = params[:partner_id]
if school_ids.length > 0 && partner_id.present?
school_ids.each do |s| school_ids.each do |s|
school = School.where("id = ?",s).first school = School.where("id = ?",s).first
if school.present? if school.present?
customer = Customer.new(partner_id: params[:partner_id]) customer = Customer.new(school_id: s)
customer.save! customer.save!
school.update_attributes(:customer_id => customer.id) PartnerCustomer.create(partner_id: partner_id,customer_id: customer.id )
end end
end end
render :json => {status: 1, message: "创建成功!"} render :json => {status: 1, message: "创建成功!"}
@ -1262,17 +1269,20 @@ end
def delete_customers def delete_customers
if params[:customer] if params[:customer]
customer = Customer.where(id: params[:customer]).first customer = Customer.find(params[:customer])
@current_partner = customer.partner @current_partner = Partner.find(params[:partner_id])
customer.school.update_attributes(:customer_id => nil)
customer.destroy customer.destroy
end end
end end
# 添加合作伙伴弹框数据
def all_partners def all_partners
@search = params[:search] @search = params[:search]
@province = params[:province] @province = params[:province]
@schools = School.where("partner_id IS NULL") # 已经选过的合作伙伴不能再再列表中显示
used_school_ids = Partner.pluck(:school_id)
used_school_ids = used_school_ids.blank? ? -1 : used_school_ids.join(",")
@schools = School.where("id not in (#{used_school_ids})")
if params[:search] if params[:search]
@schools = @schools.where("name like ?", "%#{@search}%") @schools = @schools.where("name like ?", "%#{@search}%")
@ -1296,26 +1306,20 @@ end
end end
end end
def add_partner def add_partner
school_ids = params[:school_ids] school_ids = params[:school_ids]
if school_ids.length > 0 if school_ids.length > 0
school_ids.each do |s| school_ids.each do |s|
school = School.where("id = ?",s).first old_partner = Partner.where(:school_id => s)
if school.present? && school.partner_id.nil? if old_partner.blank?
partner = Partner.new(name: school.name) partner = Partner.new(school_id: s)
partner.save partner.save
school.update_attributes(:partner_id => partner.id)
end end
end end
end end
render :json => {status: 1, message: "创建成功!"} render :json => {status: 1, message: "创建成功!"}
end end
# 删除部门管理员 # 删除部门管理员
def delete_depart_member def delete_depart_member
DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all
@ -3345,7 +3349,7 @@ end
end end
@users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc") @users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc")
@xls_users = @users.reorder("created_on desc").limit(1000) #导出excel用户 @xls_users = @users.reorder("created_on desc").limit(3000) #导出excel用户
@page = (params['page'] || 1).to_i @page = (params['page'] || 1).to_i
@users_count = @users.count @users_count = @users.count
@limit = 20 @limit = 20
@ -4176,7 +4180,7 @@ end
sheet1 = book.create_worksheet :name => "course" sheet1 = book.create_worksheet :name => "course"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue sheet1.row(0).default_format = blue
sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间"]) sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间","创建时间"])
count_row = 1 count_row = 1
courses.each do |course| courses.each do |course|
school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name
@ -4193,6 +4197,7 @@ end
sheet1[count_row,9] = school sheet1[count_row,9] = school
sheet1[count_row,10] = teacher_name sheet1[count_row,10] = teacher_name
sheet1[count_row,11] = format_time(course.updatetime) sheet1[count_row,11] = format_time(course.updatetime)
sheet1[count_row,12] = format_time(course.created_at)
count_row += 1 count_row += 1
end end
book.write xls_report book.write xls_report

@ -1,6 +1,5 @@
#encoding: utf-8 #encoding: utf-8
class OauthController < ApplicationController class OauthController < ApplicationController
require
include ApplicationHelper include ApplicationHelper
before_filter :user_setup before_filter :user_setup
@ -152,8 +151,65 @@ class OauthController < ApplicationController
render json: user_info.to_json render json: user_info.to_json
end end
####--Start-- 获取Openi的授权码access_token以及用户信息。为在openi登录的用户创建相关的educoder用户 ####
IDENTITY_SITE = Redmine::Configuration['openi_domain']
ROOT_URL = Redmine::Configuration['educoder_domain']
DEFAULT_PASSWORD = "a12345678"
TOKEN_CALL_BACK = "/oauth/get_token_callback"
USER_INFO = "/oauth/userinfo"
def get_code
# 从OpenI发过来的回调中获取授权码
code = params[:code]
# 利用授权码从OpenI这里获取access_token
client = get_client(IDENTITY_SITE)
redirect_uri = "#{ROOT_URL}#{TOKEN_CALL_BACK}"
access_token_hash = client.auth_code.get_token(code, redirect_uri: redirect_uri).to_hash
# 利用access_token获取OpenI的用户信息
access_token = access_token_hash[:access_token]
get_info_url = "#{IDENTITY_SITE}#{USER_INFO}?access_token=#{access_token}"
response = HTTParty.get(get_info_url)
body_json = JSON.parse response.body
openi_user_id = body_json['token']
avatar_url = body_json['avatar_url']
login = body_json['login']
name = body_json['name']
email = body_json['email']
# 根据获取的用户信息来查询数据库如已经存在对应的Educoder用户则直接访问用户要访问的实训页面否则为其创建用户后再访问实训页面
openi = Openi.find_by_login(login)
unless openi
ActiveRecord::Base.transaction do
user = User.new(lastname: name, mail: email, mail_notification: email)
user.login = custom_openi_login(login)
user.password = DEFAULT_PASSWORD
user.save!
UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0)
UserDayCertification.create!(user_id: user.id, status: 1)
openi = Openi.create!(user_id: user.id, openi_user_id: openi_user_id, avatar_url: avatar_url, login: login, name: name, email: email)
end
end
self.logged_user = openi.user
original_url = params[:original_url]
redirect_to original_url
end
def get_token_callback
end
####--End-- 获取Openi的授权码access_token以及用户信息。为在openi登录的用户创建相关的educoder用户 ####
private private
# 为了保证新创建的用户用户名不与系统中已存在的用户冲突,加上 _openi 后缀
def custom_openi_login(login)
login + "_openi"
end
def require_login def require_login
require "base64" require "base64"

@ -2,6 +2,8 @@
# REDO: 创建版本库权限控制 # REDO: 创建版本库权限控制
class ShixunsController < ApplicationController class ShixunsController < ApplicationController
layout 'base_shixun' layout 'base_shixun'
# 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位
before_filter :handle_openi_request, if: -> {URI(request.referer).host == 'openi.org.cn' && !current_user.logged?}
before_filter :require_login, :except => [:ghook, :download_file, :show, :index] before_filter :require_login, :except => [:ghook, :download_file, :show, :index]
before_filter :check_authentication, :except => [:ghook, :download_file, :show, :index] before_filter :check_authentication, :except => [:ghook, :download_file, :show, :index]
before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search, :shixun_courses, :new_disscuss, :shixun_migrate, :qrcode, :download_file, :departments, :get_mirror_script, :send_message_to_administrator] before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search, :shixun_courses, :new_disscuss, :shixun_migrate, :qrcode, :download_file, :departments, :get_mirror_script, :send_message_to_administrator]
@ -10,6 +12,7 @@ class ShixunsController < ApplicationController
before_filter :view_allow, :only => [:collaborators, :propaedeutics, :shixun_discuss, :ranking_list] before_filter :view_allow, :only => [:collaborators, :propaedeutics, :shixun_discuss, :ranking_list]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators, :update, :destroy] before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators, :update, :destroy]
before_filter :validation_email, :only => [:new] before_filter :validation_email, :only => [:new]
before_filter :require_admin, :only => [:destroy]
# 移动云ToC模式权限控制 # 移动云ToC模式权限控制
# before_filter :ecloud_auth, :except => [:show, :index] # before_filter :ecloud_auth, :except => [:show, :index]

@ -1,6 +1,8 @@
# encoding: utf-8 # encoding: utf-8
class SubjectsController < ApplicationController class SubjectsController < ApplicationController
layout 'base_subject' layout 'base_subject'
# 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位
before_filter :handle_openi_request, if: -> {URI(request.referer).host == 'openi.org.cn' && !current_user.logged?}
before_filter :require_login, :except => [:show, :index] before_filter :require_login, :except => [:show, :index]
before_filter :check_authentication, :except => [:show, :index] before_filter :check_authentication, :except => [:show, :index]
before_filter :find_subject, :except => [:index, :new, :create, :create_subject, :new_subject, :append_to_stage, :send_to_course] before_filter :find_subject, :except => [:index, :new, :create, :create_subject, :new_subject, :append_to_stage, :send_to_course]

@ -274,7 +274,7 @@ class UsersController < ApplicationController
# 私信 # 私信
def private_messages def private_messages
if User.current == @user || User.current.admin? if User.current == @user || User.current.admin? || User.current.business?
@onclick_time = User.current.onclick_time.onclick_time @onclick_time = User.current.onclick_time.onclick_time
User.current.onclick_time.update_attribute(:onclick_time, Time.now) User.current.onclick_time.update_attribute(:onclick_time, Time.now)
@messages = PrivateMessage.find_by_sql("SELECT ui.* FROM (SELECT * FROM private_messages WHERE STATUS != 2 AND user_id = #{@user.id} ORDER BY id DESC) ui GROUP BY ui.target_id ORDER BY ui.send_time DESC") @messages = PrivateMessage.find_by_sql("SELECT ui.* FROM (SELECT * FROM private_messages WHERE STATUS != 2 AND user_id = #{@user.id} ORDER BY id DESC) ui GROUP BY ui.target_id ORDER BY ui.send_time DESC")

@ -30,6 +30,17 @@ class WelcomeController < ApplicationController
require 'simple_xlsx_reader' require 'simple_xlsx_reader'
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
def local_init
LocalShixun.delete_all
LocalMirrorRepository.delete_all
LocalShixunTagRepertoire.delete_all
LocalChallenge.delete_all
LocalTestSet.delete_all
LocalChallengeTag.delete_all
render :json => {status: 0, message: "success"}
end
def shixun_to_local def shixun_to_local
identifiers = params[:identifiers].split(",") identifiers = params[:identifiers].split(",")
shixuns = Shixun.where(identifier: identifiers) shixuns = Shixun.where(identifier: identifiers)
@ -62,7 +73,7 @@ class WelcomeController < ApplicationController
if shixun.challenges.present? if shixun.challenges.present?
shixun.challenges.each do |challenge| shixun.challenges.each do |challenge|
new_challenge = LocalChallenge.new new_challenge = LocalChallenge.new
new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id") new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id", "test_set_score")
new_challenge.local_shixun_id = local_shixun.id new_challenge.local_shixun_id = local_shixun.id
new_challenge.save! new_challenge.save!
# 评测题,选择题暂时不考虑 # 评测题,选择题暂时不考虑
@ -98,6 +109,7 @@ class WelcomeController < ApplicationController
def local_to_shixun def local_to_shixun
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
shixun_list = []
LocalShixun.find_each do |local_shixun| LocalShixun.find_each do |local_shixun|
identifier = generate_identifier identifier = generate_identifier
shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id, shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id,
@ -141,7 +153,7 @@ class WelcomeController < ApplicationController
if local_challenges.present? if local_challenges.present?
local_challenges.each do |local_challenge| local_challenges.each do |local_challenge|
new_challenge = Challenge.new new_challenge = Challenge.new
new_challenge.attributes = local_challenge.attributes.dup.except("id","local_shixun_id","user_id") new_challenge.attributes = local_challenge.attributes.dup.except("id","local_shixun_id","user_id", "test_set_score")
new_challenge.user_id = User.current.id new_challenge.user_id = User.current.id
new_challenge.shixun_id = shixun.id new_challenge.shixun_id = shixun.id
new_challenge.save! new_challenge.save!
@ -166,8 +178,9 @@ class WelcomeController < ApplicationController
end end
end end
end end
render :json => {status: 0, message: "success", identifier: shixun.identifier} shixun_list << shixun.identifier
end end
render :json => {status: 0, message: "success", identifier: shixun_list}
end end
end end
@ -205,7 +218,7 @@ class WelcomeController < ApplicationController
@tea_users = User.where(homepage_teacher: 1).includes(:user_extensions).limit(10).order("experience desc") @tea_users = User.where(homepage_teacher: 1).includes(:user_extensions).limit(10).order("experience desc")
@stu_users = User.includes(:user_extensions).where(user_extensions: {identity: 1}).limit(10).order("experience desc") @stu_users = User.includes(:user_extensions).where(user_extensions: {identity: 1}).limit(10).order("experience desc")
render :layout => 'educoder' render :layout => 'base_local'
end end
# 自动导入用户 # 自动导入用户

@ -3995,7 +3995,7 @@ module ApplicationHelper
# Returns the javascript tags that are included in the html layout head # Returns the javascript tags that are included in the html layout head
def javascript_heads def javascript_heads
tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min', 'baiduTemplate') tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'jquery.colorbox-min', 'baiduTemplate')
unless User.current.pref.warn_on_leaving_unsaved == '0' unless User.current.pref.warn_on_leaving_unsaved == '0'
tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
end end
@ -4009,6 +4009,15 @@ module ApplicationHelper
tags tags
end end
# 临时本地版
def javascript_heads_local
tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'jquery.colorbox-min')
unless User.current.pref.warn_on_leaving_unsaved == '0'
tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });")
end
tags
end
def hubspot_head def hubspot_head
tags = javascript_include_tag('hubspot/messenger.min', 'hubspot/messenger-theme-future') tags = javascript_include_tag('hubspot/messenger.min', 'hubspot/messenger-theme-future')
tags << stylesheet_link_tag('hubspot/messenger', 'hubspot/messenger-theme-future', 'hubspot/messenger-theme-flat') tags << stylesheet_link_tag('hubspot/messenger', 'hubspot/messenger-theme-future', 'hubspot/messenger-theme-flat')

@ -1,6 +1,7 @@
class Customer < ActiveRecord::Base class Customer < ActiveRecord::Base
default_scope :order => 'customers.created_at desc' default_scope :order => 'customers.created_at desc'
belongs_to :partner has_many :partners, :through => :partner_customers
has_one :school has_many :partner_customers, :dependent => :destroy
belongs_to :school
has_many :users has_many :users
end end

@ -121,13 +121,6 @@ class OpenSourceProject < ActiveRecord::Base
ApplyProjectMaster.delete_all "apply_type = '#{self.class}' AND apply_id = #{self.id} AND user_id = #{user.id}" ApplyProjectMaster.delete_all "apply_type = '#{self.class}' AND apply_id = #{self.id} AND user_id = #{user.id}"
end end
def admin?(user)
if user.admin? or ApplyProjectMaster.find(:all, :conditions => ["user_id = ? and apply_type = 'OpenSourceProject' and apply_id = ? and status = ?", user.id, self.id, 2]).present?
return true
else
return false
end
end
def reset_counters! def reset_counters!
self.class.reset_counters!(id) self.class.reset_counters!(id)

@ -0,0 +1,8 @@
class Openi < ActiveRecord::Base
attr_accessible :allow, :avatar_url, :email, :login, :name, :openi_user_id, :user_id
belongs_to :user
def self.find_by_login(login)
Openi.where(login: login).first
end
end

@ -2,7 +2,8 @@ class Partner < ActiveRecord::Base
# attr_accessible :name, :active # attr_accessible :name, :active
attr_accessor :active attr_accessor :active
has_one :school belongs_to :school
has_many :customers has_many :customers, :through => :partner_customers
has_many :partner_customers, :dependent => :destroy
has_many :users has_many :users
end end

@ -0,0 +1,5 @@
class PartnerCustomer < ActiveRecord::Base
# attr_accessible :title, :body
belongs_to :partner
belongs_to :customer
end

@ -16,8 +16,8 @@ class School < ActiveRecord::Base
has_many :ec_majors, :through => :ec_major_schools has_many :ec_majors, :through => :ec_major_schools
has_many :ec_major_schools, :dependent => :destroy has_many :ec_major_schools, :dependent => :destroy
belongs_to :partner has_many :partners, :dependent => :destroy
belongs_to :customer has_many :customers, :dependent => :destroy
# banner图片信息 # banner图片信息
has_many :school_images, :dependent => :destroy has_many :school_images, :dependent => :destroy

@ -17,7 +17,7 @@ class GamesService
myshixun = Myshixun.min.find(game.myshixun_id) myshixun = Myshixun.min.find(game.myshixun_id)
shixun = Shixun.min.find(myshixun.shixun_id) shixun = Shixun.min.find(myshixun.shixun_id)
unless (myshixun.user_id == current_user.id || current_user.admin? || current_user.id == shixun.try(:user_id) || current_user.is_certification_teacher) unless (myshixun.user_id == current_user.id || current_user.admin? || current_user.business? || current_user.id == shixun.try(:user_id) || current_user.is_certification_teacher)
return{:status => 403} return{:status => 403}
end end
game_challenge = Challenge.min.find(game.challenge_id) game_challenge = Challenge.min.find(game.challenge_id)

@ -73,15 +73,6 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<!--第三方账号登录-->
<!--<div class="mt10 edu-txt-center">
<p class="color-grey-9">第三方账号登录</p>
<div class="mt15">
<a href="javascript:void(0)" class="margin15"><img src="/images/educoder/weixin.png" class="radius"/></a>
<a href="javascript:void(0)" class="margin15"><img src="/images/educoder/QQ.png" class="radius"/></a>
<a href="javascript:void(0)" class="margin15"><img src="/images/educoder/weibo.png" class="radius"/></a>
</div>
</div>-->
</div> </div>
</div> </div>
<%= render :partial => "account/copyright_info" %> <%= render :partial => "account/copyright_info" %>

@ -6,25 +6,8 @@
<li class="<%= course_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "翻转课堂", courses_path %></li> <li class="<%= course_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "翻转课堂", courses_path %></li>
<!-- 精选实训 --> <!-- 精选实训 -->
<li class="pr <%= shixuns_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "开发社区", shixuns_path %><img src="/images/educoder/hot-h.png" class="nav-img" /></li> <li class="pr <%= shixuns_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "开发社区", shixuns_path %><img src="/images/educoder/hot-h.png" class="nav-img" /></li>
<% careers = Career.published.order("created_at asc") %>
<% if careers.present? %>
<li class="fl edu-menu-panel headIcon careershover <%= params[:action] == "index" && params[:controller] == "careers" ? " active" : "" %>" style="cursor: auto;">
<p>职业路径</p>
<ul class="edu-menu-list edu-menu-listnew" style="top:60px">
<% careers.each do |career| %>
<li><a href="<%= introduction_career_path(career) %>"><%= career.name %></a></li>
<% end %>
</ul>
</li>
<% end %>
<li class="<%= params[:controller] == "competitions" ? " active" : "" %>"><%= link_to "竞赛", competitions_path %></li> <li class="<%= params[:controller] == "competitions" ? " active" : "" %>"><%= link_to "竞赛", competitions_path %></li>
<li class="<%= params[:controller] == "forums" ? " active" : "" %>"><%= link_to "问答", forums_path %></li> <li class="<%= params[:controller] == "forums" ? " active" : "" %>"><%= link_to "问答", forums_path %></li>
<% if User.current.ec_school.present? %>
<li class="<%= ecs_controller.include?(params[:controller]) ? " active" : "" %>" id="ec_banner">
<%= link_to "认证", department_ecs_path(:school_id => User.current.ec_school) %>
</li>
<% end %>
</ul> </ul>
<div class="posi-search" id="posi-search" style="display: none"> <div class="posi-search" id="posi-search" style="display: none">
<div class="search-all clearfix"> <div class="search-all clearfix">
@ -45,6 +28,7 @@
</div> </div>
</div> </div>
</div> </div>
<% if User.current.logged? %>
<div class="fr edu-menu-panel ml15" style="height:60px;"> <div class="fr edu-menu-panel ml15" style="height:60px;">
<%= link_to (image_tag(url_to_avatar(User.current), :width =>"34", :height => "34", :class => "radius mt13", :nhname => "avatar_image", :alt=>"头像", :id => "nh_user_logo")), user_path(User.current),:class => "fl" %> <%= link_to (image_tag(url_to_avatar(User.current), :width =>"34", :height => "34", :class => "radius mt13", :nhname => "avatar_image", :alt=>"头像", :id => "nh_user_logo")), user_path(User.current),:class => "fl" %>
<ul class="edu-menu-list" style="top:60px;"> <ul class="edu-menu-list" style="top:60px;">
@ -52,18 +36,19 @@
<li><%= link_to '我的课堂', user_path(User.current) %></li> <li><%= link_to '我的课堂', user_path(User.current) %></li>
<li><%= link_to '我的实训', user_path(User.current, :type => 'a_shixun') %></li> <li><%= link_to '我的实训', user_path(User.current, :type => 'a_shixun') %></li>
<li><%= link_to '我的实训课程', user_path(User.current, :type => 'a_path') %></li> <li><%= link_to '我的实训课程', user_path(User.current, :type => 'a_path') %></li>
<% if User.current.partner.present? %>
<li><%= link_to '客户管理', partner_list_cooperate_path(User.current.partner) %></li>
<% end %>
<li><%= link_to '我的项目', user_path(User.current, :type => 'a_project') %></li> <li><%= link_to '我的项目', user_path(User.current, :type => 'a_project') %></li>
<% if User.current.department_members.count > 0 %>
<li><%= link_to '学院统计', statistics_college_path(User.current.department_members.first.try(:department)) %></li>
<% end %>
<li><%= link_to '账号管理', my_account_path %></li> <li><%= link_to '账号管理', my_account_path %></li>
<li class="bor-top-greyE"><%= link_to '退出', signout_path %></li> <li class="bor-top-greyE"><%= link_to '退出', signout_path %></li>
</ul> </ul>
</div> </div>
<% else %>
<span class="font-15 fr mt15 ml15">
<%= link_to '登录', signin_path, :class => "mr5 color-white" %>
<em class="vertical-line"></em>
<%= link_to '注册', user_join_path, :class => "ml5 color-white" %>
</span>
<% end %>
<div class="fr head-right"> <div class="fr head-right">
<a href="javascript:void(0)" id="search-open" class="fl headIcon pointer"> <a href="javascript:void(0)" id="search-open" class="fl headIcon pointer">
<i class="iconfont icon-sousuo color-white"></i> <i class="iconfont icon-sousuo color-white"></i>
@ -87,22 +72,6 @@
</div> </div>
</div> </div>
<div class="fl edu-menu-panel headIcon">
<a href="<%= user_tidings_user_path(User.current) %>">
<i class="iconfont icon-xiaoxilingdang color-white"></i>
</a>
<!--新消息提醒-->
<% new_tidings_count = User.current.tidings.where("created_at > '#{User.current.onclick_time.onclick_time}'").count %>
<% new_pri_message_count = User.current.private_messages.where("created_at > '#{User.current.onclick_time.onclick_time}'").count %>
<% count = new_tidings_count + new_pri_message_count %>
<% if count > 0 %>
<a href="<%= user_tidings_user_path(User.current) %>"><span class="newslight"><%= count > 99 ? "99+" : count %></span> </a>
<div class="edu-menu-list edu-txt-center" style="width:220px;top:60px">
<a class="font-14 padding10" style="line-height: 35px;" href="<%= user_tidings_user_path(User.current) %>">您有<span class="color-orange"><%= count %></span>条新消息,点击查看</a>
</div>
<% end %>
</div>
</div> </div>
</div> </div>

@ -8,17 +8,6 @@
<li class="pr <%= shixuns_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "开发社区", shixuns_path %><img src="/images/educoder/hot-h.png" class="nav-img" /></li> <li class="pr <%= shixuns_controller.include?(params[:controller]) ? " active" : "" %>"><%= link_to "开发社区", shixuns_path %><img src="/images/educoder/hot-h.png" class="nav-img" /></li>
<% careers = Career.published.order("created_at asc") %>
<% if careers.present? %>
<li class="fl edu-menu-panel headIcon careershover <%= params[:action] == "index" && params[:controller] == "careers" ? " active" : "" %>" style="cursor: auto;">
<p>职业路径</p>
<ul class="edu-menu-list edu-menu-listnew" style="top:60px">
<% careers.each do |career| %>
<li><a href="<%= introduction_career_path(career) %>"><%= career.name %></a></li>
<% end %>
</ul>
</li>
<% end %>
<li class="<%= params[:controller] == "competitions" ? " active" : "" %>"><%= link_to "竞赛", competitions_path %></li> <li class="<%= params[:controller] == "competitions" ? " active" : "" %>"><%= link_to "竞赛", competitions_path %></li>
<li class="<%= params[:controller] == "forums" ? " active" : "" %>"><%= link_to "问答", forums_path %></li> <li class="<%= params[:controller] == "forums" ? " active" : "" %>"><%= link_to "问答", forums_path %></li>
<!--<li><%#= link_to "活动竞赛", competitions_path %></li>--> <!--<li><%#= link_to "活动竞赛", competitions_path %></li>-->

@ -7,43 +7,23 @@
<meta name="keywords" content="智能课堂,实训项目" /> <meta name="keywords" content="智能课堂,实训项目" />
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<%= favicon %> <%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/font-awesome','educoder/edu-main','educoder/edu-all','educoder/magic-check.css','/assets/iconfont/iconfont.css', :media => 'all' %> <%= javascript_heads %> <%= stylesheet_link_tag 'css/font-awesome','educoder/edu-main','educoder/edu-all','/assets/iconfont/iconfont.css', :media => 'all' %>
<%= javascript_include_tag 'edu/application', 'educoder/edu_application','educoder/edu_account',"educoder/edu_user" %>
<%= yield :header_tags -%>
<!-- MathJax的配置 -->
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- 配置 在生成的公式图片上去掉Math定义的右键菜单$$ $$ \( \) \[ \] 中的公式给予显示-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showMathMenu: false,
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</head> </head>
<body onload="prettyPrint();"> <body onload="prettyPrint();">
<div class="newContainer"> <!-- 页面全部内容 --> <div class="newContainer">
<div class="newHeader" id="nHeader"> <!-- 头部 --> <div class="newHeader" id="nHeader">
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header' %> <%= render :partial => 'layouts/logined_header' %>
<% else%>
<%= render :partial => 'layouts/unlogin_header' %>
<% end%>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div class="newMain clearfix"> <!-- 主提部分 --> <div class="newMain clearfix">
<div id="Container"> <div id="Container">
<%= yield %> <%= yield %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<!-------------------侧边提示区域-------------------------->
<%= render :partial => 'users/returnTop_btn' %> <%= render :partial => 'users/returnTop_btn' %>
</div> </div>
<!----------------------左侧导航栏 ------------------------->
<%#= render :partial => 'layouts/public_left_info' %>
<%= render :partial => 'layouts/footer' %> <%= render :partial => 'layouts/footer' %>
<div class="cl"></div> <div class="cl"></div>
<div id="ajax-modal" style="display:none;"></div> <div id="ajax-modal" style="display:none;"></div>
@ -55,4 +35,6 @@
</div> </div>
</div> </div>
</body> </body>
<%= javascript_heads_local %>
<%= javascript_include_tag 'edu/application', 'educoder/edu_application',"educoder/edu_user" %>
</html> </html>

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="高校智能课堂与综合实训平台" />
<meta name="keywords" content="智能课堂,实训项目" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= javascript_edu_index_heads %>
<%= stylesheet_link_tag 'educoder/edu-main', 'educoder/edu-all', 'educoder/magic-check' %>
</head>
<div class="newContainer">
<div class="newHeader" id="nHeader">
<%= render 'layouts/logined_header' %>
</div>
<div class="newMain clearfix">
<%= yield %>
</div>
<%= render :partial => 'layouts/footer' %>
</div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
</body>
<%= javascript_include_tag 'educoder/edu_application','educoder/jquery.raty' %>
</html>

@ -7,23 +7,9 @@
<meta name="keywords" content="智能课堂,实训项目" /> <meta name="keywords" content="智能课堂,实训项目" />
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<%= favicon %> <%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','educoder/edu-main','educoder/edu-all', 'css/font-awesome','educoder/magic-check.css' %> <%= stylesheet_link_tag 'educoder/edu-main','educoder/edu-all' %>
<%#= javascript_heads %> <%= javascript_include_tag 'jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'educoder/edu_application', 'educoder/edu_account' %>
<%= javascript_include_tag 'jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'jquery.colorbox-min', 'edu/application', 'educoder/edu_application','educoder/edu_account','educoder/avatars' %>
<%#= stylesheet_link_tag 'css/edu-showpage','css/edu-index', 'css/font-awesome', 'css/edu-common', 'css/edu-login', 'css/edu-public', 'css/edu-popup' %>
<%#= javascript_include_tag 'edu/application', "bigdata" %>
<!-- MathJax的配置 -->
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showMathMenu: false,
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</head> </head>
<body> <body>
<div class="newContainer"> <div class="newContainer">

@ -10,7 +10,7 @@
<span><%= index + 1 %></span> <span><%= index + 1 %></span>
<span class="task-hide"><%= customer.school.name %></span> <span class="task-hide"><%= customer.school.name %></span>
<span> <span>
<a href="javascript:void(0)" onclick="delete_confirm_box_2('<%= delete_customers_managements_path(customer: customer.id) %>', <a href="javascript:void(0)" onclick="delete_confirm_box_2('<%= delete_customers_managements_path(customer: customer.id, partner_id: @current_partner.try(:id)) %>',
'确定要删除该客户吗')" class="color-grey-9">删除</a> '确定要删除该客户吗')" class="color-grey-9">删除</a>
</span> </span>
<span> <span>

@ -1,14 +1,12 @@
<% @partners.each_with_index do |partner,index| %> <% @partners.each_with_index do |partner,index| %>
<li class="clearfix"> <li class="clearfix">
<%= link_to "#{partner.name}", partners_managements_path(:partner => partner), :class => "#{partner.id == @current_partner.id ? 'active' : ''} fl" %> <%= link_to "#{partner.school.name}", partners_managements_path(:partner => partner), :class => "#{@current_partner && partner.id == @current_partner.id ? 'active' : ''} fl" %>
<% if false %>
<div class="fr mr10 edu-menu-panel mt5"> <div class="fr mr10 edu-menu-panel mt5">
<i class="iconfont icon-sandian color-grey-9 font-14"></i> <i class="iconfont icon-sandian color-grey-9 font-14"></i>
<ul class="edu-menuSmall-list edu-txt-center"> <ul class="edu-menuSmall-list edu-txt-center">
<li><a href="javascript:void(0)">查看</a></li> <li><a href="<%= partners_managements_path(:partner => partner) %>">查看</a></li>
<li><a href="javascript:void(0)" onclick="delPartners();">删除</a></li> <li><a href="javascript:void(0)" onclick="delPartners('<%= delete_partner_managements_path(:partner_id => partner) %>');">删除</a></li>
</ul> </ul>
</div> </div>
<% end %>
</li> </li>
<% end %> <% end %>

@ -0,0 +1 @@
$("#partner_list").html("<%= j(render :partial => "partner_list") %>")

@ -6,7 +6,7 @@
</div> </div>
<div class="clearfix mt20"> <div class="clearfix mt20">
<div class="with25 fl"> <div class="with25 fl">
<%= link_to "+添加",all_partners_managements_path,remote:true,class:"color-blue addOperation" %> <%= link_to "+添加", all_partners_managements_path,remote:true,class:"color-blue addOperation" %>
<ul class="partnerList" id="partner_list"> <ul class="partnerList" id="partner_list">
<%= render :partial => "partner_list" %> <%= render :partial => "partner_list" %>
</ul> </ul>
@ -31,7 +31,7 @@
} }
function delPartners(){ function delPartners(url){
delete_confirm_box_2("","确定删除合作伙伴?"); delete_confirm_box_2(url,"确定删除合作伙伴?");
} }
</script> </script>

@ -33,6 +33,9 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'oauth/cb', to: 'oauth#test_callback', :via => :get match 'oauth/cb', to: 'oauth#test_callback', :via => :get
match 'oauth/userinfo', to: 'oauth#get_userinfo', :via => :get match 'oauth/userinfo', to: 'oauth#get_userinfo', :via => :get
match 'oauth/get_code', to: 'oauth#get_code', :via => :get
match 'oauth/get_token_callback', to: 'oauth#get_token_callback', :via => :get
get 'ecloud/ecloud_login', to: 'ecloud#ecloud_login_callback' get 'ecloud/ecloud_login', to: 'ecloud#ecloud_login_callback'
post 'ecloud/bs_new', to: 'ecloud#bs_new' post 'ecloud/bs_new', to: 'ecloud#bs_new'
post 'ecloud/bs_update', to: 'ecloud#bs_update' post 'ecloud/bs_update', to: 'ecloud#bs_update'
@ -283,6 +286,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'welcome/ccf' => 'welcome#ccf' get 'welcome/ccf' => 'welcome#ccf'
get 'welcome/shixun_to_local' => 'welcome#shixun_to_local' get 'welcome/shixun_to_local' => 'welcome#shixun_to_local'
get 'welcome/local_to_shixun' => 'welcome#local_to_shixun' get 'welcome/local_to_shixun' => 'welcome#local_to_shixun'
get 'welcome/local_init' => 'welcome#local_init'
# get 'competitions/home' => 'competitions#home' # get 'competitions/home' => 'competitions#home'
# get 'competitions/hn' => 'competitions#index' # get 'competitions/hn' => 'competitions#index'
@ -719,6 +723,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
post 'update_level_for_subject' post 'update_level_for_subject'
post :add_customers post :add_customers
delete :delete_customers delete :delete_customers
delete :delete_partner
get :customers_list get :customers_list
get :school_report, controller: 'managements::schools', action: 'statistics' get :school_report, controller: 'managements::schools', action: 'statistics'
get :school_yesterday_data, controller: 'managements::schools', action: 'yesterday_data' get :school_yesterday_data, controller: 'managements::schools', action: 'yesterday_data'

@ -0,0 +1,9 @@
class CreatePartnerCustomers < ActiveRecord::Migration
def change
create_table :partner_customers do |t|
t.references :partner
t.references :customer
t.timestamps
end
end
end

@ -0,0 +1,29 @@
class ModifyPartnerAndCustomer < ActiveRecord::Migration
def up
add_column :customers, :school_id, :integer
add_column :partners, :school_id, :integer
schools = School.where("customer_id is not null or partner_id is not null")
schools.each do |school|
if school.customer_id
customer = Customer.find_by_id(school.customer_id)
customer.update_column(:school_id, school.id) if customer
end
if school.partner_id
partner = Partner.find_by_id(school.partner_id)
partner.update_column(:school_id, school.id) if partner
end
end
# 迁移关联关系
customers = Customer.where(nil)
customers.each do |customer|
PartnerCustomer.create(partner_id: customer.partner_id, customer_id: customer.id)
end
end
def down
end
end

@ -0,0 +1,5 @@
class AddBusinessToUser < ActiveRecord::Migration
def change
add_column :users, :business, :boolean, :default => false
end
end

@ -0,0 +1,15 @@
class CreateOpenis < ActiveRecord::Migration
def change
create_table :openis do |t|
t.integer :user_id
t.integer :openi_user_id
t.string :login
t.string :avatar_url
t.string :name
t.string :email
t.integer :allow
t.timestamps
end
end
end

@ -89,7 +89,7 @@ task :add_test_users => :environment do
(1..1000).each do |i| (1..1000).each do |i|
no = sprintf("%04d", i) no = sprintf("%04d", i)
phone = "1560731#{no}" phone = "5160731#{no}"
us = UsersService.new us = UsersService.new
user = us.register phone: phone, password: 'edu12345678' user = us.register phone: phone, password: 'edu12345678'
@ -109,7 +109,7 @@ task :add_test_users => :environment do
lastname: lastname, lastname: lastname,
nickname: '', nickname: '',
sex: 0, sex: 0,
mail: "educoder#{no}@qq.com", mail: "00educoder#{no}@qq.com",
identity: 1, identity: 1,
te_technical_title: 0, te_technical_title: 0,
pro_technical_title: 0, pro_technical_title: 0,

@ -15,18 +15,6 @@ $(function(){
var searchText = result[1] var searchText = result[1]
$('#search-input').val(searchText) $('#search-input').val(searchText)
} }
// 未报名用户登录时弹框
// console.log(Cookies.get('enroll_status'));
// if(Cookies.get('enroll_status') == 0){
// Cookies.remove('enroll_status');
// var html='<div class="CompetitionEnrollBox">'+
// '<div class="pr with40">'+
// '<img src="/images/educoder/competition/boxEnroll.png" width="100%"/>'+
// '<a href="javascript:void(0)" class="CloseBox" onclick="CloseBox();"><i class="iconfont icon-roundclose color-grey-c"></i></a>'+
// '<a href="https://www.educoder.net/competitions/gcc-dev-2018/enroll" class="ImmediatelyEnroll">立即报名</a>'+
// '</div></div>';
// $(".newContainer").append(html);
// }
}); });
function CloseBox(){ function CloseBox(){

@ -0,0 +1,11 @@
FactoryGirl.define do
factory :openi do
user_id 1
openi_user_id 1
login "MyString"
avatar_url "MyString"
name "MyString"
email "MyString"
allow 1
end
end

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :partner_customer do
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Openi, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe PartnerCustomer, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save