Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_aliyun

dev_aliyun
caishi 5 years ago
commit 327759c649

@ -1188,4 +1188,12 @@ class ApplicationController < ActionController::Base
logger.info "----------------------- handle_flag: #{flag} -------------------------" logger.info "----------------------- handle_flag: #{flag} -------------------------"
flag flag
end end
# 用户是否完善资料
def check_account
if !User.current.profile_completed?
redirect_to my_account_path(need_profile_completed: true)
end
end
end end

@ -17,7 +17,8 @@ class CompetitionTeamsController < ApplicationController
@team_user_ids = @team.team_members.pluck(:user_id) @team_user_ids = @team.team_members.pluck(:user_id)
shixuns = Shixun.where(user_id: @team_user_ids, status: 2).where('shixuns.created_at > ?', Time.parse('2018-06-01')) shixuns = Shixun.where(user_id: @team_user_ids, status: 2)
.where('shixuns.created_at > ? && shixuns.created_at <= ?', Time.parse('2018-06-01'), @competition.end_time)
shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2') shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2')
shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count') shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count')
@shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator) @shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator)
@ -30,18 +31,30 @@ class CompetitionTeamsController < ApplicationController
forked_myshixun_count_map = get_valid_myshixun_count(forked_shixun_map.keys) forked_myshixun_count_map = get_valid_myshixun_count(forked_shixun_map.keys)
forked_myshixun_count_map.each { |k, v| @myshixun_count_map[forked_shixun_map[k]] += v } forked_myshixun_count_map.each { |k, v| @myshixun_count_map[forked_shixun_map[k]] += v }
# todo使用新版course_members @course_count_map = get_valid_course_count(shixun_ids)
forked_map = get_valid_course_count(forked_shixun_map.keys)
@forked_course_count_map = {}
forked_map.each do |forked_id, course_count|
@forked_course_count_map[forked_shixun_map[forked_id]] ||= 0
@forked_course_count_map[forked_shixun_map[forked_id]] += course_count
end
# 课堂
course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01')) course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01'))
.where('courses.created_at <= ?', @competition.end_time)
.joins('join course_members on course_members.course_id = courses.id and course_members.role in (1,2,3)') .joins('join course_members on course_members.course_id = courses.id and course_members.role in (1,2,3)')
.where(course_members: { user_id: @team_user_ids }).pluck(:id) .where(course_members: { user_id: @team_user_ids }).pluck(:id)
courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()') courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()')
@courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count') @courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count')
.group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0') .group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0')
course_ids = @courses.map(&:id)
@course_myshixun_map = Myshixun.joins(student_works: :homework_common) @course_myshixun_map = Myshixun.joins(student_works: :homework_common)
.where(homework_commons: { course_id: @courses.map(&:id) }) .where(homework_commons: { course_id: course_ids })
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
.group('homework_commons.course_id').count .group('homework_commons.course_id').count
@course_shixun_count_map = get_valid_shixun_count(course_ids)
end end
def search_teacher def search_teacher
@ -345,6 +358,28 @@ class CompetitionTeamsController < ApplicationController
.group('shixun_id').count .group('shixun_id').count
end end
def get_valid_course_count(ids)
percentage_sql = StudentWork.where('homework_common_id = homework_commons.id')
.select('count(compelete_status !=0 ) as finish, count(*) as total')
.having('finish > (total / 2)').to_sql
Course.joins(shixun_homework_commons: :homework_commons_shixuns)
.where('shixun_id in (?)', ids)
.where("exists (#{percentage_sql})")
.group('shixun_id').count
end
def get_valid_shixun_count(ids)
percentage_sql = StudentWork.where('homework_common_id = homework_commons.id')
.select('count(compelete_status !=0 ) as finish, count(*) as total')
.having('finish > (total / 2)').to_sql
Shixun.joins(homework_commons_shixuns: :homework_common)
.where(homework_commons: { homework_type: 3 })
.where('course_id in (?)', ids)
.where("exists (#{percentage_sql})")
.group('course_id').count
end
def record_agent_user_action def record_agent_user_action
# 记录是否是引流用户的行为 # 记录是否是引流用户的行为
ip = request.remote_ip ip = request.remote_ip

