Merge remote-tracking branch 'origin/develop' into develop

dev_aliyun
杨树明 5 years ago
commit 42fe6c2eb6

@ -140,7 +140,6 @@ module Mobile
# #
Rails.logger.info("########### host is #{request.host}") Rails.logger.info("########### host is #{request.host}")
if (Rails.env.development? && session[:user_id].blank?) || if (Rails.env.development? && session[:user_id].blank?) ||
(session[:user_id].blank? && request.host.include?("testbdweb")) ||
params[:action] == "privateGit" params[:action] == "privateGit"
session[:user_id] = 12 #116 session[:user_id] = 12 #116
end end

@ -33,9 +33,9 @@ module Mobile
if params[:edu] if params[:edu]
Rails.logger.info("####11111222##{@env['HTTP_X_REAL_IP']}") Rails.logger.info("####11111222##{@env['HTTP_X_REAL_IP']}")
ip = @env['HTTP_X_REAL_IP'] ip = @env['HTTP_X_REAL_IP']
ua = UserAgent.where(:ip => ip, :type => UserAgent::AD) ua = UserAgent.where(:ip => ip)
unless ua if ua.blank?
UserAgent.create(:key => params[:edu].strip, :ip => ip, :type => UserAgent::AD) UserAgent.create!(:key => params[:edu].strip, :ip => ip, :type => UserAgent::AD)
end end
end end
MemosService.new.show params, current_user MemosService.new.show params, current_user

@ -17,8 +17,8 @@ module Mobile
expose :bidding_users_count, if: { type: :index } expose :bidding_users_count, if: { type: :index }
expose :min_price expose :min_price
expose :max_price expose :max_price
expose :contact_name, if: ->(package, opts){ opts[:user].id == package.creator_id || opts[:user].admin? || opts[:user].business? } expose :contact_name, if: ->(package, opts){ opts[:user].present? && (opts[:user].id == package.creator_id || opts[:user].admin? || opts[:user].business?) }
expose :contact_phone, if: ->(package, opts){ opts[:user].id == package.creator_id || opts[:user].admin? || opts[:user].business? } expose :contact_phone, if: ->(package, opts){ opts[:user].present? && (opts[:user].id == package.creator_id || opts[:user].admin? || opts[:user].business?) }
expose :updated_at do |package, _| expose :updated_at do |package, _|
package.updated_at.strftime('%Y-%m-%d %H:%M:%S') package.updated_at.strftime('%Y-%m-%d %H:%M:%S')
@ -65,6 +65,7 @@ module Mobile
expose :operation, if: { type: :show } do |package, opts| expose :operation, if: { type: :show } do |package, opts|
user = opts[:user] user = opts[:user]
return {} if user.blank?
is_creator = user.id == package.creator_id is_creator = user.id == package.creator_id
is_admin = user.admin? || user.business? is_admin = user.admin? || user.business?

@ -377,6 +377,10 @@ class AccountController < ApplicationController
else else
us = UsersService.new us = UsersService.new
@user = us.register user_params.merge(:should_confirmation_password => false) @user = us.register user_params.merge(:should_confirmation_password => false)
# 注册时,记录是否是引流用户
ip = request.remote_ip
ua = UserAgent.find_by_id(:ip => ip)
ua.update_column(:type, UserAgent::REGISTER) if ua
if !@user.new_record? if !@user.new_record?
self.logged_user = @user self.logged_user = @user
flash[:notice] = l(:notice_account_activated) flash[:notice] = l(:notice_account_activated)

@ -348,10 +348,8 @@ class CompetitionTeamsController < ApplicationController
def record_agent_user_action def record_agent_user_action
# 注册时,记录是否是引流用户 # 注册时,记录是否是引流用户
ip = @env['HTTP_X_REAL_IP'] ip = request.remote_ip
ua = UserAgent.where(:ip => ip, :type => UserAgent::AD).take ua = UserAgent.find_by_id(:ip => ip)
if ua && UserAgent.where(:ip => ip, :type => UserAgent::COMPETITION).blank? ua.update_column(:type, UserAgent::COMPETITION) if ua
UserAgent.create(:key => ua.key, :ip => ip, :type => UserAgent::COMPETITION, :user_id => User.current.id)
end
end end
end end

@ -28,6 +28,15 @@ class ManagementsController < ApplicationController
render :json => {status: 1} render :json => {status: 1}
end end
def user_agents
@user_agents = UserAgent.where("user_agents.key is not null")
@agents_count = @user_agents.count
limit = 20
@agents_pages = Paginator.new @agents_count, limit, params['page'] || 1
@offset ||= @agents_pages.offset
@user_agents = paginateHelper @user_agents, limit
end
# 实训课程等级体系 # 实训课程等级体系
def subject_level_system def subject_level_system
@levels = SubjectLevelSystem.all @levels = SubjectLevelSystem.all

@ -1,7 +1,7 @@
# encoding=utf-8 # encoding=utf-8
# For react # For react
class ProjectPackagesController < ApplicationController class ProjectPackagesController < ApplicationController
before_filter :require_login, :except => [:index] before_filter :require_login, :except => [:index, :show]
include ApplicationHelper include ApplicationHelper

@ -136,10 +136,6 @@ class UsersService
ue = @user.user_extensions ||= UserExtensions.new ue = @user.user_extensions ||= UserExtensions.new
ue.user_id = @user.id ue.user_id = @user.id
ue.save ue.save
# 注册时,记录是否是引流用户
ip = @env['HTTP_X_REAL_IP']
ua = UserAgent.where(:ip => ip, :type => UserAgent::AD).take
UserAgent.create(:key => ua.key, :ip => ip, :type => UserAgent::REGISTER, :user_id => @user.id) if ua
end end
@user @user
#img_url = url_to_avatar(@user) #img_url = url_to_avatar(@user)

@ -145,6 +145,7 @@
<li style="width: 120px"><%= link_to "升级通知", update_notice_managements_path %></li> <li style="width: 120px"><%= link_to "升级通知", update_notice_managements_path %></li>
<li style="width: 120px"><%= link_to "门户banner设置", setting_banner_managements_path %></li> <li style="width: 120px"><%= link_to "门户banner设置", setting_banner_managements_path %></li>
<li style="width: 120px"><%= link_to "培训会", training_2018_managements_path %></li> <li style="width: 120px"><%= link_to "培训会", training_2018_managements_path %></li>
<li style="width: 120px"><%= link_to "引流情况", user_agents_managements_path %></li>
</ul> </ul>
</li> </li>
</ul> </ul>

@ -2,7 +2,7 @@
<% if @libraries.present? %> <% if @libraries.present? %>
<% @libraries.each do |library| %> <% @libraries.each do |library| %>
<li class="library_list_item"> <li class="library_list_item">
<% image_url = library.cover.present? ? named_attachment_path(library.cover.id, library.cover.filename) : 'educoder/library-default-cover.png' %> <% image_url = library.cover.present? ? download_attachment_path(library.cover.id) : 'educoder/library-default-cover.png' %>
<%= image_tag(image_url, width: 120, height: 90, class: 'mr15 mt3 radius4') %> <%= image_tag(image_url, width: 120, height: 90, class: 'mr15 mt3 radius4') %>
<div class="flex1"> <div class="flex1">
<p class="clearfix mb15 lineh-40 mt10"> <p class="clearfix mb15 lineh-40 mt10">

@ -0,0 +1,66 @@
<table class="edu-pop-table edu-txt-center" cellspacing="0" cellpadding="0" style="table-layout: fixed;">
<thead>
<th width="10%">ID</th>
<th width="10%">代理人登录名</th>
<th width="10%">代理人姓名</th>
<th width="20%">学校</th>
<th width="10%">竞赛报名状态</th>
<th width="10%">ip</th>
<th width="10%">ip</th>
<th width="20%">负责人</th>
</thead>
<tbody>
<% @user_agents.each do |ua| %>
<% user = User.find_by_login(ua.key) %>
<% user_extension = user.extensions %>
<% school = user_extension.school %>
<tr>
<td><%= ua.id %></td>
<td class="edu-txt-left"><span><%= link_to ua.key, user_path(ua.key), :target => "_blank" %></span></td>
<td><%= link_to user.try(:show_real_name), user_path(user), target:'_blank' %></td>
<td><%= school.name %></td>
<td><%= "--" %></td>
<td><%= ua.ip %></td>
<td><%= "理由" %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="cl"></div>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @agents_pages, @agents_count, :per_page_links => false, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<script>
$(".eud-pointer").on("click", function(ev){
var nArrow = $(this).find("i");
var sx_order = nArrow.hasClass("fa-long-arrow-down") ? "asc" : "desc";
$.ajax({
url:"<%= shixuns_managements_path %>",
data: {sx_order:sx_order},
dateType: "script"
});
});
$(".shixun_webssh").on("click", 'input', function(ev){
var id = $(ev.target).parent().find("div").html();
var status = $(ev.target).parent().find("input").is(':checked');
$.ajax({
url:"<%= update_webssh_managements_path %>",
dataType: "script",
data:{shixun_id: id, status: status}
});
});
$(".shixun_hidden").on("click", 'input', function(ev){
var id = $(ev.target).parent().find("div").html();
$.ajax({
url:"<%= update_shixun_hidden_managements_path %>",
dataType: "script",
data:{shixun_id: id}
});
});
</script>

@ -0,0 +1,19 @@
<%= form_tag(url_for(departments_part_managements_path),:id=>"department_part_search",:method => "post",:remote=>true) do %>
<div class="edu-con-top clearfix mb20 xmt10 bor-grey-e mt10">
<input class="fl task-form-20 task-height-30 ml25" id="shixun_Look_name" name="search" maxlength="" placeholder="输入关键字进行搜索" type="text" >
<a href="javascript:void(0);" class="fl task-btn task-btn-orange ml5 mt2" onclick="$('#department_part_search').submit();">搜索</a>
<a href="javascript:clearSearchCondition();" class="fl task-btn ml5 mt2" id="clear_contents">清除</a>
<%= link_to "关联代理人",add_departments_part_managements_path(),:class => "task-btn task-btn-green fr mt6 mr30" %>
<input name="sx_order" type="hidden">
</div>
<% end %>
<div class="edu-con-bg01 mt15" id="managements_department_part_list">
<%= render :partial => "managements/user_agent_list" %>
</div>
<script>
function clearSearchCondition() {
$("#shixun_Look_name").val("");
$.get('<%= departments_part_managements_path() %>')
}
</script>

@ -537,6 +537,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
resources :managements do resources :managements do
collection do collection do
get 'user_agents'
get 'evaluate_simple' get 'evaluate_simple'
get 'hidden_course' get 'hidden_course'
match 'training_2018',:via=>[:get,:post] match 'training_2018',:via=>[:get,:post]

Loading…
Cancel
Save