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

dev_auth
cxt 6 years ago
commit 1a565231e4

@ -80,6 +80,21 @@ $(document).on('turbolinks:load', function(){
}) })
}); });
// reset user login times
$('.users-list-container').on('click', '.reset-login-times-action', function(){
var $action = $(this);
var userId = $action.data('id');
$.ajax({
url: '/admins/users/' + userId + '/reset_login_times',
method: 'POST',
dataType: 'json',
success: function() {
showSuccessNotify();
}
});
});
// ***************** reward grade modal ***************** // ***************** reward grade modal *****************
var $rewardGradeModal = $('.admin-users-reward-grade-modal'); var $rewardGradeModal = $('.admin-users-reward-grade-modal');
var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form'); var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form');

@ -52,6 +52,12 @@ class Admins::UsersController < Admins::BaseController
render_ok(grade: user.grade) render_ok(grade: user.grade)
end end
def reset_login_times
User.find(params[:id]).reset_login_times!
render_ok
end
private private
def update_params def update_params

@ -11,6 +11,6 @@ class Users::AuthenticationAppliesController < Users::BaseAccountController
private private
def create_params def create_params
params.permit(:name, :id_number, :upload_image) params.permit(:name, :gender, :id_number, :upload_image)
end end
end end

@ -32,6 +32,7 @@ class LimitForbidControl::Base
# 锁定 # 锁定
if value >= allow_times.to_i if value >= allow_times.to_i
Rails.logger.info("[LimitForbidControl] Lock #{cache_key}")
Rails.cache.write(forbid_cache_key, true, expires_in: forbid_expires) Rails.cache.write(forbid_cache_key, true, expires_in: forbid_expires)
Rails.cache.delete(cache_key) Rails.cache.delete(cache_key)
else else
@ -40,6 +41,7 @@ class LimitForbidControl::Base
end end
def clear def clear
Rails.logger.info("[LimitForbidControl] Clear #{cache_key}")
Rails.cache.delete(forbid_cache_key) Rails.cache.delete(forbid_cache_key)
Rails.cache.delete(cache_key) Rails.cache.delete(cache_key)
end end

@ -660,6 +660,10 @@ class User < ApplicationRecord
end end
end end
def reset_login_times!
LimitForbidControl::UserLogin.new(self).clear
end
protected protected
def validate_password_length def validate_password_length
# 管理员的初始密码是5位 # 管理员的初始密码是5位