@ -145,7 +145,7 @@ class CompetitionsController < ApplicationController
section = stage.competition_stage_sections.reorder("start_time asc").first section = stage.competition_stage_sections.reorder("start_time asc").first
if section.present? && section.start_time.present? && section.start_time > Time.now if section.present? && section.start_time.present? && section.start_time > Time.now
User.where(:id => TeamMember.where(:competition_team_id => @competition.competition_teams.pluck(:id)).pluck(:user_id).uniq).each do |user| User.where(:id => TeamMember.where(:competition_team_id => @competition.competition_teams.pluck(:id)).pluck(:user_id).uniq).each do |user|
name = @competition.name + "#{stage.name}" name = @competition.name + "#{@competition.sub_title}#{stage.name}"
begin begin
if user.phone.present? if user.phone.present?
status = Trustie::Sms.send(mobile: user.phone.to_s, code: '1', send_type:'competition_start', user_name:user.show_name, name:name, result:section.start_time.strftime('%Y-%m-%d %H:%M:%S')) status = Trustie::Sms.send(mobile: user.phone.to_s, code: '1', send_type:'competition_start', user_name:user.show_name, name:name, result:section.start_time.strftime('%Y-%m-%d %H:%M:%S'))

@ -1,7 +1,9 @@
class LibrariesController < ApplicationController class LibrariesController < ApplicationController
include ApplicationHelper
layout 'base_library' layout 'base_library'
before_filter :require_login, :except => [:index, :show] before_filter :require_login, :except => [:index, :show]
before_filter :check_account, only: [:new, :create]
after_filter :increment_visit_count, only: [:show, :create, :edit, :update] after_filter :increment_visit_count, only: [:show, :create, :edit, :update]
def index def index

@ -1664,7 +1664,8 @@ end
# 删除单位 # 删除单位
def delete_school def delete_school
school = School.where(:id => params[:school]).first school = School.where(:id => params[:school]).first
UserExtensions.where(:school_id => params[:school]).update_all(school_id: nil, department_id: nil, profile_completed: false) UserExtensions.where(:school_id => params[:school]).update_all(school_id: nil, department_id: nil)
User.joins(:user_extension).where(user_extensions: {school_id: params[:school]}).update_all(profile_completed: false)
ApplyAddSchools.where(:school_id => params[:school]).destroy_all ApplyAddSchools.where(:school_id => params[:school]).destroy_all
ApplyAddDepartment.where(:school_id => params[:school]).destroy_all ApplyAddDepartment.where(:school_id => params[:school]).destroy_all
school.destroy school.destroy
@ -1869,6 +1870,7 @@ end
# 删除学校的用户 # 删除学校的用户
users = UserExtensions.where("school_id = #{applied_school.school_id}") users = UserExtensions.where("school_id = #{applied_school.school_id}")
User.where(id: users.map(&:user_id)).update_all(profile_completed: false)
# 申请了职业认证的用户撤销申请 # 申请了职业认证的用户撤销申请
apply_user_auth = ApplyUserAuthentication.where(:user_id => users.map(&:user_id), :auth_type => 2, :status => 0) apply_user_auth = ApplyUserAuthentication.where(:user_id => users.map(&:user_id), :auth_type => 2, :status => 0)
@ -3030,6 +3032,7 @@ end
user.certification = 1 user.certification = 1
user.grade = 0 user.grade = 0
user.password = "12345678" user.password = "12345678"
user.phone = list[5]
if user.save if user.save
ue = UserExtensions.new(:user_id => user.id, :gender => 0, :school_id => school_id, :location => school.province, :location_city => school.city, :identity => list[3], :student_id => list[0], :department_id => department.try(:id)) ue = UserExtensions.new(:user_id => user.id, :gender => 0, :school_id => school_id, :location => school.province, :location_city => school.city, :identity => list[3], :student_id => list[0], :department_id => department.try(:id))
if list[3] && list[3].to_i == 0 if list[3] && list[3].to_i == 0

@ -1,10 +1,11 @@
# encoding=utf-8 # encoding=utf-8
# For react # For react
class ProjectPackagesController < ApplicationController class ProjectPackagesController < ApplicationController
before_filter :require_login, :except => [:index, :show]
include ApplicationHelper include ApplicationHelper
before_filter :require_login, except: [:index]
before_filter :check_account, only: [:new, :create]
def show def show
render_react render_react
end end

