diff --git a/app/assets/javascripts/admins/identity_verifications.js b/app/assets/javascripts/admins/identity_verifications.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/admins/identity_verifications.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. diff --git a/app/assets/javascripts/admins/site_pages.js b/app/assets/javascripts/admins/site_pages.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/admins/site_pages.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. diff --git a/app/assets/javascripts/identity_verifications.js b/app/assets/javascripts/identity_verifications.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/identity_verifications.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. diff --git a/app/assets/javascripts/pages.js b/app/assets/javascripts/pages.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/pages.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. diff --git a/app/assets/stylesheets/admins/identity_verifications.scss b/app/assets/stylesheets/admins/identity_verifications.scss new file mode 100644 index 000000000..c26986f12 --- /dev/null +++ b/app/assets/stylesheets/admins/identity_verifications.scss @@ -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/ diff --git a/app/assets/stylesheets/admins/site_pages.scss b/app/assets/stylesheets/admins/site_pages.scss new file mode 100644 index 000000000..f84f347b4 --- /dev/null +++ b/app/assets/stylesheets/admins/site_pages.scss @@ -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/ diff --git a/app/assets/stylesheets/identity_verifications.scss b/app/assets/stylesheets/identity_verifications.scss new file mode 100644 index 000000000..f2edc1e20 --- /dev/null +++ b/app/assets/stylesheets/identity_verifications.scss @@ -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/ diff --git a/app/assets/stylesheets/pages.scss b/app/assets/stylesheets/pages.scss new file mode 100644 index 000000000..0d6878aa1 --- /dev/null +++ b/app/assets/stylesheets/pages.scss @@ -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/ diff --git a/app/controllers/admins/identity_verifications_controller.rb b/app/controllers/admins/identity_verifications_controller.rb new file mode 100644 index 000000000..f5d5a11e3 --- /dev/null +++ b/app/controllers/admins/identity_verifications_controller.rb @@ -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 diff --git a/app/controllers/admins/site_pages_controller.rb b/app/controllers/admins/site_pages_controller.rb new file mode 100644 index 000000000..04bff32c7 --- /dev/null +++ b/app/controllers/admins/site_pages_controller.rb @@ -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 diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index 9137e218e..b948f8232 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -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 diff --git a/app/controllers/identity_verifications_controller.rb b/app/controllers/identity_verifications_controller.rb new file mode 100644 index 000000000..4542163ab --- /dev/null +++ b/app/controllers/identity_verifications_controller.rb @@ -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 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 04982d8ce..c7caec807 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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? diff --git a/app/controllers/site_pages_controller.rb b/app/controllers/site_pages_controller.rb new file mode 100644 index 000000000..444838b26 --- /dev/null +++ b/app/controllers/site_pages_controller.rb @@ -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 diff --git a/app/helpers/admins/identity_verifications_helper.rb b/app/helpers/admins/identity_verifications_helper.rb new file mode 100644 index 000000000..c44651a7f --- /dev/null +++ b/app/helpers/admins/identity_verifications_helper.rb @@ -0,0 +1,2 @@ +module Admins::IdentityVerificationsHelper +end diff --git a/app/helpers/admins/site_pages_helper.rb b/app/helpers/admins/site_pages_helper.rb new file mode 100644 index 000000000..d21cdefb9 --- /dev/null +++ b/app/helpers/admins/site_pages_helper.rb @@ -0,0 +1,2 @@ +module Admins::SitePagesHelper +end diff --git a/app/helpers/identity_verifications_helper.rb b/app/helpers/identity_verifications_helper.rb new file mode 100644 index 000000000..acd433185 --- /dev/null +++ b/app/helpers/identity_verifications_helper.rb @@ -0,0 +1,2 @@ +module IdentityVerificationsHelper +end diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb new file mode 100644 index 000000000..2c057fd05 --- /dev/null +++ b/app/helpers/pages_helper.rb @@ -0,0 +1,2 @@ +module PagesHelper +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0c056f60c..f79aca153 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -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 # diff --git a/app/models/bot.rb b/app/models/bot.rb index 13ac70a78..e7a14d009 100644 --- a/app/models/bot.rb +++ b/app/models/bot.rb @@ -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 # diff --git a/app/models/bot_install.rb b/app/models/bot_install.rb index d5283c131..57e5a750b 100644 --- a/app/models/bot_install.rb +++ b/app/models/bot_install.rb @@ -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 diff --git a/app/models/ci/user.rb b/app/models/ci/user.rb index 62ed4c447..aae6e601c 100644 --- a/app/models/ci/user.rb +++ b/app/models/ci/user.rb @@ -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 # diff --git a/app/models/glcc_medium_term_examine_material.rb b/app/models/glcc_medium_term_examine_material.rb index 1e7c3bedb..e2ec7aec2 100644 --- a/app/models/glcc_medium_term_examine_material.rb +++ b/app/models/glcc_medium_term_examine_material.rb @@ -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" diff --git a/app/models/glcc_registration_student.rb b/app/models/glcc_registration_student.rb index 3ea0c3134..5dd988c95 100644 --- a/app/models/glcc_registration_student.rb +++ b/app/models/glcc_registration_student.rb @@ -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 diff --git a/app/models/help.rb b/app/models/help.rb index 5a4c480b4..8e0bcad78 100644 --- a/app/models/help.rb +++ b/app/models/help.rb @@ -9,7 +9,6 @@ # agreement :text(65535) # status :text(65535) # help_center :text(65535) -# join_us :text(65535) # class Help < ApplicationRecord diff --git a/app/models/identity_verification.rb b/app/models/identity_verification.rb new file mode 100644 index 000000000..983755b16 --- /dev/null +++ b/app/models/identity_verification.rb @@ -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 diff --git a/app/models/import_repo.rb b/app/models/import_repo.rb index 8b53a7765..24c96a715 100644 --- a/app/models/import_repo.rb +++ b/app/models/import_repo.rb @@ -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 diff --git a/app/models/license.rb b/app/models/license.rb index d14a9db14..f84e63573 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -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 diff --git a/app/models/member.rb b/app/models/member.rb index 521f939c5..aaaf34efc 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -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 diff --git a/app/models/organization.rb b/app/models/organization.rb index fb1659d1a..cb829626e 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -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 # diff --git a/app/models/organization_user.rb b/app/models/organization_user.rb index 4ff6946b7..900710a9a 100644 --- a/app/models/organization_user.rb +++ b/app/models/organization_user.rb @@ -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 # diff --git a/app/models/page.rb b/app/models/page.rb new file mode 100644 index 000000000..12b5c620e --- /dev/null +++ b/app/models/page.rb @@ -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 diff --git a/app/models/project.rb b/app/models/project.rb index 3a868357c..17972dd50 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/app/models/project_category.rb b/app/models/project_category.rb index 97a304259..bc6f8427d 100644 --- a/app/models/project_category.rb +++ b/app/models/project_category.rb @@ -15,6 +15,7 @@ # Indexes # # index_project_categories_on_ancestry (ancestry) +# index_project_categories_on_id (id) # class ProjectCategory < ApplicationRecord diff --git a/app/models/project_language.rb b/app/models/project_language.rb index 0770a1efa..22a4a81ff 100644 --- a/app/models/project_language.rb +++ b/app/models/project_language.rb @@ -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 diff --git a/app/models/repository.rb b/app/models/repository.rb index f2815dde7..7d3f207ea 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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) diff --git a/app/models/school.rb b/app/models/school.rb index 5b30be9a5..d7a41c914 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 55d50ba98..8f1e29547 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/models/user_extension.rb b/app/models/user_extension.rb index ef4af5fd3..aeb9a9d83 100644 --- a/app/models/user_extension.rb +++ b/app/models/user_extension.rb @@ -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") diff --git a/app/queries/admins/identity_verification_query.rb b/app/queries/admins/identity_verification_query.rb new file mode 100644 index 000000000..a0064ec0a --- /dev/null +++ b/app/queries/admins/identity_verification_query.rb @@ -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 \ No newline at end of file diff --git a/app/queries/admins/site_pages_query.rb b/app/queries/admins/site_pages_query.rb new file mode 100644 index 000000000..75694157c --- /dev/null +++ b/app/queries/admins/site_pages_query.rb @@ -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 \ No newline at end of file diff --git a/app/queries/page_query.rb b/app/queries/page_query.rb new file mode 100644 index 000000000..50fcb92ad --- /dev/null +++ b/app/queries/page_query.rb @@ -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 \ No newline at end of file diff --git a/app/services/admins/update_user_service.rb b/app/services/admins/update_user_service.rb index 9d116cffe..4dd80b9d0 100644 --- a/app/services/admins/update_user_service.rb +++ b/app/services/admins/update_user_service.rb @@ -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 diff --git a/app/services/page_service.rb b/app/services/page_service.rb new file mode 100644 index 000000000..29b1f1004 --- /dev/null +++ b/app/services/page_service.rb @@ -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 \ No newline at end of file diff --git a/app/views/admins/identity_verifications/edit.html.erb b/app/views/admins/identity_verifications/edit.html.erb new file mode 100644 index 000000000..4719b01f0 --- /dev/null +++ b/app/views/admins/identity_verifications/edit.html.erb @@ -0,0 +1,131 @@ +<% + define_admin_breadcrumbs do + add_admin_breadcrumb('用户管理', admins_identity_verifications_path) + add_admin_breadcrumb('用户身份审核详情') + end +%> + +
+
+ <%= link_to "/#{@identity_verification.user.login}", class: 'user-info-avatar col-md-1', target: '_blank', data: { toggle: 'tooltip', title: '个人中心' } do %> + + <% end %> + +
+ + <%= simple_form_for(@identity_verification, url: admins_identity_verification_path(@identity_verification)) do |f| %> + +
+
审核信息
+ + +
+ <%= f.input :name, label: '姓名', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-11' , value: @identity_verification.name } %> +
+
+ <%= f.input :number, label: '身份证号', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-11' , value: @identity_verification.number } %> +
+ +
+ + <% 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%> +