@ -22,6 +22,8 @@ class Users::ApplyAuthenticationService < ApplicationService
user.authentication = false user.authentication = false
user.save! user.save!
user.user_extension.update!(gender: params[:gender].to_i) if params[:gender].present?
user.apply_user_authentication.create!(auth_type: 1, status: 0) user.apply_user_authentication.create!(auth_type: 1, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false' move_image_file! unless params[:upload_image].to_s == 'false'

@ -1,7 +1,7 @@
class Users::CourseService class Users::CourseService
include CustomSortable include CustomSortable
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc sort_columns :created_at, :updated_at, default_by: :updated_at, default_direction: :desc
attr_reader :user, :params attr_reader :user, :params
@ -15,7 +15,7 @@ class Users::CourseService
courses = status_filter(courses) courses = status_filter(courses)
custom_sort(courses, :updated_at, params[:sort_direction]) custom_sort(courses, params[:sort_by], params[:sort_direction])
end end
private private

@ -1,7 +1,7 @@
class Users::ProjectService class Users::ProjectService
include CustomSortable include CustomSortable
sort_columns :updated_on, default_by: :updated_on, default_direction: :desc sort_columns :created_on, :updated_on, default_by: :updated_on, default_direction: :desc
attr_reader :user, :params attr_reader :user, :params
@ -21,7 +21,7 @@ class Users::ProjectService
projects = category_filter(projects) projects = category_filter(projects)
projects = status_filter(projects) projects = status_filter(projects)
custom_sort(projects, :updated_on, params[:sort_direction]) custom_sort(projects, params[:sort_by], params[:sort_direction])
end end
private private

@ -77,6 +77,10 @@ class Users::ShixunService
sort_by = sort_by&.downcase sort_by = sort_by&.downcase
sort_direction = sort_direction&.downcase sort_direction = sort_direction&.downcase
if sort_by.blank? || !%w(updated_at created_at).include?(sort_by)
sort_by = 'updated_at'
end
if sort_direction.blank? || !%w(desc asc).include?(sort_direction) if sort_direction.blank? || !%w(desc asc).include?(sort_direction)
sort_direction = 'desc' sort_direction = 'desc'
end end
@ -87,11 +91,11 @@ class Users::ShixunService
case params[:category] case params[:category]
when 'study' then when 'study' then
relations.order("myshixuns.updated_at #{sort_direction}") relations.order("myshixuns.#{sort_by} #{sort_direction}")
when 'manage' then when 'manage' then
relations.order("shixuns.updated_at #{sort_direction}") relations.order("shixuns.#{sort_by} #{sort_direction}")
else else
relations.order("shixuns.created_at #{sort_direction}") relations.order("shixuns.#{sort_by} #{sort_direction}")
end end
end end
end end

@ -1,7 +1,7 @@
class Users::SubjectService class Users::SubjectService
include CustomSortable include CustomSortable
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc sort_columns :created_at, :updated_at, default_by: :updated_at, default_direction: :desc
attr_reader :user, :params attr_reader :user, :params
@ -14,7 +14,7 @@ class Users::SubjectService
subjects = category_scope_subjects subjects = category_scope_subjects
subjects = user_policy_filter(subjects) subjects = user_policy_filter(subjects)
custom_sort(subjects.distinct, :updated_at, params[:sort_direction]) custom_sort(subjects.distinct, params[:sort_by], params[:sort_direction])
end end
private private

@ -2,15 +2,15 @@
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th width="10%" class="text-left">真实姓名</th> <th width="10%" class="text-left">真实姓名</th>
<th width="16%">邮件地址</th> <th width="15%">邮件地址</th>
<th width="10%">手机号码</th> <th width="10%">手机号码</th>
<th width="14%">单位</th> <th width="14%">单位</th>
<th width="8%">角色</th> <th width="7%">角色</th>
<th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %></th> <th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %></th>
<th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %></th> <th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %></th>
<th width="6%"><%= sort_tag('经验值', name: 'experience', path: admins_users_path) %></th> <th width="6%"><%= sort_tag('经验值', name: 'experience', path: admins_users_path) %></th>
<th width="6%"><%= sort_tag('金币', name: 'grade', path: admins_users_path) %></th> <th width="6%"><%= sort_tag('金币', name: 'grade', path: admins_users_path) %></th>
<th width="12%">操作</th> <th width="14%">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -33,8 +33,6 @@
<td class="action-container"> <td class="action-container">
<%= link_to '编辑', edit_admins_user_path(user), class: 'action' %> <%= link_to '编辑', edit_admins_user_path(user), class: 'action' %>
<%= javascript_void_link('奖励', class: 'action reward-grade-action', data: { toggle: 'modal', target: '.admin-users-reward-grade-modal', id: user.id }) %>
<%= javascript_void_link '解锁', class: 'action unlock-action', data: { id: user.id }, style: user.locked? ? '' : 'display: none;' %> <%= javascript_void_link '解锁', class: 'action unlock-action', data: { id: user.id }, style: user.locked? ? '' : 'display: none;' %>
<% if user.registered? %> <% if user.registered? %>
@ -45,7 +43,14 @@
<%= javascript_void_link '加锁', class: 'action lock-action', data: { id: user.id }, style: user.locked? || user.registered? ? 'display: none;' : '' %> <%= javascript_void_link '加锁', class: 'action lock-action', data: { id: user.id }, style: user.locked? || user.registered? ? 'display: none;' : '' %>
<% end %> <% end %>
<%= delete_link '删除', admins_user_path(user, element: ".user-item-#{user.id}"), class: 'delete-user-action' %> <%= javascript_void_link('更多', class: 'action dropdown-toggle', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) %>
<div class="dropdown-menu more-action-dropdown">
<%= javascript_void_link('奖励', class: 'dropdown-item reward-grade-action', data: { toggle: 'modal', target: '.admin-users-reward-grade-modal', id: user.id }) %>
<%= javascript_void_link '恢复禁密账号', class: 'dropdown-item reset-login-times-action', data: { id: user.id } %>
<%= delete_link '删除', admins_user_path(user, element: ".user-item-#{user.id}"), class: 'dropdown-item delete-user-action' %>
</div>
</td> </td>
</tr> </tr>
<% end %> <% end %>

@ -906,6 +906,7 @@ Rails.application.routes.draw do
post :lock post :lock
post :unlock post :unlock
post :active post :active
post :reset_login_times
end end
end end
resource :import_users, only: [:create] resource :import_users, only: [:create]

@ -0,0 +1,7 @@
class ReCounterCourseGroups < ActiveRecord::Migration[5.2]
def change
CourseGroup.find_each do |group|
CourseGroup.reset_counters(group.id, :course_members_count)
end
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -138762,6 +138762,21 @@ $(document).on('turbolinks:load', function(){
}) })
}); });
// reset user login times
$('.users-list-container').on('click', '.reset-login-times-action', function(){
var $action = $(this);
var userId = $action.data('id');
$.ajax({
url: '/admins/users/' + userId + '/reset_login_times',
method: 'POST',
dataType: 'json',
success: function() {
showSuccessNotify();
}
});
});
// ***************** reward grade modal ***************** // ***************** reward grade modal *****************
var $rewardGradeModal = $('.admin-users-reward-grade-modal'); var $rewardGradeModal = $('.admin-users-reward-grade-modal');
var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form'); var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form');

File diff suppressed because one or more lines are too long