@ -30,6 +30,7 @@ class ProjectsController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:training_task_status] skip_before_filter :verify_authenticity_token, :only => [:training_task_status]
skip_before_filter :check_if_login_required, :only => [:training_task_status] skip_before_filter :check_if_login_required, :only => [:training_task_status]
before_filter :check_authentication before_filter :check_authentication
before_filter :check_account, only: [:new, :create]
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise, before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,
:view_homework_attaches,:join_project, :project_home, :training_execute, :training_task_status] :view_homework_attaches,:join_project, :project_home, :training_execute, :training_task_status]
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]

@ -628,17 +628,19 @@ module ApplicationHelper
return return
end end
=end =end
if !User.current.profile_completed?
redirect_to my_account_path # 暂时不需要试用授权
Rails.logger.info("check_authentication end") # if !User.current.profile_completed?
elsif User.current.certification != 1 # 系统没有授权 # redirect_to my_account_path
day_cer = UserDayCertification.where(:user_id => User.current.id).last # Rails.logger.info("check_authentication end")
unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 # elsif User.current.certification != 1 # 系统没有授权
redirect_to my_account_path # day_cer = UserDayCertification.where(:user_id => User.current.id).last
Rails.logger.info("check_authentication end") # unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400
return # redirect_to my_account_path
end # Rails.logger.info("check_authentication end")
end # return
# end
# end
end end
def match_specific_symbol(str) def match_specific_symbol(str)

@ -32,7 +32,7 @@ class Shixun < ActiveRecord::Base
has_many :users, :through => :shixun_members has_many :users, :through => :shixun_members
has_many :shixun_members, :dependent => :destroy has_many :shixun_members, :dependent => :destroy
has_one :repository, :dependent => :destroy has_one :repository, :dependent => :destroy
has_many :homework_commons_shixunses has_many :homework_commons_shixuns, class_name: 'HomeworkCommonsShixuns'
has_many :homework_challenge_settings, :dependent => :destroy has_many :homework_challenge_settings, :dependent => :destroy
has_many :challenges, :dependent => :destroy has_many :challenges, :dependent => :destroy
has_many :myshixuns, :dependent => :destroy has_many :myshixuns, :dependent => :destroy

@ -506,7 +506,7 @@ class CareersService
{username: current_user.show_name, login: current_user.login, {username: current_user.show_name, login: current_user.login,
user_id: current_user.id, image_url: url_to_avatar(current_user), user_id: current_user.id, image_url: url_to_avatar(current_user),
admin: current_user.admin?, is_teacher: current_user.user_extensions.try(:identity) == 0, admin: current_user.admin?, is_teacher: current_user.user_extensions.try(:identity) == 0,
tidding_count: count, phone: current_user.phone} tidding_count: count, phone: current_user.phone, is_student: current_user.user_extensions.try(:identity) == 1}
end end
def find_career id def find_career id

