add site page
This commit is contained in:
parent
ba4c479cc2
commit
96936da9ac
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the admins/identity_verifications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the admins/site_pages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the identity_verifications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the pages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,33 @@
|
|||
class Admins::IdentityVerificationsController < Admins::BaseController
|
||||
before_action :finder_identity_verification, except: [:index]
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
identity_verifications = Admins::IdentityVerificationQuery.call(params)
|
||||
|
||||
@identity_verifications = paginate identity_verifications.preload(:user)
|
||||
end
|
||||
|
||||
def show
|
||||
render 'edit'
|
||||
end
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@identity_verification.update(update_params)
|
||||
flash[:success] = '保存成功'
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
private
|
||||
def finder_identity_verification
|
||||
@identity_verification = IdentityVerification.find(params[:id])
|
||||
@user = @identity_verification.user
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:identity_verification).permit(:state, :description)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
class Admins::SitePagesController < Admins::BaseController
|
||||
before_action :finder_site_page, except: [:index]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
pages = Admins::SitePagesQuery.call(params)
|
||||
|
||||
@site_pages = paginate pages.preload(:user)
|
||||
end
|
||||
|
||||
def show
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@site_page.update(update_params)
|
||||
flash[:success] = '保存成功'
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
private
|
||||
def finder_site_page
|
||||
@site_page = Page.find(params[:id])
|
||||
@user = @site_page.user
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:page).permit(:state, :state_description)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class Admins::UsersController < Admins::BaseController
|
||||
before_action :finder_user, except: [:index]
|
||||
before_action :finder_user, except: [:index]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||
|
@ -72,6 +72,6 @@ class Admins::UsersController < Admins::BaseController
|
|||
def update_params
|
||||
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker
|
||||
mail phone location location_city school_id department_id admin
|
||||
password login])
|
||||
password login website_permission])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
class IdentityVerificationsController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :require_profile_completed, only: [:create]
|
||||
|
||||
def index
|
||||
@id_verify = current_user.identity_verification
|
||||
return render_ok({data:nil}) unless @id_verify
|
||||
end
|
||||
|
||||
def create
|
||||
return tip_exception(-1, "您已提交过身份审核,请勿重复提交") if IdentityVerification.exists?(user:current_user)
|
||||
return tip_exception(-1, "身份证输入有误")unless create_params[:number] =~ User::VALID_NUMBER_REGEX
|
||||
@id_verify = IdentityVerification.new(create_params)
|
||||
@id_verify.user = current_user
|
||||
@id_verify.save
|
||||
end
|
||||
|
||||
def update
|
||||
return tip_exception(-1, "身份证输入有误")unless create_params[:number] =~ User::VALID_NUMBER_REGEX
|
||||
current_user.identity_verification.update(create_params.merge({ state: 0 }))
|
||||
current_user.update(id_card_verify: false)
|
||||
@id_verify = current_user.identity_verification
|
||||
end
|
||||
|
||||
private
|
||||
def create_params
|
||||
params.permit(:number, :name, :card_front, :card_back, :hold_card_front, :hold_card_back)
|
||||
end
|
||||
end
|
|
@ -5,8 +5,8 @@ class ProjectsController < ApplicationController
|
|||
include Acceleratorable
|
||||
|
||||
before_action :require_login, except: %i[index branches branches_slice group_type_list simple show fork_users praise_users watch_users recommend banner_recommend about menu_list verify_auth_token]
|
||||
before_action :require_profile_completed, only: [:create, :migrate,:verify_auth_token]
|
||||
before_action :load_repository, except: %i[index group_type_list migrate create recommend banner_recommend verify_auth_token]
|
||||
before_action :require_profile_completed, only: [:create, :migrate,:page_migrate,:verify_auth_token]
|
||||
before_action :load_repository, except: %i[index group_type_list migrate page_migrate create recommend banner_recommend verify_auth_token]
|
||||
before_action :authorizate_user_can_edit_project!, only: %i[update]
|
||||
before_action :project_public?, only: %i[fork_users praise_users watch_users]
|
||||
before_action :request_limit, only: %i[index]
|
||||
|
@ -97,6 +97,43 @@ class ProjectsController < ApplicationController
|
|||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
|
||||
def page_migrate
|
||||
return normal_status(-1, "您还未开通Page服务,无法进行新建站点") unless current_user.id_card_verify
|
||||
Projects::MigrateForm.new(mirror_params).validate!
|
||||
|
||||
@project =
|
||||
if EduSetting.get("mirror_address").to_s.include?("github") && enable_accelerator?(mirror_params[:clone_addr])
|
||||
source_clone_url = mirror_params[:clone_addr]
|
||||
uid_logger("########## 已动加速器 ##########")
|
||||
result = Gitea::Accelerator::MigrateService.call(mirror_params)
|
||||
if result[:status] == :success
|
||||
Rails.logger.info "########## 加速镜像成功 ########## "
|
||||
Projects::MigrateService.call(current_user,
|
||||
mirror_params.merge(source_clone_url: source_clone_url,
|
||||
clone_addr: accelerator_url(mirror_params[:repository_name])))
|
||||
else
|
||||
Projects::MigrateService.call(current_user, mirror_params)
|
||||
end
|
||||
elsif EduSetting.get("mirror_address").to_s.include?("cnpmjs") && mirror_params[:clone_addr].include?("github.com")
|
||||
source_clone_url = mirror_params[:clone_addr]
|
||||
clone_url = source_clone_url.gsub('github.com', 'github.com.cnpmjs.org')
|
||||
uid_logger("########## 更改clone_addr ##########")
|
||||
Projects::MigrateService.call(current_user, mirror_params.merge(source_clone_url: source_clone_url, clone_addr: clone_url))
|
||||
else
|
||||
Projects::MigrateService.call(current_user, mirror_params)
|
||||
end
|
||||
if @project.present?
|
||||
page = Page.new page_site_params
|
||||
page.user = current_user
|
||||
page.project = @project
|
||||
page.save
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
def branches
|
||||
return @branches = [] unless @project.forge?
|
||||
|
||||
|
@ -305,6 +342,10 @@ class ProjectsController < ApplicationController
|
|||
:auth_password, :project_category_id, :project_language_id, :clone_addr, :private)
|
||||
end
|
||||
|
||||
def page_site_params
|
||||
params.permit(:site_name, :identifier,:language_frame,:theme)
|
||||
end
|
||||
|
||||
def project_public?
|
||||
return if @project.is_public?
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
class SitePagesController < ApplicationController
|
||||
before_action :require_login, except: [:softbot_build, :themes]
|
||||
before_action :require_profile_completed, only: [:create]
|
||||
before_action :load_project, except: [:softbot_build, :index, :themes]
|
||||
before_action :authenticate_user!, except: [:softbot_build, :index, :themes]
|
||||
|
||||
def index
|
||||
@pages = PageQuery.call(params,current_user)
|
||||
@pages = paginate(@pages)
|
||||
end
|
||||
|
||||
def show
|
||||
@page = Page.find_by(user_id: current_user.id, project_id: @project.id)
|
||||
return render_ok({data:nil}) unless @page.present?
|
||||
end
|
||||
|
||||
def create
|
||||
return normal_status(-1, "您还未通过身份认证,无法开通Page") unless current_user.id_card_verify
|
||||
return normal_status(-1, "您还未开通Page服务,无法进行部署") unless current_user.website_permission
|
||||
return normal_status(-1, "你已使用了 #{params[:identifier]} 作为page标识") if Page.exists?(identifier: params[:identifier], user: current_user)
|
||||
return normal_status(-1, "该仓库已开通Page服务") if Page.exists?(project: @project)
|
||||
@page = Page.new(create_params)
|
||||
@page.user = current_user
|
||||
@page.project = @project
|
||||
@page.save
|
||||
end
|
||||
|
||||
def build
|
||||
return normal_status(-1, "您还未开通Page服务,无法进行部署") unless current_user.website_permission
|
||||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") unless Page.exists?(project: @project)
|
||||
@page = Page.find params[:id]
|
||||
return normal_status(-1, @page.state_description) unless @page.state
|
||||
response_str = @page.deploy_page(params[:branch])
|
||||
data = JSON.parse(response_str)["result"]
|
||||
if data.nil?
|
||||
data = JSON.parse(response_str)["error"]
|
||||
end
|
||||
@page.update(last_build_at: Time.now)
|
||||
render_ok({data: data.nil? ? nil : data.split("\n") })
|
||||
end
|
||||
|
||||
def softbot_build
|
||||
branch = params[:ref].split("/").last
|
||||
user = User.find_by_login params[:repository][:owner][:login]
|
||||
return normal_status(-1, "您还未开通Page服务,无法进行部署") unless user.website_permission
|
||||
|
||||
project = Project.where(identifier: params[:repository][:name],user_id: user.id)
|
||||
return normal_status(-1, "你没有权限操作") if project.owner?(user)
|
||||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") if Page.exists?(user: user, project: project)
|
||||
|
||||
@page = Page.find_by(user: user, project: project)
|
||||
@page.deploy_page(branch)
|
||||
render_ok
|
||||
end
|
||||
|
||||
def themes
|
||||
data = YAML.load_file(Rails.root.join('config/admins', 'page_themes.yml'))
|
||||
render_ok({themes:data[theme_params.downcase]})
|
||||
end
|
||||
|
||||
private
|
||||
def authenticate_user!
|
||||
return if @project.is_public
|
||||
return if @project.owner?(current_user)
|
||||
render_forbidden('你没有权限操作')
|
||||
end
|
||||
|
||||
def theme_params
|
||||
params[:theme] || "hugo"
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.permit(:identifier, :language_frame, :theme, :site_name)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Admins::IdentityVerificationsHelper
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Admins::SitePagesHelper
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module IdentityVerificationsHelper
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module PagesHelper
|
||||
end
|
|
@ -26,6 +26,8 @@
|
|||
# cloud_url :string(255) default("")
|
||||
# course_second_category_id :integer default("0")
|
||||
# delay_publish :boolean default("0")
|
||||
# memo_image :boolean default("0")
|
||||
# extra_type :integer default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -2,23 +2,24 @@
|
|||
#
|
||||
# Table name: bot
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# bot_name :string(255)
|
||||
# bot_des :text(4294967295)
|
||||
# webhook :string(255)
|
||||
# is_public :integer
|
||||
# logo :string(255)
|
||||
# state :integer
|
||||
# client_id :string(255)
|
||||
# client_secret :string(255)
|
||||
# web_url :string(255)
|
||||
# category :string(255)
|
||||
# install_num :integer default("0")
|
||||
# update_time :datetime not null
|
||||
# create_time :datetime not null
|
||||
# private_key :text(65535)
|
||||
# uid :integer
|
||||
# owner_id :integer
|
||||
# id :integer not null, primary key
|
||||
# bot_name :string(255) not null
|
||||
# bot_des :text(4294967295)
|
||||
# webhook :string(255) not null
|
||||
# is_public :integer
|
||||
# logo :string(255)
|
||||
# state :integer
|
||||
# client_id :string(255)
|
||||
# client_secret :string(255)
|
||||
# web_url :string(255)
|
||||
# category :string(255)
|
||||
# install_num :integer default("0")
|
||||
# update_time :datetime not null
|
||||
# create_time :datetime not null
|
||||
# uid :integer
|
||||
# owner_id :integer
|
||||
# private_key :text(65535)
|
||||
# oauth_callback_url :string(255) not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -2,13 +2,18 @@
|
|||
#
|
||||
# Table name: install_bot
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# bot_id :integer not null
|
||||
# installer_id :integer not null
|
||||
# store_id :integer not null
|
||||
# state :integer not null
|
||||
# create_time :datetime not null
|
||||
# update_time :datetime not null
|
||||
# id :integer not null, primary key
|
||||
# bot_id :integer not null
|
||||
# installer_id :integer not null
|
||||
# store_id :integer not null
|
||||
# state :integer not null
|
||||
# create_time :datetime not null
|
||||
# update_time :datetime not null
|
||||
# installer_login :string(255) not null
|
||||
# store_repo :string(255) not null
|
||||
# webhook_id :integer
|
||||
# webhook_response_msg :text(65535)
|
||||
# repo_owner :string(255)
|
||||
#
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
# devops_step :integer default("0")
|
||||
# sign_cla :boolean default("0")
|
||||
# enabling_cla :boolean default("0")
|
||||
# id_card_verify :boolean default("0")
|
||||
# website_permission :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: ignores
|
||||
# Table name: glcc_medium_term_examine_material
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# student_reg_id :integer not null
|
||||
# task_id :integer not null
|
||||
# defence_video_url :string(1000) not null
|
||||
# code_or_pr_url :string(1000)
|
||||
# PPT_attachment_id :integer not null
|
||||
# term :integer
|
||||
# created_on :datetime
|
||||
# updated_on :datetime
|
||||
# is_delete :boolean default("0"), not null
|
||||
# round :integer default("1"), not null
|
||||
#
|
||||
# student_reg_id
|
||||
# task_id
|
||||
# defence_video_url
|
||||
# code_or_pr_url
|
||||
# PPT_attachment_id
|
||||
# term
|
||||
# created_on
|
||||
# updated_on
|
||||
# is_delete
|
||||
# round
|
||||
|
||||
class GlccMediumTermExamineMaterial < ActiveRecord::Base
|
||||
self.table_name = "glcc_medium_term_examine_material"
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: ignores
|
||||
# user_id
|
||||
# student_name
|
||||
# school
|
||||
# profession
|
||||
# location
|
||||
# grade
|
||||
# phone
|
||||
# mail
|
||||
# created_on
|
||||
# is_delete
|
||||
# prove_attachment_id
|
||||
# cancel_count
|
||||
# round
|
||||
# Table name: glcc_registration_student
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# student_name :string(255)
|
||||
# school :string(255)
|
||||
# profession :string(255)
|
||||
# location :string(255)
|
||||
# grade :string(255)
|
||||
# phone :string(255)
|
||||
# mail :string(255)
|
||||
# created_on :datetime
|
||||
# is_delete :boolean default("0"), not null
|
||||
# prove_attachment_id :integer
|
||||
# cancel_count :integer default("0")
|
||||
# round :integer default("1"), not null
|
||||
#
|
||||
|
||||
class GlccRegistrationStudent < ActiveRecord::Base
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
# agreement :text(65535)
|
||||
# status :text(65535)
|
||||
# help_center :text(65535)
|
||||
# join_us :text(65535)
|
||||
#
|
||||
|
||||
class Help < ApplicationRecord
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: identity_verifications
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# number :string(255) not null
|
||||
# name :string(255) not null
|
||||
# card_front :integer
|
||||
# card_back :integer
|
||||
# hold_card_front :integer
|
||||
# hold_card_back :integer
|
||||
# state :integer default("0")
|
||||
# description :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_identity_verifications_on_number (number)
|
||||
#
|
||||
|
||||
class IdentityVerification < ApplicationRecord
|
||||
belongs_to :user
|
||||
enum state: { "待审核": 0, "已通过": 1, "已拒绝": 2}
|
||||
|
||||
after_save do
|
||||
if state == "已通过"
|
||||
user.update(id_card_verify: true, website_permission: true)
|
||||
end
|
||||
end
|
||||
|
||||
def card_front_attachment
|
||||
Attachment.find_by_id card_front
|
||||
end
|
||||
|
||||
def card_back_attachment
|
||||
Attachment.find_by_id card_back
|
||||
end
|
||||
|
||||
def hold_card_front_attachment
|
||||
Attachment.find_by_id hold_card_front
|
||||
end
|
||||
|
||||
def hold_card_back_attachment
|
||||
Attachment.find_by_id hold_card_back
|
||||
end
|
||||
end
|
|
@ -1,3 +1,26 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: open_shixuns
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255)
|
||||
# shixun_user_name :string(255)
|
||||
# shixun_user_phone :string(255)
|
||||
# shixun_user_mail :string(255)
|
||||
# shixun_identifier :string(255)
|
||||
# git_url :string(255)
|
||||
# identifier :string(255)
|
||||
# myshixun_git_url :string(255)
|
||||
# myshixun_user_name :string(255)
|
||||
# myshixun_user_phone :string(255)
|
||||
# myshixun_user_mail :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# idx_email (myshixun_user_mail)
|
||||
# idx_phone (myshixun_user_phone)
|
||||
#
|
||||
|
||||
|
||||
|
||||
# for oauth2 application
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# content :text(65535)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# is_secret :boolean default("0")
|
||||
#
|
||||
|
||||
class License < ApplicationRecord
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# course_group_id :integer default("0")
|
||||
# is_collect :integer default("1")
|
||||
# graduation_group_id :integer default("0")
|
||||
# is_apply_signature :boolean default("0")
|
||||
# team_user_id :integer
|
||||
#
|
||||
# Indexes
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
# devops_step :integer default("0")
|
||||
# sign_cla :boolean default("0")
|
||||
# enabling_cla :boolean default("0")
|
||||
# id_card_verify :boolean default("0")
|
||||
# website_permission :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# id :integer not null, primary key
|
||||
# user_id :integer
|
||||
# organization_id :integer
|
||||
# is_creator :boolean default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: pages
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# project_id :integer not null
|
||||
# identifier :string(255)
|
||||
# site_name :string(255)
|
||||
# language_frame :integer default("0")
|
||||
# theme :string(255)
|
||||
# last_build_at :datetime
|
||||
# state :boolean default("1")
|
||||
# state_description :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_pages_on_project_id (project_id)
|
||||
# index_pages_on_user_id (user_id)
|
||||
#
|
||||
|
||||
class Page < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
|
||||
# language_frame 前端语言框架
|
||||
enum language_frame: { hugo: 0, hexo: 1, jeklly: 2}
|
||||
|
||||
after_create do
|
||||
PageService.genernate_user(user_id)
|
||||
end
|
||||
|
||||
before_save do
|
||||
if state_changed? && state == false
|
||||
PageService.close_site(user_id, identifier)
|
||||
end
|
||||
end
|
||||
|
||||
def deploy_page(branch)
|
||||
PageService.deploy_page(branch,self.id)
|
||||
end
|
||||
|
||||
def url
|
||||
"http://#{user.login}.kingchan.cn/#{identifier}"
|
||||
end
|
||||
|
||||
end
|
|
@ -55,13 +55,14 @@
|
|||
# default_branch :string(255) default("master")
|
||||
# website :string(255)
|
||||
# lesson_url :string(255)
|
||||
# use_blockchain :boolean default("0")
|
||||
# is_pinned :boolean default("0")
|
||||
# recommend_index :integer default("0")
|
||||
# use_blockchain :boolean default("0")
|
||||
# pr_view_admin :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_projects_on_forked_count (forked_count)
|
||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||
# index_projects_on_identifier (identifier)
|
||||
# index_projects_on_invite_code (invite_code)
|
||||
|
@ -71,6 +72,7 @@
|
|||
# index_projects_on_license_id (license_id)
|
||||
# index_projects_on_name (name)
|
||||
# index_projects_on_platform (platform)
|
||||
# index_projects_on_praises_count (praises_count)
|
||||
# index_projects_on_project_category_id (project_category_id)
|
||||
# index_projects_on_project_language_id (project_language_id)
|
||||
# index_projects_on_project_type (project_type)
|
||||
|
@ -78,6 +80,7 @@
|
|||
# index_projects_on_rgt (rgt)
|
||||
# index_projects_on_status (status)
|
||||
# index_projects_on_updated_on (updated_on)
|
||||
# index_projects_on_user_id (user_id)
|
||||
#
|
||||
|
||||
class Project < ApplicationRecord
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# Indexes
|
||||
#
|
||||
# index_project_categories_on_ancestry (ancestry)
|
||||
# index_project_categories_on_id (id)
|
||||
#
|
||||
|
||||
class ProjectCategory < ApplicationRecord
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_project_languages_on_id (id)
|
||||
#
|
||||
|
||||
class ProjectLanguage < ApplicationRecord
|
||||
include Projectable
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_name (project_id)
|
||||
# index_repositories_on_identifier (identifier)
|
||||
# index_repositories_on_project_id (project_id)
|
||||
# index_repositories_on_user_id (user_id)
|
||||
|
|
|
@ -15,23 +15,6 @@
|
|||
# auto_users_trial :boolean default("0")
|
||||
# shool_code :string(255)
|
||||
# authorization_time :datetime
|
||||
# ec_auth :integer default("0")
|
||||
# identifier :string(255)
|
||||
# is_online :boolean default("0")
|
||||
# video_name :string(255)
|
||||
# video_desc :string(255)
|
||||
# course_link :string(255)
|
||||
# course_name :string(255)
|
||||
# partner_id :integer
|
||||
# customer_id :integer
|
||||
# school_property_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_schools_on_customer_id (customer_id)
|
||||
# index_schools_on_identifier (identifier)
|
||||
# index_schools_on_partner_id (partner_id)
|
||||
# index_schools_on_school_property_id (school_property_id)
|
||||
#
|
||||
|
||||
class School < ApplicationRecord
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
# devops_step :integer default("0")
|
||||
# sign_cla :boolean default("0")
|
||||
# enabling_cla :boolean default("0")
|
||||
# id_card_verify :boolean default("0")
|
||||
# website_permission :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -120,6 +122,7 @@ class User < Owner
|
|||
has_many :open_users, dependent: :destroy
|
||||
has_one :wechat_open_user, class_name: 'OpenUsers::Wechat'
|
||||
has_one :qq_open_user, class_name: 'OpenUsers::Qq'
|
||||
has_one :identity_verification
|
||||
accepts_nested_attributes_for :user_extension, update_only: true
|
||||
has_many :fork_users, dependent: :destroy
|
||||
|
||||
|
@ -186,6 +189,8 @@ class User < Owner
|
|||
has_many :user_clas, :dependent => :destroy
|
||||
has_many :clas, through: :user_clas
|
||||
|
||||
has_many :pages, :dependent => :destroy
|
||||
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
||||
scope :like, lambda { |keywords|
|
||||
|
@ -758,6 +763,7 @@ class User < Owner
|
|||
if password
|
||||
salt_password(password)
|
||||
end
|
||||
check_website_permission
|
||||
end
|
||||
|
||||
def salt_password(clear_password)
|
||||
|
@ -765,6 +771,13 @@ class User < Owner
|
|||
self.hashed_password = User.hash_password("#{salt}#{User.hash_password clear_password}")
|
||||
end
|
||||
|
||||
def check_website_permission
|
||||
if website_permission_changed? && website_permission == false
|
||||
self.pages.update_all(state: false, state_description:"因违规使用,现关闭Page服务")
|
||||
PageService.close_site(self.id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.generate_salt
|
||||
Gitlink::Utils.random_hex(16)
|
||||
end
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
# school_id :integer
|
||||
# description :string(255)
|
||||
# department_id :integer
|
||||
# province :string(255)
|
||||
# city :string(255)
|
||||
# province :text(65535)
|
||||
# custom_department :string(255)
|
||||
# city :string(255)
|
||||
# show_email :boolean default("0")
|
||||
# show_location :boolean default("0")
|
||||
# show_department :boolean default("0")
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
class Admins::IdentityVerificationQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
state = params[:state].blank? ? [0,1,2] : params[:state].to_i
|
||||
applies = IdentityVerification.where(state: state)
|
||||
custom_sort(applies, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
class Admins::SitePagesQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :created_at, default_by: :created_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
state = params[:state].blank? ? [true,false] : params[:state]
|
||||
pages = Page.joins(:user).where(state: state)
|
||||
# 关键字检索
|
||||
keyword = params[:keyword].to_s.strip.presence
|
||||
if keyword
|
||||
sql = 'users.nickname LIKE :keyword OR users.login LIKE :keyword OR users.mail LIKE :keyword OR users.phone LIKE :keyword'
|
||||
pages = pages.where(sql, keyword: "%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(pages, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class PageQuery < ApplicationQuery
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params, user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
def call
|
||||
pages = Page.where(user: @user)
|
||||
|
||||
pages
|
||||
end
|
||||
end
|
|
@ -32,7 +32,7 @@ class Admins::UpdateUserService < ApplicationService
|
|||
|
||||
def user_attributes
|
||||
params.slice(*%i[lastname nickname mail phone admin business is_test login
|
||||
professional_certification authentication is_shixun_marker])
|
||||
professional_certification authentication is_shixun_marker website_permission])
|
||||
end
|
||||
|
||||
def user_extension_attributes
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
class PageService
|
||||
def self.genernate_user(user_id)
|
||||
Rails.logger.info "################### PageService genernate_user #{user_id}"
|
||||
user = User.find user_id
|
||||
if user.id_card_verify == true && user.website_permission == true
|
||||
uri = URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=create_dir&owner=#{user.login.downcase}")
|
||||
response = Net::HTTP.get_response(uri)
|
||||
end
|
||||
Rails.logger.info "################### PageService genernate_user end #{response.body}"
|
||||
return response.body
|
||||
end
|
||||
|
||||
def self.close_site(user_id,identifier=nil)
|
||||
Rails.logger.info "################### PageService close_site #{user_id} / #{identifier}"
|
||||
user = User.find user_id
|
||||
uri = if identifier.present?
|
||||
URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=remove_dir&owner=#{user.login.downcase}/#{identifier}/")
|
||||
else
|
||||
URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=remove_dir&owner=#{user.login.downcase}/")
|
||||
end
|
||||
response = Net::HTTP.get_response(uri)
|
||||
Rails.logger.info "################### PageService close_site end #{response.body}"
|
||||
return response.body
|
||||
end
|
||||
|
||||
def self.deploy_page(branch, page_id)
|
||||
Rails.logger.info "################### PageService deploy #{branch} for page #{page_id}"
|
||||
page = Page.find page_id
|
||||
user = page.user
|
||||
project = page.project
|
||||
owner = user.login.downcase
|
||||
|
||||
project_dir = page.identifier
|
||||
repo_link = project.repository.url
|
||||
repo = project.repository.identifier
|
||||
branch = branch
|
||||
script_path = nil
|
||||
script_path = case page.language_frame
|
||||
when "hugo"
|
||||
"hugo_build"
|
||||
|
||||
when "jekyll"
|
||||
"jekyll_build"
|
||||
|
||||
when "hexo"
|
||||
"hexo_build"
|
||||
else
|
||||
"hugo_build"
|
||||
end
|
||||
|
||||
if script_path.present?
|
||||
uri = URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=#{script_path}&project_dir=#{project_dir}&repo=#{repo}&repo_link=#{repo_link}&branch=#{branch}&owner=#{owner}")
|
||||
response = Net::HTTP.get_response(uri)
|
||||
Rails.logger.info "################### PageService deploy #{response.body}"
|
||||
return response.body
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,131 @@
|
|||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('用户管理', admins_identity_verifications_path)
|
||||
add_admin_breadcrumb('用户身份审核详情')
|
||||
end
|
||||
%>
|
||||
|
||||
<div class="box identity_verification-edit-container">
|
||||
<div class="identity_verification-info mb-4 row">
|
||||
<%= link_to "/#{@identity_verification.user.login}", class: 'user-info-avatar col-md-1', target: '_blank', data: { toggle: 'tooltip', title: '个人中心' } do %>
|
||||
<img src="/<%= url_to_avatar(@user) %>" class="rounded-circle" width="80" height="80" />
|
||||
<% end %>
|
||||
<div class="d-flex flex-column justify-content-between col-md-3 user-info-content">
|
||||
<div class="user-info-name flex"><%= @user.real_name %> | <%= @user.id %> | <%= @user.login %></div>
|
||||
|
||||
<div class="d-flex flex-row user-info-auth">
|
||||
<% if @user.authentication? %>
|
||||
<i class="fa fa-user text-success" data-toggle="tooltip" data-placement="bottom" title="已实名认证"></i>
|
||||
<% elsif @user.process_real_name_apply.present? %>
|
||||
<i class="fa fa-user text-danger" data-toggle="tooltip" data-placement="bottom" title="实名认证中"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-user text-muted" data-toggle="tooltip" data-placement="bottom" title="未实名认证"></i>
|
||||
<% end %>
|
||||
|
||||
<% if @user.professional_certification %>
|
||||
<i class="fa fa-list-alt text-success" data-toggle="tooltip" data-placement="bottom" title="已职业认证"></i>
|
||||
<% elsif @user.process_professional_apply.present? %>
|
||||
<i class="fa fa-list-alt text-danger" data-toggle="tooltip" data-placement="bottom" title="职业认证中"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-list-alt text-muted" data-toggle="tooltip" data-placement="bottom" title="未职业认证"></i>
|
||||
<% end %>
|
||||
|
||||
<% if @user.phone.present? %>
|
||||
<i class="fa fa-mobile text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定手机"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-mobile text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定手机"></i>
|
||||
<% end %>
|
||||
|
||||
<% if @user.mail.present? %>
|
||||
<i class="fa fa-envelope text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定邮箱"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-envelope text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定邮箱"></i>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="user-info-last-login">最近登录:<%= @user.last_login_on&.strftime('%Y-%m-%d %H:%M') %></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= simple_form_for(@identity_verification, url: admins_identity_verification_path(@identity_verification)) do |f| %>
|
||||
|
||||
<div class="mt-4">
|
||||
<h6>审核信息</h6>
|
||||
<label>当前身份审核状态为 <b><%=@identity_verification.state %></b></label>
|
||||
|
||||
<div class="form-row">
|
||||
<%= f.input :name, label: '姓名', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-11' , value: @identity_verification.name } %>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<%= f.input :number, label: '身份证号', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-11' , value: @identity_verification.number } %>
|
||||
</div>
|
||||
<label>身份证正面: </label>
|
||||
<div class="form-row">
|
||||
<td>
|
||||
<% if @identity_verification.card_front_attachment.present? %>
|
||||
<%= link_to "#{@identity_verification.card_front_attachment.try(:filename)}",attachment_path(@identity_verification.card_front_attachment), target: "_blank" %>
|
||||
<%else%>
|
||||
<p> 图片无法展示,图片已丢失</p>
|
||||
<%end%>
|
||||
</td>
|
||||
</div>
|
||||
<label>身份证背面: </label>
|
||||
<div class="form-row">
|
||||
<td>
|
||||
<% if @identity_verification.card_back_attachment.present? %>
|
||||
<%= link_to "#{@identity_verification.card_back_attachment.try(:filename)}",attachment_path(@identity_verification.card_back_attachment), target: "_blank" %>
|
||||
<%else%>
|
||||
<p> 图片无法展示,图片已丢失</p>
|
||||
<%end%>
|
||||
</td>
|
||||
</div>
|
||||
<label>手持身份证正面: </label>
|
||||
<div class="form-row">
|
||||
<td>
|
||||
<% if @identity_verification.hold_card_front_attachment.present? %>
|
||||
<%= link_to "#{@identity_verification.hold_card_front_attachment.try(:filename)}",attachment_path(@identity_verification.hold_card_front_attachment), target: "_blank" %>
|
||||
<%else%>
|
||||
<p> 图片无法展示,图片已丢失</p>
|
||||
<%end%>
|
||||
</td>
|
||||
</div>
|
||||
<label>手持身份证背面: </label>
|
||||
<div class="form-row">
|
||||
<td>
|
||||
<% if @identity_verification.hold_card_back_attachment.present? %>
|
||||
<%= link_to "#{@identity_verification.hold_card_back_attachment.try(:filename)}",attachment_path(@identity_verification.hold_card_back_attachment), target: "_blank" %>
|
||||
<%else%>
|
||||
<p> 图片无法展示,图片已丢失</p>
|
||||
<%end%>
|
||||
</td>
|
||||
</div>
|
||||
</br>
|
||||
<div class="form-row">
|
||||
<label><b>是否通过身份证审核: </b></label>
|
||||
</div>
|
||||
<b>
|
||||
|
||||
<% if @identity_verification.state == "已通过" %>
|
||||
<div class="form-row">
|
||||
<p> 用户身份审核已通过</p>
|
||||
</div>
|
||||
<%else%>
|
||||
<div class="form-row">
|
||||
<%= f.radio_button :state, '已通过' %> 通过
|
||||
<%= f.radio_button :state, '已拒绝' %> 拒绝
|
||||
</div>
|
||||
</br>
|
||||
<div class="form-row">
|
||||
<%= f.input :description, as: :text,label: '拒绝理由:(拒绝时请填写拒绝理由,可以为空)', wrapper_html: { class: 'col-md-12' }, input_html: { maxlength: 100, size: 40, class: 'col-md-11' , value: @identity_verification.description } %>
|
||||
</div>
|
||||
<div class="form-row mt-4">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %>
|
||||
<%= link_to '取消', admins_identity_verifications_path, class: 'btn btn-secondary px-4' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</b>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,21 @@
|
|||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('用户管理', admins_identity_verifications_path) %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container user-list-form">
|
||||
<%= form_tag(admins_identity_verifications_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<div class="form-group mr-2">
|
||||
<label for="state">状态:</label>
|
||||
<% state_options = [['全部',nil], ['待审核', 0], ['已通过', 1], ['已拒绝', 2]] %>
|
||||
<%= select_tag(:state, options_for_select(state_options), class: 'form-control') %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container identity-verifications-list-container">
|
||||
<%= render partial: 'admins/identity_verifications/shared/info_list', locals: { identity_verifications: @identity_verifications } %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1 @@
|
|||
$('.identity-verifications-list-container').html("<%= j( render partial: 'admins/identity_verifications/shared/info_list', locals: { identity_verifications: @identity_verifications } ) %>");
|
|
@ -0,0 +1,35 @@
|
|||
<table class="table table-hover identity-verifications-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="10%">序号</th>
|
||||
<th width="10%" class="text-left">昵称</th>
|
||||
<th width="10%">审核状态</th>
|
||||
<th width="10%"><%= sort_tag('创建于', name: 'created_at', path: admins_identity_verifications_path) %></th>
|
||||
<th width="14%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if identity_verifications.present? %>
|
||||
<% identity_verifications.each_with_index do |identity_verification, index| %>
|
||||
<tr class="identity-verification-item-<%= identity_verification.id %>">
|
||||
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||
<td class="text-left">
|
||||
<%= link_to "/#{identity_verification.user.login}", target: '_blank' do %>
|
||||
<%= overflow_hidden_span identity_verification.user.real_name, width: 100 %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= display_text(identity_verification.state) %></td>
|
||||
|
||||
<td><%= display_text(identity_verification.created_at&.strftime('%Y-%m-%d %H:%M')) %></td>
|
||||
<td class="action-container">
|
||||
<%= link_to "#{ identity_verification.state == "待审核" ? '审核' : "查看"}", edit_admins_identity_verification_path(identity_verification), class: 'action' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: identity_verifications } %>
|
|
@ -24,6 +24,8 @@
|
|||
<%= sidebar_item_group('#user-submenu', '用户', icon: 'user') do %>
|
||||
<li><%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users') %></li>
|
||||
<li><%= sidebar_item(admins_organizations_path, '组织列表', icon: 'user', controller: 'admins-organizations') %></li>
|
||||
<li><%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications') %></li>
|
||||
<li><%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'user', controller: 'admins-site_pages') %></li>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('用户管理', admins_site_pages_path)
|
||||
add_admin_breadcrumb('站点列表')
|
||||
end
|
||||
%>
|
||||
|
||||
<div class="box site_page-edit-container">
|
||||
<div class="site_page-info mb-4 row">
|
||||
<%= link_to "/#{@site_page.user.login}", class: 'user-info-avatar col-md-1', target: '_blank', data: { toggle: 'tooltip', title: '个人中心' } do %>
|
||||
<img src="/<%= url_to_avatar(@user) %>" class="rounded-circle" width="80" height="80" />
|
||||
<% end %>
|
||||
|
||||
<div class="d-flex flex-column justify-content-between col-md-3 user-info-content">
|
||||
<div class="user-info-name flex"><%= @user.real_name %> | <%= @user.id %> | <%= @user.login %></div>
|
||||
|
||||
<div class="d-flex flex-row user-info-auth">
|
||||
<% if @user.authentication? %>
|
||||
<i class="fa fa-user text-success" data-toggle="tooltip" data-placement="bottom" title="已实名认证"></i>
|
||||
<% elsif @user.process_real_name_apply.present? %>
|
||||
<i class="fa fa-user text-danger" data-toggle="tooltip" data-placement="bottom" title="实名认证中"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-user text-muted" data-toggle="tooltip" data-placement="bottom" title="未实名认证"></i>
|
||||
<% end %>
|
||||
|
||||
<% if @user.professional_certification %>
|
||||
<i class="fa fa-list-alt text-success" data-toggle="tooltip" data-placement="bottom" title="已职业认证"></i>
|
||||
<% elsif @user.process_professional_apply.present? %>
|
||||
<i class="fa fa-list-alt text-danger" data-toggle="tooltip" data-placement="bottom" title="职业认证中"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-list-alt text-muted" data-toggle="tooltip" data-placement="bottom" title="未职业认证"></i>
|
||||
<% end %>
|
||||
|
||||
<% if @user.phone.present? %>
|
||||
<i class="fa fa-mobile text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定手机"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-mobile text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定手机"></i>
|
||||
<% end %>
|
||||
|
||||
<% if @user.mail.present? %>
|
||||
<i class="fa fa-envelope text-success" data-toggle="tooltip" data-placement="bottom" title="已绑定邮箱"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-envelope text-muted" data-toggle="tooltip" data-placement="bottom" title="未绑定邮箱"></i>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="user-info-last-login">最近登录:<%= @user.last_login_on&.strftime('%Y-%m-%d %H:%M') %></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= simple_form_for(@site_page, url: admins_site_page_path(@site_page)) do |f| %>
|
||||
|
||||
<div class="mt-4">
|
||||
<h6>审核信息</h6>
|
||||
<label>当前身份审核状态为 <b><%=@site_page.state %></b></label>
|
||||
|
||||
<div class="form-row">
|
||||
<%= f.input :identifier, label: '站点标识', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.identifier } %>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<%= f.input :site_name, label: '站点名', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.site_name } %>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<%= f.input :language_frame, label: '建站工具', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.language_frame } %>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<%= f.input :theme, label: '主题', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.theme } %>
|
||||
</div>
|
||||
</br>
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<label>当前站点:</label>
|
||||
<a href="<%= @site_page.url%>" target="_blank"> <%= @site_page.url%> </a>
|
||||
</div>
|
||||
</br>
|
||||
<div class="form-row">
|
||||
<label>是否关闭站点? </label>
|
||||
<%= f.radio_button :state, 'false' %> 关闭
|
||||
</div>
|
||||
</br>
|
||||
<div class="form-row">
|
||||
<label>注意,因为关闭站点涉及操作另外一台服务器,所以站点关闭后<b>无法重新打开</b>,请谨慎操作, 关闭站点后该仓库再也不能进行 <b>开通站点、部署等</b>操作 </label>
|
||||
</div>
|
||||
</br>
|
||||
<div class="form-row">
|
||||
<%= f.input :state_description, as: :text,label: '关闭理由,如需关闭 理由不能为空', wrapper_html: { class: 'col-md-12' }, input_html: { maxlength: 100, size: 40, class: 'col-md-11' , value: @site_page.state_description } %>
|
||||
</div>
|
||||
|
||||
<div class="form-row mt-4">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %>
|
||||
<%= link_to '取消', admins_site_pages_path, class: 'btn btn-secondary px-4' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,21 @@
|
|||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('用户管理', admins_site_pages_path) %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container user-list-form">
|
||||
<%= form_tag(admins_site_pages_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<div class="form-group mr-2">
|
||||
<label for="state">状态:</label>
|
||||
<% state_options = [['全部',nil], ['正常', true], ['已关闭', false]] %>
|
||||
<%= select_tag(:state, options_for_select(state_options), class: 'form-control') %>
|
||||
</div>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '输入用户 ID/姓名/邮箱/手机号 检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container identity-site-pages-list-container">
|
||||
<%= render partial: 'admins/site_pages/shared/info_list', locals: { site_pages: @site_pages } %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1 @@
|
|||
$('.identity-site-pages-list-container').html("<%= j( render partial: 'admins/site_pages/shared/info_list', locals: { site_pages: @site_pages } ) %>");
|
|
@ -0,0 +1,58 @@
|
|||
<table class="table table-hover identity-verifications-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="10%">序号</th>
|
||||
<th width="10%" class="text-left">昵称</th>
|
||||
<th width="10%" class="text-left">仓库</th>
|
||||
<th width="10%">站点状态</th>
|
||||
<th width="10%" class="text-left">站点名</th>
|
||||
<th width="10%" class="text-left">站点标识</th>
|
||||
<th width="20%" class="text-left">站点地址</th>
|
||||
|
||||
<th width="10%" class="text-left">建站工具</th>
|
||||
<th width="10%" class="text-left">主题</th>
|
||||
<th width="10%" class="text-left">上次构建时间</th>
|
||||
|
||||
|
||||
<th width="10%"><%= sort_tag('创建于', name: 'created_at', path: admins_site_pages_path) %></th>
|
||||
<th width="14%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if site_pages.present? %>
|
||||
<% site_pages.each_with_index do |site_page, index| %>
|
||||
<tr class="identity-verification-item-<%= site_page.id %>">
|
||||
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||
<td class="text-left">
|
||||
<%= link_to "/#{site_page.user.login}", target: '_blank' do %>
|
||||
<%= overflow_hidden_span site_page.user.real_name, width: 100 %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="text-left">
|
||||
<%= link_to "/#{site_page.user.login}/#{site_page.project.identifier}", target: '_blank' do %>
|
||||
<%= overflow_hidden_span site_page.project.name, width: 100 %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= display_text(site_page.state == true ? "已正常" : "关闭") %></td>
|
||||
<td><%= display_text(site_page.site_name) %></td>
|
||||
<td><%= display_text(site_page.identifier) %></td>
|
||||
<td><%= link_to "#{site_page.url}", site_page.url, target: '_blank'%></td>
|
||||
|
||||
<td><%= display_text(site_page.language_frame) %></td>
|
||||
<td><%= display_text(site_page.theme) %></td>
|
||||
<td><%= display_text(site_page.last_build_at&.strftime('%Y-%m-%d %H:%M')) %></td>
|
||||
|
||||
<td><%= display_text(site_page.created_at&.strftime('%Y-%m-%d %H:%M')) %></td>
|
||||
|
||||
<td class="action-container">
|
||||
<%= link_to "查看", edit_admins_site_page_path(site_page), class: 'action' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: site_pages } %>
|
|
@ -92,8 +92,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<% if @user.id_card_verify %>
|
||||
<div class="form-group check_boxes optional">
|
||||
<%= f.label :role, label: '站点权限' %>
|
||||
<div class="d-flex">
|
||||
<%= f.input :website_permission, as: :boolean, label: '开通站点', checked_value: 1, unchecked_value: 0 %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-row">
|
||||
<%= f.input :password, as: :password, label: '修改密码', wrapper_html: { class: 'col-md-3' }, input_html: { class: 'col-sm-11', autocomplete: 'new-password' } %>
|
||||
<%= f.input :password_confirmation, as: :password, label: '确认密码', wrapper_html: { class: 'col-md-3' }, input_html: { class: 'col-sm-11', autocomplete: 'new-password' } %>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
json.id id_verify.id
|
||||
json.number id_verify.number
|
||||
json.name id_verify.name
|
||||
json.card_front id_verify.card_front
|
||||
json.card_back id_verify.card_back
|
||||
json.hold_card_front id_verify.hold_card_front
|
||||
json.hold_card_back id_verify.hold_card_back
|
||||
json.state id_verify.state
|
||||
json.description id_verify.description
|
||||
json.created_at id_verify.created_at.strftime("%Y-%m-%d %H:%M")
|
|
@ -0,0 +1 @@
|
|||
json.partial! 'info', locals: {id_verify: @id_verify}
|
|
@ -0,0 +1 @@
|
|||
json.partial! 'info', locals: {id_verify: @id_verify}
|
|
@ -0,0 +1 @@
|
|||
json.partial! 'info', locals: {id_verify: @id_verify}
|
|
@ -0,0 +1,12 @@
|
|||
json.id page.id
|
||||
json.identifier page.identifier
|
||||
json.owner page.user.login
|
||||
json.repo page.project.identifier
|
||||
json.user_id page.user_id
|
||||
json.project_id page.project_id
|
||||
json.site_name page.site_name
|
||||
json.theme page.theme
|
||||
json.language_frame page.language_frame
|
||||
json.url page.url
|
||||
json.created_at page.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
||||
json.last_build_at page.last_build_at.nil? ? nil : page.last_build_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
@ -0,0 +1 @@
|
|||
json.partial! "info", page: @page
|
|
@ -0,0 +1,4 @@
|
|||
json.total_count @pages.size
|
||||
json.pages @pages.each do |page|
|
||||
json.partial! 'info', locals: {page: page}
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
json.partial! 'info', locals: {page: @page}
|
|
@ -30,3 +30,5 @@ json.is_new params[:login].present? && (UserAction.where(action_type: "sync_educ
|
|||
json.nps EduSetting.get("nps-on-off-switch").to_s == 'true' && UserNp.where(user_id: current_user.id).where("created_at >= ?", (Time.now - 30.days).beginning_of_day ).blank?
|
||||
json.open_blockchain EduSetting.get("open_blockchain_users").to_s.split(",").include?(@user.id.to_s) || EduSetting.get("open_blockchain_users").to_s.split(",").include?(@user.login)
|
||||
json.sign_cla @user.sign_cla
|
||||
json.id_card_verify @user.id_card_verify
|
||||
json.website_permission @user.website_permission
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
hugo:
|
||||
-
|
||||
name: "hugo无主题"
|
||||
imgage_url: "https://pic1.zhimg.com/50/v2-02ed5def1f25e0de21f40eb9f96d28b9_200x0.jpg?source=b6762063"
|
||||
clone_url: "https://gitlink.org.cn/SiteTheme/hugo.git"
|
||||
-
|
||||
name: "hugo主题1"
|
||||
imgage_url: "https://pic1.zhimg.com/50/v2-02ed5def1f25e0de21f40eb9f96d28b9_200x0.jpg?source=b6762063"
|
||||
clone_url: "https://gitlink.org.cn/SiteTheme/hugo.git"
|
||||
|
||||
|
||||
jekyll:
|
||||
-
|
||||
name: "Jekyll无主题"
|
||||
imgage_url: "https://pic1.zhimg.com/50/v2-02ed5def1f25e0de21f40eb9f96d28b9_200x0.jpg?source=b6762063"
|
||||
clone_url: "https://gitlink.org.cn/SiteTheme/hugo.git"
|
||||
-
|
||||
name: "Jekyll主题1"
|
||||
imgage_url: "https://pic1.zhimg.com/50/v2-02ed5def1f25e0de21f40eb9f96d28b9_200x0.jpg?source=b6762063"
|
||||
clone_url: "https://gitlink.org.cn/SiteTheme/hugo.git"
|
||||
|
||||
|
||||
hexo:
|
||||
-
|
||||
name: "Hexo无主题"
|
||||
imgage_url: "https://pic1.zhimg.com/50/v2-02ed5def1f25e0de21f40eb9f96d28b9_200x0.jpg?source=b6762063"
|
||||
clone_url: "https://gitlink.org.cn/SiteTheme/hugo.git"
|
||||
-
|
||||
name: "Hexo主题1"
|
||||
imgage_url: "https://pic1.zhimg.com/50/v2-02ed5def1f25e0de21f40eb9f96d28b9_200x0.jpg?source=b6762063"
|
||||
clone_url: "https://gitlink.org.cn/SiteTheme/hugo.git"
|
|
@ -89,7 +89,7 @@ Rails.application.routes.draw do
|
|||
resources :project_rank, only: [:index]
|
||||
resources :user_rank, only: [:index]
|
||||
resources :nps, only: [:create]
|
||||
|
||||
|
||||
resources :statistic, only: [:index] do
|
||||
collection do
|
||||
get :platform_profile
|
||||
|
@ -239,6 +239,7 @@ Rails.application.routes.draw do
|
|||
|
||||
collection do
|
||||
post :migrate
|
||||
post :page_migrate
|
||||
get :group_type_list
|
||||
get :recommend
|
||||
get :banner_recommend
|
||||
|
@ -479,6 +480,16 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
end
|
||||
resources :identity_verifications
|
||||
resources :site_pages do
|
||||
member do
|
||||
post :build
|
||||
end
|
||||
collection do
|
||||
post :softbot_build
|
||||
get :themes
|
||||
end
|
||||
end
|
||||
|
||||
namespace :traces do
|
||||
resources :trace_users, only: [:create]
|
||||
|
@ -802,6 +813,8 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
resources :users_rank, only: [:index]
|
||||
resources :identity_verifications
|
||||
resources :site_pages
|
||||
resources :projects_rank, only: [:index]
|
||||
resources :sites
|
||||
resources :edu_settings
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
class CreatePages < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :pages do |t|
|
||||
t.integer :user_id, null:false, index:true
|
||||
t.integer :project_id, null:false, index:true
|
||||
t.string :identifier
|
||||
t.string :site_name
|
||||
t.integer :language_frame, default: 0
|
||||
t.string :theme
|
||||
t.datetime :last_build_at
|
||||
t.boolean :state, default: true
|
||||
t.string :state_description
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
class CreateIdentityVerifications < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :identity_verifications do |t|
|
||||
t.integer :user_id, null:false
|
||||
t.string :number, null:false, index: true
|
||||
t.string :name, null:false
|
||||
t.integer :card_front
|
||||
t.integer :card_back
|
||||
t.integer :hold_card_front
|
||||
t.integer :hold_card_back
|
||||
t.integer :state, default: 0
|
||||
t.string :description
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AddIdCardVerifyToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :id_card_verify, :boolean, default: false
|
||||
add_column :users, :website_permission, :boolean, default: false
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admins::IdentityVerificationsController, type: :controller do
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admins::SitePagesController, type: :controller do
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe IdentityVerificationsController, type: :controller do
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SitePagesController, type: :controller do
|
||||
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Admins::IdentityVerificationsHelper. For example:
|
||||
#
|
||||
# describe Admins::IdentityVerificationsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Admins::IdentityVerificationsHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Admins::SitePagesHelper. For example:
|
||||
#
|
||||
# describe Admins::SitePagesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Admins::SitePagesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the IdentityVerificationsHelper. For example:
|
||||
#
|
||||
# describe IdentityVerificationsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe IdentityVerificationsHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the PagesHelper. For example:
|
||||
#
|
||||
# describe PagesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe PagesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe IdentityVerification, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Page, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue