diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 22888abb..b1281b12 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -362,6 +362,13 @@ class ApplicationController < ActionController::Base true end + # 运营人员 + def require_business + unless (User.current.business? || User.current.admin?) + render_403 + end + end + def deny_access User.current.logged? ? render_403 : require_login end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index b65f2219..421e5da3 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1635,7 +1635,7 @@ class CoursesController < ApplicationController @course_modules = @course.course_modules.where(:hidden => 0) 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 member = @course.members.where(:user_id => User.current.id).first if member.try(:course_group_id).to_i == 0 diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 1c454424..07381e57 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1,6 +1,6 @@ # encoding: utf-8 class ManagementsController < ApplicationController - before_filter :require_admin + before_filter :require_business layout 'base_management' include ManagementsHelper include SortHelper @@ -63,7 +63,6 @@ class ManagementsController < ApplicationController # 工程认证视频导入模板 def ec_template @template = EcTemplate.where(nil) - end def add_template @@ -3350,7 +3349,7 @@ end end @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 @users_count = @users.count @limit = 20 @@ -4181,7 +4180,7 @@ end sheet1 = book.create_worksheet :name => "course" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间"]) + sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间","创建时间"]) count_row = 1 courses.each do |course| school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name @@ -4198,6 +4197,7 @@ end sheet1[count_row,9] = school sheet1[count_row,10] = teacher_name sheet1[count_row,11] = format_time(course.updatetime) + sheet1[count_row,12] = format_time(course.created_at) count_row += 1 end book.write xls_report diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0572f8fa..adcc46c3 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -12,6 +12,7 @@ class ShixunsController < ApplicationController 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 :validation_email, :only => [:new] + before_filter :require_admin, :only => [:destroy] # 移动云ToC模式权限控制 # before_filter :ecloud_auth, :except => [:show, :index] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d13db006..df2ce0cd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -274,7 +274,7 @@ class UsersController < ApplicationController # 私信 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 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") diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index c6fa78d9..729a9564 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -30,6 +30,17 @@ class WelcomeController < ApplicationController 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) + 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 identifiers = params[:identifiers].split(",") shixuns = Shixun.where(identifier: identifiers) @@ -62,7 +73,7 @@ class WelcomeController < ApplicationController if shixun.challenges.present? shixun.challenges.each do |challenge| 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.save! # 评测题,选择题暂时不考虑 @@ -98,6 +109,7 @@ class WelcomeController < ApplicationController def local_to_shixun ActiveRecord::Base.transaction do + shixun_list = [] LocalShixun.find_each do |local_shixun| identifier = generate_identifier 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? local_challenges.each do |local_challenge| 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.shixun_id = shixun.id new_challenge.save! @@ -166,8 +178,9 @@ class WelcomeController < ApplicationController end end end - render :json => {status: 0, message: "success", identifier: shixun.identifier} + shixun_list << shixun.identifier end + render :json => {status: 0, message: "success", identifier: shixun_list} end end @@ -205,7 +218,7 @@ class WelcomeController < ApplicationController @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") - render :layout => 'educoder' + render :layout => 'base_local' end # 自动导入用户 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c02f7e5a..b08cda24 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3995,7 +3995,7 @@ module ApplicationHelper # Returns the javascript tags that are included in the html layout head 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' tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") end @@ -4009,6 +4009,15 @@ module ApplicationHelper tags 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 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') diff --git a/app/models/open_source_project.rb b/app/models/open_source_project.rb index 0adc0957..93b91fbb 100644 --- a/app/models/open_source_project.rb +++ b/app/models/open_source_project.rb @@ -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}" 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! self.class.reset_counters!(id) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 8573c683..bddb03b7 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -17,7 +17,7 @@ class GamesService myshixun = Myshixun.min.find(game.myshixun_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} end game_challenge = Challenge.min.find(game.challenge_id) diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index a4af9782..83b6b152 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -73,15 +73,6 @@ <% end %> - - <%= render :partial => "account/copyright_info" %> diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 6b282631..55cd14c9 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -6,25 +6,8 @@
  • "><%= link_to "翻转课堂", courses_path %>
  • "><%= link_to "开发社区", shixuns_path %>
  • - - <% careers = Career.published.order("created_at asc") %> - <% if careers.present? %> -
  • " style="cursor: auto;"> -

    职业路径

    - -
  • - <% end %>
  • "><%= link_to "竞赛", competitions_path %>
  • "><%= link_to "问答", forums_path %>
  • - <% if User.current.ec_school.present? %> -
  • " id="ec_banner"> - <%= link_to "认证", department_ecs_path(:school_id => User.current.ec_school) %> -
  • - <% end %> -
    - <%= 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" %> - -
    @@ -81,28 +66,12 @@
  • <%= link_to '新建项目', new_project_path() %>
  • - -
    - - - - - <% 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 %> - <%= count > 99 ? "99+" : count %> -
    - 您有<%= count %>条新消息,点击查看 -
    - <% end %> -
    @@ -128,11 +97,11 @@ <% notice = SystemUpdateNotice.last %> <% if @noticed_update || ((User.current.certification == 1 || params[:controller] != "welcome") && notice.present? && notice.end_time > Time.now && notice.start_time >= (Time.now - 21600) && User.current.user_system_notices.where(:notice_type => notice.notice_type).count == 0) %> - var htmlvalue = "<%= escape_javascript(render :partial => 'account/user_update_notice', :locals => {:notice => notice})%>"; - pop_box_new(htmlvalue, 500, 380); - <% UserSystemNotice.create(:user_id => User.current.id, :notice_type => notice.notice_type) %> + var htmlvalue = "<%= escape_javascript(render :partial => 'account/user_update_notice', :locals => {:notice => notice})%>"; + pop_box_new(htmlvalue, 500, 380); + <% UserSystemNotice.create(:user_id => User.current.id, :notice_type => notice.notice_type) %> <%# elsif notice.present? && notice.end_time < Time.now %> - <%# notice.destroy %> + <%# notice.destroy %> <% end %> }); diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index d970fffc..72dd2731 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -8,17 +8,6 @@
  • "><%= link_to "开发社区", shixuns_path %>
  • - <% careers = Career.published.order("created_at asc") %> - <% if careers.present? %> -
  • " style="cursor: auto;"> -

    职业路径

    - -
  • - <% end %>
  • "><%= link_to "竞赛", competitions_path %>
  • "><%= link_to "问答", forums_path %>
  • diff --git a/app/views/layouts/base_edu_user.html.erb b/app/views/layouts/base_edu_user.html.erb index 293b9426..37ba85ca 100644 --- a/app/views/layouts/base_edu_user.html.erb +++ b/app/views/layouts/base_edu_user.html.erb @@ -7,43 +7,23 @@ <%= csrf_meta_tag %> <%= 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 %> - <%= javascript_include_tag 'edu/application', 'educoder/edu_application','educoder/edu_account',"educoder/edu_user" %> - <%= yield :header_tags -%> - - - - + <%= stylesheet_link_tag 'css/font-awesome','educoder/edu-main','educoder/edu-all','/assets/iconfont/iconfont.css', :media => 'all' %> -
    -
    - <% if User.current.logged? %> - <%= render :partial => 'layouts/logined_header' %> - <% else%> - <%= render :partial => 'layouts/unlogin_header' %> - <% end%> +
    +
    + <%= render :partial => 'layouts/logined_header' %>
    -
    +
    <%= yield %>
    - + <%= render :partial => 'users/returnTop_btn' %>
    - - <%#= render :partial => 'layouts/public_left_info' %> + <%= render :partial => 'layouts/footer' %>
    @@ -55,4 +35,6 @@
    +<%= javascript_heads_local %> +<%= javascript_include_tag 'edu/application', 'educoder/edu_application',"educoder/edu_user" %> \ No newline at end of file diff --git a/app/views/layouts/base_local.html.erb b/app/views/layouts/base_local.html.erb new file mode 100644 index 00000000..5ce69147 --- /dev/null +++ b/app/views/layouts/base_local.html.erb @@ -0,0 +1,31 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_edu_index_heads %> + <%= stylesheet_link_tag 'educoder/edu-main', 'educoder/edu-all', 'educoder/magic-check' %> + + + +
    +
    + <%= render 'layouts/logined_header' %> +
    +
    + <%= yield %> +
    + <%= render :partial => 'layouts/footer' %> +
    + + + +<%= javascript_include_tag 'educoder/edu_application','educoder/jquery.raty' %> + + diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb index 818ba099..e8ad5ae9 100644 --- a/app/views/layouts/login.html.erb +++ b/app/views/layouts/login.html.erb @@ -7,23 +7,9 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','educoder/edu-main','educoder/edu-all', 'css/font-awesome','educoder/magic-check.css' %> - <%#= javascript_heads %> - <%= 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" %> - - -
    diff --git a/config/routes.rb b/config/routes.rb index 9e0879e7..c2ed181b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -286,6 +286,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'welcome/ccf' => 'welcome#ccf' get 'welcome/shixun_to_local' => 'welcome#shixun_to_local' get 'welcome/local_to_shixun' => 'welcome#local_to_shixun' + get 'welcome/local_init' => 'welcome#local_init' # get 'competitions/home' => 'competitions#home' # get 'competitions/hn' => 'competitions#index' diff --git a/db/migrate/20190426020414_add_business_to_user.rb b/db/migrate/20190426020414_add_business_to_user.rb new file mode 100644 index 00000000..c9ab35ca --- /dev/null +++ b/db/migrate/20190426020414_add_business_to_user.rb @@ -0,0 +1,5 @@ +class AddBusinessToUser < ActiveRecord::Migration + def change + add_column :users, :business, :boolean, :default => false + end +end diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake index d8ae770e..bfa0678c 100644 --- a/lib/tasks/users.rake +++ b/lib/tasks/users.rake @@ -89,7 +89,7 @@ task :add_test_users => :environment do (1..1000).each do |i| no = sprintf("%04d", i) - phone = "1560731#{no}" + phone = "5160731#{no}" us = UsersService.new user = us.register phone: phone, password: 'edu12345678' @@ -109,7 +109,7 @@ task :add_test_users => :environment do lastname: lastname, nickname: '', sex: 0, - mail: "educoder#{no}@qq.com", + mail: "00educoder#{no}@qq.com", identity: 1, te_technical_title: 0, pro_technical_title: 0, diff --git a/public/javascripts/educoder/edu_application.js b/public/javascripts/educoder/edu_application.js index 01daa18d..5d81c572 100644 --- a/public/javascripts/educoder/edu_application.js +++ b/public/javascripts/educoder/edu_application.js @@ -15,18 +15,6 @@ $(function(){ var searchText = result[1] $('#search-input').val(searchText) } - // 未报名用户登录时弹框 - // console.log(Cookies.get('enroll_status')); - // if(Cookies.get('enroll_status') == 0){ - // Cookies.remove('enroll_status'); - // var html='
    '+ - // '
    '+ - // ''+ - // ''+ - // '立即报名'+ - // '
    '; - // $(".newContainer").append(html); - // } }); function CloseBox(){