@ -20,11 +20,23 @@
<% <%
total_myshixun_count = 0 total_myshixun_count = 0
total_forked_myshixun_count = 0 total_forked_myshixun_count = 0
total_shixun_score = 0
%> %>
<% @shixuns.each do |shixun| %> <% @shixuns.each do |shixun| %>
<% <%
total_myshixun_count += shixun.myshixuns_count total_myshixun_count += shixun.myshixuns_count
total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i
valid_course_count = @course_count_map.fetch(shixun.id, 0)
valid_student_count = @myshixun_count_map.fetch(shixun.id, 0)
score =
if shixun.fork_from.blank?
500 + 50 * valid_course_count + 10 * valid_student_count
else
100 + 10 * valid_course_count + 5 * valid_student_count
end
score += @forked_course_count_map.fetch(shixun.id, 0)
total_shixun_score += score
%> %>
<tr> <tr>
<td width="10%"><%= shixun.creator.show_real_name %></td> <td width="10%"><%= shixun.creator.show_real_name %></td>
@ -39,7 +51,7 @@
<td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td> <td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td>
<td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td> <td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td>
<td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td> <td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%">--</td> <td width="15%"><%= score.zero? ? '--' : score %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -50,7 +62,7 @@
<th width="10%"><%= total_myshixun_count %></th> <th width="10%"><%= total_myshixun_count %></th>
<th width="15%"><%= total_forked_myshixun_count %></th> <th width="15%"><%= total_forked_myshixun_count %></th>
<th width="10%"><%= @myshixun_count_map.values.reduce(:+) %></th> <th width="10%"><%= @myshixun_count_map.values.reduce(:+) %></th>
<th width="15%">--</th> <th width="15%"><%= total_shixun_score %></th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@ -73,11 +85,15 @@
<% <%
total_members_count = 0 total_members_count = 0
total_shixun_homework_count = 0 total_shixun_homework_count = 0
total_course_score = 0
%> %>
<% @courses.each do |course| %> <% @courses.each do |course| %>
<% <%
total_members_count += course.members_count.to_i total_members_count += course.members_count.to_i
total_shixun_homework_count += course['shixun_homework_count'].to_i total_shixun_homework_count += course['shixun_homework_count'].to_i
score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0)
total_course_score += score
%> %>
<tr> <tr>
<td width="10%"><%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %></td> <td width="10%"><%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %></td>
@ -89,7 +105,7 @@
<td width="10%"><%= course.members_count %></td> <td width="10%"><%= course.members_count %></td>
<td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td> <td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td>
<td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td> <td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%">--</td> <td width="15%"><%= score.zero? ? '--' : score %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
@ -99,8 +115,8 @@
<th width="40%" class="edu-txt-left"><%= @courses.size %></th> <th width="40%" class="edu-txt-left"><%= @courses.size %></th>
<th width="10%"><%= total_members_count %></th> <th width="10%"><%= total_members_count %></th>
<th width="15%"><%= total_shixun_homework_count %></th> <th width="15%"><%= total_shixun_homework_count %></th>
<th width="10%"><%= @course_myshixun_map.values.reduce(:+) %></th> <th width="10%"><%= @course_myshixun_map.values.reduce(:+) || 0 %></th>
<th width="15%">--</th> <th width="15%"><%= total_course_score %></th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

