add user profile completed check

dev_aliyun
p31729568 5 years ago
parent d22f9c3f43
commit a264ce6ea2

@ -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

@ -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

@ -57,6 +57,14 @@
%>
var userEnrolled = <%= user_enrolled %>;
var userProfileModal = function(url, str) {
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix">提示</div>'+
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div>' +
'<div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
'<a href="'+ url +'" class="task-btn task-btn-orange fr" target="_blank" onclick="hideModal();">立即完善</a></div></div>';
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",

@ -5,8 +5,10 @@
<% if @maximum_staff > 1 %>
<p class="sub_title"><%= @competition.sub_title %></p>
<p class="edu-txt-right inline mt20">
<% 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 = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix">提示</div>'+
'<div class="task-popup-content"><p class="task-popup-text-center font-16">您需要去完善您的个人资料,才能使用此功能</p></div>' +
'<div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
'<a href="/my/account" class="task-btn task-btn-orange fr" target="_blank" onclick="hideModal();">立即完善</a></div></div>';
pop_box_new(htmlvalue, 480, 205);
}
function joinSure() {
if ($("#codeinput").val().trim() == "") {
$("#codeInput-notice").html("请输入邀请码");

Loading…
Cancel
Save