@ -3663,16 +3663,16 @@ class Listofworksstudentone extends Component {
textAlign: "center;" textAlign: "center;"
}}> }}>
<span className="fl color-grey-6 font-12"> <span className="fl font-12">
<span className="color-grey-9A">已开始做题</span> <span className="color-grey-9">已开始做题</span>
<span className=" ml3 mr3 color-grey-9A"> <span className=" ml3 mr3 color-grey-9">
{teacherdata === undefined ? "0" : teacherdata.commit_count === undefined ? "0" : teacherdata.commit_count} {teacherdata === undefined ? "0" : teacherdata.commit_count === undefined ? "0" : teacherdata.commit_count}
</span><span className="color-grey-9A"></span> </span><span className="color-grey-9"></span>
<span className="ml10 color-grey-9A">未开始做题</span> <span className="ml10 color-grey-9">未开始做题</span>
<span <span
className="ml3 mr3 color-grey-9A">{teacherdata === undefined ? "0" : teacherdata.uncommit_count}</span><span className="ml3 mr3 color-grey-9">{teacherdata === undefined ? "0" : teacherdata.uncommit_count}</span><span
className="color-grey-9A"></span> className="color-grey-9"></span>
<span style={{color: "#666"}}>
{teacherdata === undefined ? "" : teacherdata.left_time === undefined ? "" : teacherdata.left_time === null ? "" : {teacherdata === undefined ? "" : teacherdata.left_time === undefined ? "" : teacherdata.left_time === null ? "" :
<span className="ml20">{teacherdata.left_time.status}</span> <span className="ml20">{teacherdata.left_time.status}</span>
} }
@ -3680,6 +3680,7 @@ class Listofworksstudentone extends Component {
<span className="ml20" <span className="ml20"
style={{color: '#FF6800'}}>{teacherdata.left_time.time}</span> style={{color: '#FF6800'}}>{teacherdata.left_time.time}</span>
} }
</span>
</span> </span>
<div className="fr"> <div className="fr">
@ -3859,21 +3860,23 @@ class Listofworksstudentone extends Component {
lineHeight: "31px !important;", lineHeight: "31px !important;",
textAlign: "center;" textAlign: "center;"
}}> }}>
<span className="fl color-grey-6 font-12"> <span className="fl font-12">
<span className="color-grey-9A">已开始做题</span> <span style={{color: "#999999"}}>已开始做题</span>
<span className=" ml3 mr3 color-grey-9A"> <span className=" ml3 mr3 " style={{color: "#999999"}}>
{teacherdata === undefined ? "0" : teacherdata.commit_count === undefined ? "0" : teacherdata.commit_count} {teacherdata === undefined ? "0" : teacherdata.commit_count === undefined ? "0" : teacherdata.commit_count}
</span><span className="color-grey-9A"></span> </span><span style={{color: "#999999"}}></span>
<span className="ml10 color-grey-9A">未开始做题</span> <span className="ml10 " style={{color: "#999999"}}>未开始做题</span>
<span <span
className="ml3 mr3 color-grey-9A">{teacherdata === undefined ? "0" : teacherdata.uncommit_count}</span><span className="ml3 mr3 "
className="color-grey-9A"></span> style={{color: "#999999"}}>{teacherdata === undefined ? "0" : teacherdata.uncommit_count}</span><span
style={{color: "#999999"}}></span>
<span style={{color: "#666"}}>
{teacherdata === undefined ? "" : teacherdata.left_time === undefined ? "" : teacherdata.left_time === null ? "" : {teacherdata === undefined ? "" : teacherdata.left_time === undefined ? "" : teacherdata.left_time === null ? "" :
<span className="ml20">{teacherdata.left_time.status}</span>} <span className="ml20">{teacherdata.left_time.status}</span>}
{teacherdata === undefined ? "0" : teacherdata.left_time === undefined ? "0" : teacherdata.left_time === null ? "0" : {teacherdata === undefined ? "0" : teacherdata.left_time === undefined ? "0" : teacherdata.left_time === null ? "0" :
<span className="ml20" <span className="ml20"
style={{color: '#FF6800'}}>{teacherdata.left_time.time}</span>} style={{color: '#FF6800'}}>{teacherdata.left_time.time}</span>}
</span>
</span> </span>
<style> <style>
{` {`

@ -206,10 +206,6 @@ input::-ms-clear{display:none;}
.color-grey-c{color: #ccc!important;} .color-grey-c{color: #ccc!important;}
.color-grey-cd{color: #cdcdcd!important;} .color-grey-cd{color: #cdcdcd!important;}
.color-grey-9{color: #999999!important;} .color-grey-9{color: #999999!important;}
.color-grey-9A {
color: #9A9A9A !important;
}
.color-grey-98{color: #989898!important;} .color-grey-98{color: #989898!important;}
.color-grey-8{color: #888!important;} .color-grey-8{color: #888!important;}
.color-grey-6{color: #666!important;} .color-grey-6{color: #666!important;}

Loading…
Cancel
Save