@ -43,7 +43,7 @@
},{ },{
name: 'C++项目', name: 'C++项目',
description: "Sentencepiece是Google公司开发的一个C++自然语言处理工具包,它实现了数据驱动、跨语言、高性能、轻量级的面向神经网络文本生成系统的无监督文本词条化工具。<br/><br/>本项目的src/目录中包含了BPE、Unigram以及Char等文本分词算法的C++实现。", description: "Sentencepiece是Google公司开发的一个C++自然语言处理工具包,它实现了数据驱动、跨语言、高性能、轻量级的面向神经网络文本生成系统的无监督文本词条化工具。<br/><br/>本项目的src/目录中包含了BPE、Unigram以及Char等文本分词算法的C++实现。",
task: '标注../src/目录下的所有.cc和.h代码文件不包括子目录(注:其中模型训练、测试相关代码可以去掉:*_test.cc, *_trainer.cc, *_trainer.h', task: '标注../src/目录下的所有.cc和.h代码文件不包括子目录。',
link_name: 'CSDN, sentencePiece入门小结', link_name: 'CSDN, sentencePiece入门小结',
link_url: 'https://blog.csdn.net/sinat_33455447/article/details/90265938' link_url: 'https://blog.csdn.net/sinat_33455447/article/details/90265938'
},{ },{

@ -57,6 +57,14 @@
%> %>
var userEnrolled = <%= user_enrolled %>; 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(){ $(".enroll-btn.active").on("click", function(){
var url = $(this).data("url"); var url = $(this).data("url");
@ -65,6 +73,11 @@
return; return;
} }
if (<%= !@user.profile_completed? %>) {
userProfileModal('/my/account?need_profile_completed=true', '您需要去完善您的个人资料,才能使用此功能');
return
}
if (!userEnrolled) { if (!userEnrolled) {
$.ajax({ $.ajax({
url: "/api/courses/apply_to_join_course.json", url: "/api/courses/apply_to_join_course.json",

@ -5,8 +5,10 @@
<% if @maximum_staff > 1 %> <% if @maximum_staff > 1 %>
<p class="sub_title"><%= @competition.sub_title %></p> <p class="sub_title"><%= @competition.sub_title %></p>
<p class="edu-txt-right inline mt20"> <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" %> <%= 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 %> <% else %>
<% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> <% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if !@can_enroll %> <% if !@can_enroll %>
@ -19,8 +21,10 @@
<% end %> <% end %>
<% end %> <% end %>
<% unless User.current.logged? %> <% if !User.current.logged? %>
<%= link_to "加入战队", signin_path, :remote => true, :class => "enroll-in-b fr" %> <%= 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 %> <% else %>
<% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> <% unless @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if !@can_enroll %> <% if !@can_enroll %>
@ -153,6 +157,14 @@
pop_box_new(htmlvalue, 500, 205); 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?need_profile_completed=true" class="task-btn task-btn-orange fr" onclick="hideModal();">立即完善</a></div></div>';
pop_box_new(htmlvalue, 480, 205);
}
function joinSure() { function joinSure() {
if ($("#codeinput").val().trim() == "") { if ($("#codeinput").val().trim() == "") {
$("#codeInput-notice").html("请输入邀请码"); $("#codeInput-notice").html("请输入邀请码");

@ -79,13 +79,21 @@
<div class="edu-menu-list" style="top:60px;width: 240px;"> <div class="edu-menu-list" style="top:60px;width: 240px;">
<div class="overPart"></div> <div class="overPart"></div>
<ul class="fl with50 edu-txt-center pr ul-leftline"> <ul class="fl with50 edu-txt-center pr ul-leftline">
<li><%= link_to '新建课堂', new_course_path() %></li> <% unless User.current.identity == "学生" %>
<li><%= link_to '新建课堂', new_course_path() %></li>
<% end %>
<li><%= link_to '新建实训', new_shixun_path() %></li> <li><%= link_to '新建实训', new_shixun_path() %></li>
<li><%= link_to '新建实践课程', new_subject_path() %></li> <li><%= link_to '新建实践课程', new_subject_path() %></li>
<li><%= link_to '新建项目', new_project_path() %></li> <li><%= link_to '新建项目', new_project_path() %></li>
</ul> </ul>
<ul class="fl with50 edu-txt-center"> <ul class="fl with50 edu-txt-center">
<li><%= link_to "加入课堂", join_private_courses_path, :remote => true %></li> <li>
<% if User.current.profile_completed? %>
<%= link_to "加入课堂", join_private_courses_path, :remote => true %>
<% else %>
<%= link_to "加入课堂", 'javascript:void(0)', onclick: 'showUserProfileModal()' %>
<% end %>
</li>
<!-- <li><%#= link_to "加入项目", applied_join_project_path, :remote => true %></li>--> <!-- <li><%#= link_to "加入项目", applied_join_project_path, :remote => true %></li>-->
</ul> </ul>
</div> </div>
@ -154,4 +162,12 @@
<% end %> <% end %>
}); });
function showUserProfileModal() {
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?need_profile_completed=true" class="task-btn task-btn-orange fr" onclick="hideModal();">立即完善</a></div></div>';
pop_box_new(htmlvalue, 480, 205);
}
</script> </script>

@ -66,9 +66,9 @@
<div class="edu-menu-list" style="top:60px;width: 240px;"> <div class="edu-menu-list" style="top:60px;width: 240px;">
<div class="overPart"></div> <div class="overPart"></div>
<ul class="fl with50 edu-txt-center pr ul-leftline"> <ul class="fl with50 edu-txt-center pr ul-leftline">
<li><%= link_to '新建实训', new_shixun_path() %></li> <li><%= link_to "新建实训", signin_path, :remote => true %></li>
<li><%= link_to '新建实践课程', new_subject_path() %></li> <li><%= link_to "新建实践课程", signin_path, :remote => true %></li>
<li><%= link_to '新建项目', new_project_path() %></li> <li><%= link_to "新建项目", signin_path, :remote => true %></li>
</ul> </ul>
<ul class="fl with50 edu-txt-center"> <ul class="fl with50 edu-txt-center">
<li><%= link_to "加入课堂", signin_path, :remote => true %></li> <li><%= link_to "加入课堂", signin_path, :remote => true %></li>

@ -18,7 +18,7 @@
</ul> </ul>
<div class="edu-position fr mt12 mb10"> <div class="edu-position fr mt12 mb10">
<%= hidden_field_tag(:type, params[:type]) %> <%= hidden_field_tag(:type, params[:type]) %>
<input class="winput-300-35 panel-box-sizing" placeholder="输入教学案例标题、编号进行检索" type="text" id="search_name"> <input class="winput-300-35 panel-box-sizing" placeholder="输入教学案例标题、作者、单位进行检索" type="text" id="search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey" id="search"><i class="fa fa-search"></i></a> <a href="javascript:void(0);" class="edu-btn-search font-16 color-grey" id="search"><i class="fa fa-search"></i></a>
</div> </div>
</div> </div>

@ -33,7 +33,7 @@
<td><%= member_user.try(:authentication_status) %></td> <td><%= member_user.try(:authentication_status) %></td>
<td><%= member_user.try(:professional_status) %></td> <td><%= member_user.try(:professional_status) %></td>
<td><%= member_user.try(:school_name) %></td> <td><%= member_user.try(:school_name) %></td>
<td><%= member_user.user_extensions.school.try(:province) %></td> <td><%= member_user.user_extensions.try(:school).try(:province) %></td>
<td><%= format_time member.created_at %></td> <td><%= format_time member.created_at %></td>
</tr> </tr>
<% end %> <% end %>

@ -193,9 +193,10 @@
<% if User.current.admin? %> <% if User.current.admin? %>
<label class="panel-form-label fl mr18">管理员:</label> <label class="panel-form-label fl mr18">管理员:</label>
<span class="fl"> <span class="fl">
<input type="checkbox" <%= @user.admin? ? "checked" : "" %> name="admin" value="<%= @user.admin? ? "1" : "0" %>" id="person_admin" class="magic-checkbox" style="float:left; margin-top: 8px;"> <input type="checkbox" <%= @user.admin? ? "checked" : "" %> id="person_admin" class="magic-checkbox" style="float:left; margin-top: 8px;">
<label for="person_admin"></label> <label for="person_admin"></label>
</span> </span>
<input type="hidden" id="user_admin" name="admin" value="<%= @user.admin? ? "1" : "0" %>">
<% end %> <% end %>
</li> </li>
@ -636,9 +637,9 @@
<% if User.current.admin? %> <% if User.current.admin? %>
var admin_check = document.getElementById('person_admin').checked; var admin_check = document.getElementById('person_admin').checked;
if (admin_check) { if (admin_check) {
document.getElementById('person_admin').value = "1"; document.getElementById('user_admin').value = "1";
} else { } else {
document.getElementById('person_admin').value = "0"; document.getElementById('user_admin').value = "0";
} }
<% end %> <% end %>
my_account_form_submit(); my_account_form_submit();

@ -2,8 +2,12 @@
praised = PraiseTread.praised(object) praised = PraiseTread.praised(object)
praise_num = get_praise_num(object) || 0 praise_num = get_praise_num(object) || 0
%> %>
<p class="noteDetailPoints plus-praise-btn" data-tip-down="点赞" style="<%= praised ? 'display:block' : 'display:none' %>"><i class="iconfont icon-dianzan"></i><br><span class="praise-num"><%= praise_num %></span></p> <% if User.current.try(:logged?) %>
<p class="noteDetailPointsBCD1E3 minus-praise-btn" data-tip-down="取消点赞" style="<%= praised ? 'display:none' : 'display:block' %>"><span>已赞</span><br><span class="praise-num"><%= praise_num %></span></p> <p class="noteDetailPoints plus-praise-btn" data-tip-down="点赞" style="<%= praised ? 'display:block' : 'display:none' %>"><i class="iconfont icon-dianzan"></i><br><span class="praise-num"><%= praise_num %></span></p>
<p class="noteDetailPointsBCD1E3 minus-praise-btn" data-tip-down="取消点赞" style="<%= praised ? 'display:none' : 'display:block' %>"><span>已赞</span><br><span class="praise-num"><%= praise_num %></span></p>
<% else %>
<p class="noteDetailPointsBCD1E3 minus-praise-btn unlogged"><i class="iconfont icon-dianzan"></i><br><span class="praise-num"><%= praise_num %></span></p>
<% end %>
<script> <script>
$(function(){ $(function(){
@ -26,6 +30,11 @@
}); });
$minusPraiseBtn.on('click', function(){ $minusPraiseBtn.on('click', function(){
if($(this).hasClass('unlogged')){
window.location.href = '<%= signin_path(back_url: request.original_url) %>';
return;
}
$.ajax({ $.ajax({
method: "get", method: "get",
url: "<%= praise_tread_praise_minus_path(obj_id: object.id, obj_type: object.class) %>", url: "<%= praise_tread_praise_minus_path(obj_id: object.id, obj_type: object.class) %>",

File diff suppressed because one or more lines are too long

@ -0,0 +1,13 @@
class ModifyTestUserForSchool < ActiveRecord::Migration
def up
school_ids = School.where("id < 1500").pluck(:id)
users = User.where(is_test: true).includes(:user_extensions)
users.find_each do |u|
school_id = school_ids.sample
u.user_extensions.update_column(:school_id, school_id) if u.user_extensions.present?
end
end
def down
end
end

@ -41,7 +41,7 @@ var proxy = "http://localhost:3000"
// proxy = "http://testbdweb.trustie.net" // proxy = "http://testbdweb.trustie.net"
// proxy = "http://testbdweb.educoder.net" // proxy = "http://testbdweb.educoder.net"
// proxy ="http://192.168.2.63:3000" // proxy ="http://192.168.2.63:3000"
// proxy='https://www.educoder.net' proxy='http://120.27.231.56:48080'
const requestMap={}; const requestMap={};
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求 // 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制 // 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制

@ -258,20 +258,20 @@ class NewHeader extends Component {
} }
NewCoursesAndShixuns=(sum)=>{ NewCoursesAndShixuns=(sum)=>{
if(this.props.current_user&&this.props.current_user.login=== ""){
if(this.props.user&&this.props.user.login=== ""||this.props.user&&this.props.user===null||this.props.current_user&&this.props.current_user=== ""){
window.location.href = "/login";
}else if(this.state.current_user=== ""){
window.location.href = "/login"; window.location.href = "/login";
}else{ }else if(sum===1){
if(sum===1){ window.location.href = "/courses/new";
window.location.href = "/courses/new"; }else if(sum===2){
}else if(sum===2){ window.location.href = "/shixuns/new";
window.location.href = "/shixuns/new"; }else if(sum===3){
}else if(sum===3){ window.location.href = "/paths/new";
window.location.href = "/paths/new"; }else if(sum===4){
}else if(sum===4){ window.location.href = "/projects/new";
window.location.href = "/projects/new";
}
} }
} }
render() { render() {
@ -308,7 +308,7 @@ class NewHeader extends Component {
console.log(this.props.current_user&&this.props.current_user.login=== "") console.log(this.props.user&&this.props.user.is_student=== true||this.props.current_user&&this.props.current_user.is_student==true)
console.log(this.state.current_user) console.log(this.state.current_user)
// console.log(match.path.startsWith("/ec_courses")) // console.log(match.path.startsWith("/ec_courses"))
return ( return (
@ -477,7 +477,10 @@ class NewHeader extends Component {
<div className="edu-menu-list" style={{top: '60px',width:"240px"}}> <div className="edu-menu-list" style={{top: '60px',width:"240px"}}>
<div className="overPart"></div> <div className="overPart"></div>
<ul className="fl with50 edu-txt-center pr ul-leftline"> <ul className="fl with50 edu-txt-center pr ul-leftline">
<li><a onClick={()=>this.NewCoursesAndShixuns(1)}>新建课堂</a></li> {
this.props.user&&this.props.user.is_student=== false || this.props.current_user&&this.props.current_user.is_student==false?
<li><a onClick={()=>this.NewCoursesAndShixuns(1)}>新建课堂</a></li>:""
}
<li><a onClick={()=>this.NewCoursesAndShixuns(2)}>新建实训</a></li> <li><a onClick={()=>this.NewCoursesAndShixuns(2)}>新建实训</a></li>
<li><a onClick={()=>this.NewCoursesAndShixuns(3)}>新建实践课程</a></li> <li><a onClick={()=>this.NewCoursesAndShixuns(3)}>新建实践课程</a></li>
<li><a onClick={()=>this.NewCoursesAndShixuns(4)}>新建项目</a></li> <li><a onClick={()=>this.NewCoursesAndShixuns(4)}>新建项目</a></li>

Loading…
Cancel
Save