diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index ac861841..a1e8a56c 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -1,7 +1,9 @@ class LibrariesController < ApplicationController + include ApplicationHelper layout 'base_library' before_filter :require_login, :except => [:index, :show] + before_filter :check_authentication, except: [:index, :show] after_filter :increment_visit_count, only: [:show, :create, :edit, :update] def index diff --git a/app/controllers/project_packages_controller.rb b/app/controllers/project_packages_controller.rb index 6721c1c4..7a0990f3 100644 --- a/app/controllers/project_packages_controller.rb +++ b/app/controllers/project_packages_controller.rb @@ -1,10 +1,11 @@ # encoding=utf-8 # For react class ProjectPackagesController < ApplicationController - before_filter :require_login, :except => [:index, :show] - include ApplicationHelper + before_filter :require_login, except: [:index] + before_filter :check_authentication, except: [:index] + def show render_react end diff --git a/app/views/competitions/_qg_second_opensource.html.erb b/app/views/competitions/_qg_second_opensource.html.erb index 8aef0390..47fc814b 100644 --- a/app/views/competitions/_qg_second_opensource.html.erb +++ b/app/views/competitions/_qg_second_opensource.html.erb @@ -57,6 +57,14 @@ %> var userEnrolled = <%= user_enrolled %>; + var userProfileModal = function(url, str) { + var htmlvalue = '
提示
'+ + '

' + str + '

' + + '
取消'+ + '立即完善
'; + pop_box_new(htmlvalue, 480, 205); + } + $(".enroll-btn.active").on("click", function(){ var url = $(this).data("url"); @@ -65,6 +73,11 @@ return; } + if (<%= !@user.profile_completed? %>) { + userProfileModal('/my/account', '您需要去完善您的个人资料,才能使用此功能'); + return + } + if (!userEnrolled) { $.ajax({ url: "/api/courses/apply_to_join_course.json", diff --git a/app/views/competitions/enroll.html.erb b/app/views/competitions/enroll.html.erb index ee439267..c2a3d029 100644 --- a/app/views/competitions/enroll.html.erb +++ b/app/views/competitions/enroll.html.erb @@ -5,8 +5,10 @@ <% if @maximum_staff > 1 %>

<%= @competition.sub_title %>

- <% unless User.current.logged? %> + <% if !User.current.logged? %> <%= link_to "创建战队", signin_path, :remote => true, :class => "enroll-in-b enroll-in-b-green fr" %> + <% elsif !User.current.try(:profile_completed?) %> + <%= link_to "创建战队", 'javascript:void(0)', :class => "enroll-in-b enroll-in-b-green fr", onclick: "userProfileModal()" %> <% else %> <% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> <% if !@can_enroll %> @@ -19,8 +21,10 @@ <% end %> <% end %> - <% unless User.current.logged? %> + <% if !User.current.logged? %> <%= link_to "加入战队", signin_path, :remote => true, :class => "enroll-in-b fr" %> + <% elsif !User.current.try(:profile_completed?) %> + <%= link_to "加入战队", 'javascript:void(0)', :class => "enroll-in-b fr", onclick: "userProfileModal()" %> <% else %> <% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> <% if !@can_enroll %> @@ -153,6 +157,14 @@ pop_box_new(htmlvalue, 500, 205); } + function userProfileModal() { + var htmlvalue = '

提示
'+ + '

您需要去完善您的个人资料,才能使用此功能

' + + '
取消'+ + '立即完善
'; + pop_box_new(htmlvalue, 480, 205); + } + function joinSure() { if ($("#codeinput").val().trim() == "") { $("#codeInput-notice").html("请输入邀请码");