图片无法展示,图片已丢失

+ <%end%> + +
+ +
+ + <% 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%> +

图片无法展示,图片已丢失

+ <%end%> + +
+ +
+ + <% 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%> +

图片无法展示,图片已丢失

+ <%end%> + +
+ +
+ + <% 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%> +

图片无法展示,图片已丢失

+ <%end%> + +
+
+
+ +
+ + + <% if @identity_verification.state == "已通过" %> +
+

用户身份审核已通过

+
+ <%else%> +
+ <%= f.radio_button :state, '已通过' %> 通过   + <%= f.radio_button :state, '已拒绝' %> 拒绝 +
+
+
+ <%= 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 } %> +
+
+ <%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %> + <%= link_to '取消', admins_identity_verifications_path, class: 'btn btn-secondary px-4' %> +
+ <% end %> +
+
+ + + + <% end %> +
diff --git a/app/views/admins/identity_verifications/index.html.erb b/app/views/admins/identity_verifications/index.html.erb new file mode 100644 index 000000000..d5aef6dc6 --- /dev/null +++ b/app/views/admins/identity_verifications/index.html.erb @@ -0,0 +1,21 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('用户管理', admins_identity_verifications_path) %> +<% end %> + +
+ <%= form_tag(admins_identity_verifications_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> +
+ + <% state_options = [['全部',nil], ['待审核', 0], ['已通过', 1], ['已拒绝', 2]] %> + <%= select_tag(:state, options_for_select(state_options), class: 'form-control') %> +
+ + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + <% end %> + +
+ +
+ <%= render partial: 'admins/identity_verifications/shared/info_list', locals: { identity_verifications: @identity_verifications } %> +
+ diff --git a/app/views/admins/identity_verifications/index.js.erb b/app/views/admins/identity_verifications/index.js.erb new file mode 100644 index 000000000..7b0ae2d82 --- /dev/null +++ b/app/views/admins/identity_verifications/index.js.erb @@ -0,0 +1 @@ +$('.identity-verifications-list-container').html("<%= j( render partial: 'admins/identity_verifications/shared/info_list', locals: { identity_verifications: @identity_verifications } ) %>"); \ No newline at end of file diff --git a/app/views/admins/identity_verifications/shared/_info_list.html.erb b/app/views/admins/identity_verifications/shared/_info_list.html.erb new file mode 100644 index 000000000..486a4ec5d --- /dev/null +++ b/app/views/admins/identity_verifications/shared/_info_list.html.erb @@ -0,0 +1,35 @@ + + + + + + + + + + + + <% if identity_verifications.present? %> + <% identity_verifications.each_with_index do |identity_verification, index| %> + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号昵称审核状态<%= sort_tag('创建于', name: 'created_at', path: admins_identity_verifications_path) %>操作
<%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to "/#{identity_verification.user.login}", target: '_blank' do %> + <%= overflow_hidden_span identity_verification.user.real_name, width: 100 %> + <% end %> + <%= display_text(identity_verification.state) %><%= display_text(identity_verification.created_at&.strftime('%Y-%m-%d %H:%M')) %> + <%= link_to "#{ identity_verification.state == "待审核" ? '审核' : "查看"}", edit_admins_identity_verification_path(identity_verification), class: 'action' %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: identity_verifications } %> diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index 481676b8f..fd468c4d8 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -24,6 +24,8 @@ <%= sidebar_item_group('#user-submenu', '用户', icon: 'user') do %>
  • <%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users') %>
  • <%= sidebar_item(admins_organizations_path, '组织列表', icon: 'user', controller: 'admins-organizations') %>
  • +
  • <%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications') %>
  • +
  • <%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'user', controller: 'admins-site_pages') %>
  • <% end %>
  • diff --git a/app/views/admins/site_pages/edit.html.erb b/app/views/admins/site_pages/edit.html.erb new file mode 100644 index 000000000..84b69f683 --- /dev/null +++ b/app/views/admins/site_pages/edit.html.erb @@ -0,0 +1,99 @@ +<% + define_admin_breadcrumbs do + add_admin_breadcrumb('用户管理', admins_site_pages_path) + add_admin_breadcrumb('站点列表') + end +%> + +
    +
    + <%= link_to "/#{@site_page.user.login}", class: 'user-info-avatar col-md-1', target: '_blank', data: { toggle: 'tooltip', title: '个人中心' } do %> + + <% end %> + + +
    + + <%= simple_form_for(@site_page, url: admins_site_page_path(@site_page)) do |f| %> + +
    +
    审核信息
    + + +
    + <%= f.input :identifier, label: '站点标识', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.identifier } %> +
    + +
    + <%= f.input :site_name, label: '站点名', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.site_name } %> +
    + +
    + <%= f.input :language_frame, label: '建站工具', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.language_frame } %> +
    + +
    + <%= f.input :theme, label: '主题', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.theme } %> +
    +
    + + +
    + + <%= @site_page.url%> +
    +
    +
    + + <%= f.radio_button :state, 'false' %> 关闭 +
    +
    +
    + +
    +
    +
    + <%= 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 } %> +
    + +
    + <%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %> + <%= link_to '取消', admins_site_pages_path, class: 'btn btn-secondary px-4' %> +
    +
    + + <% end %> +
    diff --git a/app/views/admins/site_pages/index.html.erb b/app/views/admins/site_pages/index.html.erb new file mode 100644 index 000000000..8197ae6ee --- /dev/null +++ b/app/views/admins/site_pages/index.html.erb @@ -0,0 +1,21 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('用户管理', admins_site_pages_path) %> +<% end %> + +
    + <%= form_tag(admins_site_pages_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> +
    + + <% state_options = [['全部',nil], ['正常', true], ['已关闭', false]] %> + <%= select_tag(:state, options_for_select(state_options), class: 'form-control') %> +
    + <%= 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 %> + +
    + +
    + <%= render partial: 'admins/site_pages/shared/info_list', locals: { site_pages: @site_pages } %> +
    + diff --git a/app/views/admins/site_pages/index.js.erb b/app/views/admins/site_pages/index.js.erb new file mode 100644 index 000000000..a2a0b3bac --- /dev/null +++ b/app/views/admins/site_pages/index.js.erb @@ -0,0 +1 @@ +$('.identity-site-pages-list-container').html("<%= j( render partial: 'admins/site_pages/shared/info_list', locals: { site_pages: @site_pages } ) %>"); \ No newline at end of file diff --git a/app/views/admins/site_pages/shared/_info_list.html.erb b/app/views/admins/site_pages/shared/_info_list.html.erb new file mode 100644 index 000000000..4eaef2ef1 --- /dev/null +++ b/app/views/admins/site_pages/shared/_info_list.html.erb @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + <% if site_pages.present? %> + <% site_pages.each_with_index do |site_page, index| %> + + + + + + + + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号昵称仓库站点状态站点名站点标识站点地址建站工具主题上次构建时间<%= sort_tag('创建于', name: 'created_at', path: admins_site_pages_path) %>操作
    <%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to "/#{site_page.user.login}", target: '_blank' do %> + <%= overflow_hidden_span site_page.user.real_name, width: 100 %> + <% end %> + + <%= link_to "/#{site_page.user.login}/#{site_page.project.identifier}", target: '_blank' do %> + <%= overflow_hidden_span site_page.project.name, width: 100 %> + <% end %> + <%= display_text(site_page.state == true ? "已正常" : "关闭") %><%= display_text(site_page.site_name) %><%= display_text(site_page.identifier) %><%= link_to "#{site_page.url}", site_page.url, target: '_blank'%><%= display_text(site_page.language_frame) %><%= display_text(site_page.theme) %><%= display_text(site_page.last_build_at&.strftime('%Y-%m-%d %H:%M')) %><%= display_text(site_page.created_at&.strftime('%Y-%m-%d %H:%M')) %> + <%= link_to "查看", edit_admins_site_page_path(site_page), class: 'action' %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: site_pages } %> diff --git a/app/views/admins/users/edit.html.erb b/app/views/admins/users/edit.html.erb index b407cbbe7..616d97870 100644 --- a/app/views/admins/users/edit.html.erb +++ b/app/views/admins/users/edit.html.erb @@ -92,8 +92,15 @@ <% end %> - - + + <% if @user.id_card_verify %> +
    + <%= f.label :role, label: '站点权限' %> +
    + <%= f.input :website_permission, as: :boolean, label: '开通站点', checked_value: 1, unchecked_value: 0 %> +
    +
    + <% end %>
    <%= 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' } %> diff --git a/app/views/identity_verifications/_info.json.jbuilder b/app/views/identity_verifications/_info.json.jbuilder new file mode 100644 index 000000000..8235bafa6 --- /dev/null +++ b/app/views/identity_verifications/_info.json.jbuilder @@ -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") diff --git a/app/views/identity_verifications/create.json.jbuilder b/app/views/identity_verifications/create.json.jbuilder new file mode 100644 index 000000000..400230393 --- /dev/null +++ b/app/views/identity_verifications/create.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'info', locals: {id_verify: @id_verify} \ No newline at end of file diff --git a/app/views/identity_verifications/index.json.jbuilder b/app/views/identity_verifications/index.json.jbuilder new file mode 100644 index 000000000..400230393 --- /dev/null +++ b/app/views/identity_verifications/index.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'info', locals: {id_verify: @id_verify} \ No newline at end of file diff --git a/app/views/identity_verifications/update.json.jbuilder b/app/views/identity_verifications/update.json.jbuilder new file mode 100644 index 000000000..400230393 --- /dev/null +++ b/app/views/identity_verifications/update.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'info', locals: {id_verify: @id_verify} \ No newline at end of file diff --git a/app/views/site_pages/_info.json.jbuilder b/app/views/site_pages/_info.json.jbuilder new file mode 100644 index 000000000..90840b68f --- /dev/null +++ b/app/views/site_pages/_info.json.jbuilder @@ -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") \ No newline at end of file diff --git a/app/views/site_pages/create.json.jbuilder b/app/views/site_pages/create.json.jbuilder new file mode 100644 index 000000000..b706f67b8 --- /dev/null +++ b/app/views/site_pages/create.json.jbuilder @@ -0,0 +1 @@ +json.partial! "info", page: @page \ No newline at end of file diff --git a/app/views/site_pages/index.json.jbuilder b/app/views/site_pages/index.json.jbuilder new file mode 100644 index 000000000..035f4bc1b --- /dev/null +++ b/app/views/site_pages/index.json.jbuilder @@ -0,0 +1,4 @@ +json.total_count @pages.size +json.pages @pages.each do |page| + json.partial! 'info', locals: {page: page} +end diff --git a/app/views/site_pages/show.jbuilder b/app/views/site_pages/show.jbuilder new file mode 100644 index 000000000..0ca595ca1 --- /dev/null +++ b/app/views/site_pages/show.jbuilder @@ -0,0 +1 @@ +json.partial! 'info', locals: {page: @page} \ No newline at end of file diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index 021c9a752..901ea87f0 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -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 diff --git a/config/admins/page_themes.yml b/config/admins/page_themes.yml new file mode 100644 index 000000000..69b069a76 --- /dev/null +++ b/config/admins/page_themes.yml @@ -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" diff --git a/config/routes.rb b/config/routes.rb index 6d9fda2e9..6a291bf2b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20230725020157_create_pages.rb b/db/migrate/20230725020157_create_pages.rb new file mode 100644 index 000000000..97d6be8a7 --- /dev/null +++ b/db/migrate/20230725020157_create_pages.rb @@ -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 diff --git a/db/migrate/20230725060833_create_identity_verifications.rb b/db/migrate/20230725060833_create_identity_verifications.rb new file mode 100644 index 000000000..ba0618986 --- /dev/null +++ b/db/migrate/20230725060833_create_identity_verifications.rb @@ -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 diff --git a/db/migrate/20230727083929_add_id_card_verify_to_users.rb b/db/migrate/20230727083929_add_id_card_verify_to_users.rb new file mode 100644 index 000000000..1bb47f760 --- /dev/null +++ b/db/migrate/20230727083929_add_id_card_verify_to_users.rb @@ -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 diff --git a/spec/controllers/admins/identity_verifications_controller_spec.rb b/spec/controllers/admins/identity_verifications_controller_spec.rb new file mode 100644 index 000000000..a7cbaa5c0 --- /dev/null +++ b/spec/controllers/admins/identity_verifications_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Admins::IdentityVerificationsController, type: :controller do + +end diff --git a/spec/controllers/admins/site_pages_controller_spec.rb b/spec/controllers/admins/site_pages_controller_spec.rb new file mode 100644 index 000000000..11a4fb4ec --- /dev/null +++ b/spec/controllers/admins/site_pages_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Admins::SitePagesController, type: :controller do + +end diff --git a/spec/controllers/identity_verifications_controller_spec.rb b/spec/controllers/identity_verifications_controller_spec.rb new file mode 100644 index 000000000..a912bf23d --- /dev/null +++ b/spec/controllers/identity_verifications_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe IdentityVerificationsController, type: :controller do + +end diff --git a/spec/controllers/site_pages_controller_spec.rb b/spec/controllers/site_pages_controller_spec.rb new file mode 100644 index 000000000..6f9d0c956 --- /dev/null +++ b/spec/controllers/site_pages_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SitePagesController, type: :controller do + +end diff --git a/spec/helpers/admins/identity_verifications_helper_spec.rb b/spec/helpers/admins/identity_verifications_helper_spec.rb new file mode 100644 index 000000000..558db9635 --- /dev/null +++ b/spec/helpers/admins/identity_verifications_helper_spec.rb @@ -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 diff --git a/spec/helpers/admins/site_pages_helper_spec.rb b/spec/helpers/admins/site_pages_helper_spec.rb new file mode 100644 index 000000000..29f12aecc --- /dev/null +++ b/spec/helpers/admins/site_pages_helper_spec.rb @@ -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 diff --git a/spec/helpers/identity_verifications_helper_spec.rb b/spec/helpers/identity_verifications_helper_spec.rb new file mode 100644 index 000000000..abe1b65fb --- /dev/null +++ b/spec/helpers/identity_verifications_helper_spec.rb @@ -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 diff --git a/spec/helpers/pages_helper_spec.rb b/spec/helpers/pages_helper_spec.rb new file mode 100644 index 000000000..296094107 --- /dev/null +++ b/spec/helpers/pages_helper_spec.rb @@ -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 diff --git a/spec/models/identity_verification_spec.rb b/spec/models/identity_verification_spec.rb new file mode 100644 index 000000000..88a798969 --- /dev/null +++ b/spec/models/identity_verification_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe IdentityVerification, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/page_spec.rb b/spec/models/page_spec.rb new file mode 100644 index 000000000..4e863026f --- /dev/null +++ b/spec/models/page_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Page, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end