From b0d22b3053b856392e6d354b8adb7fdc4648f580 Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 8 Sep 2021 15:34:53 +0800 Subject: [PATCH 01/10] =?UTF-8?q?FIX=20=E8=A7=A3=E5=86=B3=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=BB=E9=A1=B5=E5=9B=A0=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=BC=BA=E9=99=B7=E5=AF=BC=E8=87=B4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/headmaps_controller.rb | 2 +- app/controllers/users/statistics_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/headmaps_controller.rb b/app/controllers/users/headmaps_controller.rb index 81bd5771c..7c88b5681 100644 --- a/app/controllers/users/headmaps_controller.rb +++ b/app/controllers/users/headmaps_controller.rb @@ -1,7 +1,7 @@ class Users::HeadmapsController < Users::BaseController def index result = Gitea::User::HeadmapService.call(observed_user.login, start_stamp, end_stamp) - @headmaps = result[2] + @headmaps = result[2].blank? ? [] : result[2] rescue Exception => e uid_logger_error(e.message) tip_exception(e.message) diff --git a/app/controllers/users/statistics_controller.rb b/app/controllers/users/statistics_controller.rb index c6cc0d889..592a8be94 100644 --- a/app/controllers/users/statistics_controller.rb +++ b/app/controllers/users/statistics_controller.rb @@ -14,7 +14,7 @@ class Users::StatisticsController < Users::BaseController @date_data << date.strftime("%Y.%m.%d") @issue_data << observed_user.issues.where("DATE(created_on) = ?", date).size @pull_request_data << observed_user.pull_requests.where("DATE(created_at) = ?", date).size - date_commit_data = commit_data.select{|item| item["timestamp"] == date.to_time.to_i} + date_commit_data = commit_data.blank? ? nil : commit_data.select{|item| item["timestamp"] == date.to_time.to_i} @commit_data << (date_commit_data.blank? ? 0 : date_commit_data[0]["contributions"].to_i) end render :json => {dates: @date_data, issues_count: @issue_data, pull_requests_count: @pull_request_data, commits_count: @commit_data} From 67d4544d6b6f21fbf84a0c533d836556120b35ff Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 9 Sep 2021 13:50:31 +0800 Subject: [PATCH 02/10] FIX delete some mandatory field with projects list api --- api_document.md | 10 +++++----- app/controllers/projects_controller.rb | 1 - app/forms/base_form.rb | 10 ++++++++-- app/forms/projects/create_form.rb | 3 +-- app/services/gitea/repository/create_service.rb | 4 ++-- app/services/projects/create_service.rb | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/api_document.md b/api_document.md index 7620c42a6..ddb791952 100644 --- a/api_document.md +++ b/api_document.md @@ -338,10 +338,10 @@ http://localhost:3000/api/projects/ | jq |-|-|-|-| |user_id |是|int |用户id或者组织id | |name |是|string |项目名称 | -|description |是|string |项目描述 | +|description |否|string |项目描述 | |repository_name |是|string |仓库名称, 只含有数字、字母、下划线不能以下划线开头和结尾,且唯一 | -|project_category_id|是|int |项目类别id | -|project_language_id|是|int |项目语言id | +|project_category_id|否|int |项目类别id | +|project_language_id|否|int |项目语言id | |ignore_id |否|int |gitignore相关id | |license_id |否|int |开源许可证id | |private |否|boolean|项目是否私有, true:为私有,false: 公开,默认为公开 | @@ -388,8 +388,8 @@ http://localhost:3000/api/projects/migrate.json | jq |clone_addr |是|string |镜像项目clone地址 | |description |否|string |项目描述 | |repository_name |是|string |仓库名称, 只含有数字、字母、下划线不能以下划线开头和结尾,且唯一 | -|project_category_id|是|int |项目类别id | -|project_language_id|是|int |项目语言id | +|project_category_id|否|int |项目类别id | +|project_language_id|否|int |项目语言id | |is_mirror |否|boolean|是否设置为镜像, true:是, false:否,默认为否 | |auth_username |否|string|镜像源仓库的登录用户名 | |auth_password |否|string|镜像源仓库的登录秘密 | diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2936b35ea..bdc96e900 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -46,7 +46,6 @@ class ProjectsController < ApplicationController def create ActiveRecord::Base.transaction do - tip_exception("无法使用以下关键词:#{project_params[:repository_name]},请重新命名") if ReversedKeyword.is_reversed(project_params[:repository_name]).present? Projects::CreateForm.new(project_params).validate! @project = Projects::CreateService.new(current_user, project_params).call diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index 015332d82..1f6014904 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -2,18 +2,24 @@ class BaseForm include ActiveModel::Model def check_project_category(project_category_id) - raise "project_category_id参数值无效." if (ProjectCategory.find_by_id project_category_id).blank? + raise "project_category_id参数值无效." if project_category_id && !ProjectCategory.exists?(project_category_id) end def check_project_language(project_language_id) - raise "project_language_id参数值无效." if (ProjectLanguage.find_by_id project_language_id).blank? + raise "project_language_id参数值无效." if project_language_id && !ProjectLanguage.exists?(project_language_id) end def check_repository_name(user_id, repository_name) + check_reversed_keyword(repository_name) raise "仓库名称已被使用." if Repository.where(user_id: user_id, identifier: repository_name.strip).exists? end def check_project_name(user_id, project_name) raise "项目名称已被使用." if Project.where(user_id: user_id, name: project_name.strip).exists? end + + def check_reversed_keyword(repository_name) + raise "仓库名称已被使用." if ReversedKeyword.is_reversed(repository_name).exists? + end + end diff --git a/app/forms/projects/create_form.rb b/app/forms/projects/create_form.rb index 8265f323e..7014da2b7 100644 --- a/app/forms/projects/create_form.rb +++ b/app/forms/projects/create_form.rb @@ -3,8 +3,7 @@ class Projects::CreateForm < BaseForm attr_accessor :user_id, :name, :description, :repository_name, :project_category_id, :project_language_id, :ignore_id, :license_id, :private, :owner - validates :user_id, :name, :description,:repository_name, - :project_category_id, :project_language_id, presence: true + validates :user_id, :name, :repository_name, presence: true validates :repository_name, format: { with: REPOSITORY_NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" } validates :name, length: { maximum: 50 } diff --git a/app/services/gitea/repository/create_service.rb b/app/services/gitea/repository/create_service.rb index 168aaab24..98a283034 100644 --- a/app/services/gitea/repository/create_service.rb +++ b/app/services/gitea/repository/create_service.rb @@ -25,8 +25,8 @@ class Gitea::Repository::CreateService < Gitea::ClientService private def request_params - create_params = params.merge(readme: "readme") - Hash.new.merge(token: token, data: create_params) + # create_params = params.merge(readme: "readme") + Hash.new.merge(token: token, data: params) end def url diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index e7e4924ae..72ad8f161 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -43,7 +43,7 @@ class Projects::CreateService < ApplicationService ignore_id: params[:ignore_id], license_id: params[:license_id], website: params[:website], - identifier: params[:repository_name] #新增,hs + identifier: params[:repository_name] } end From e38539445d97cd2605805cd451b8268a8e97c27c Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 9 Sep 2021 14:34:29 +0800 Subject: [PATCH 03/10] FIX delete some mandatory field with migrate repo api --- api_document.md | 4 +--- app/controllers/projects_controller.rb | 1 - app/forms/base_form.rb | 2 +- app/forms/projects/create_form.rb | 3 +-- app/forms/projects/migrate_form.rb | 11 ++++------- app/libs/custom_regexp.rb | 4 ++++ app/services/repositories/migrate_service.rb | 2 +- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/api_document.md b/api_document.md index ddb791952..8a579f8e7 100644 --- a/api_document.md +++ b/api_document.md @@ -374,9 +374,7 @@ curl -X POST \ -d "user_id=36408" \ -d "clone_addr=https://gitea.com/mx8090alex/golden.git" \ -d "name=golden_mirror1" \ --d "description=golden_mirror" \ --d "project_category_id=1" \ --d "project_language_id=2" \ +-d "repository_name=golden_mirror1" \ http://localhost:3000/api/projects/migrate.json | jq ``` *请求参数说明:* diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index bdc96e900..9b3909690 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -56,7 +56,6 @@ class ProjectsController < ApplicationController end def migrate - tip_exception("无法使用以下关键词:#{mirror_params[:repository_name]},请重新命名") if ReversedKeyword.is_reversed(mirror_params[:repository_name]).present? Projects::MigrateForm.new(mirror_params).validate! @project = diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index 1f6014904..a939b1991 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -19,7 +19,7 @@ class BaseForm end def check_reversed_keyword(repository_name) - raise "仓库名称已被使用." if ReversedKeyword.is_reversed(repository_name).exists? + raise "仓库名称已被占用." if ReversedKeyword.is_reversed(repository_name).exists? end end diff --git a/app/forms/projects/create_form.rb b/app/forms/projects/create_form.rb index 7014da2b7..a45da1a87 100644 --- a/app/forms/projects/create_form.rb +++ b/app/forms/projects/create_form.rb @@ -1,10 +1,9 @@ class Projects::CreateForm < BaseForm - REPOSITORY_NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾 attr_accessor :user_id, :name, :description, :repository_name, :project_category_id, :project_language_id, :ignore_id, :license_id, :private, :owner validates :user_id, :name, :repository_name, presence: true - validates :repository_name, format: { with: REPOSITORY_NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" } + validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" } validates :name, length: { maximum: 50 } validates :repository_name, length: { maximum: 100 } diff --git a/app/forms/projects/migrate_form.rb b/app/forms/projects/migrate_form.rb index 51116b2b5..13a3af2cb 100644 --- a/app/forms/projects/migrate_form.rb +++ b/app/forms/projects/migrate_form.rb @@ -1,12 +1,9 @@ class Projects::MigrateForm < BaseForm - REPOSITORY_NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾 - URL_REGEX = /\A(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?\z/i + attr_accessor :user_id, :name, :repository_name, :project_category_id, :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner - attr_accessor :user_id, :name, :description, :repository_name, :project_category_id, :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner - - validates :user_id, :name, :description,:repository_name, :project_category_id, :project_language_id, presence: true - validates :repository_name, format: { with: REPOSITORY_NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" } - validates :clone_addr, format: { with: URL_REGEX, multiline: true, message: "地址格式不正确" } + validates :user_id, :name, :repository_name, :clone_addr, presence: true + validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" } + validates :clone_addr, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" } validate do check_project_name(user_id, name) unless name.blank? check_repository_name(user_id, repository_name) unless repository_name.blank? diff --git a/app/libs/custom_regexp.rb b/app/libs/custom_regexp.rb index 4aa6fac2d..c7b5e7a1a 100644 --- a/app/libs/custom_regexp.rb +++ b/app/libs/custom_regexp.rb @@ -6,4 +6,8 @@ module CustomRegexp PASSWORD = /\A[a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'_<>~\·`\?:;|]{8,16}\z/ URL = /\Ahttps?:\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]\z/ IP = /^((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/ + + URL_REGEX = /\A(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?\z/i + REPOSITORY_NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾 + end diff --git a/app/services/repositories/migrate_service.rb b/app/services/repositories/migrate_service.rb index 2870faba9..cccfaed04 100644 --- a/app/services/repositories/migrate_service.rb +++ b/app/services/repositories/migrate_service.rb @@ -32,7 +32,7 @@ class Repositories::MigrateService < ApplicationService private: params[:hidden], mirror: wrapper_mirror || false, auth_username: params[:login], - auth_password: Base64.decode64(params[:password]) + auth_password: Base64.decode64(params[:password] || "") } end From f5ffd978ac7ddddf5f26a976cc71ff68ec41aebe Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 9 Sep 2021 14:35:26 +0800 Subject: [PATCH 04/10] FIX delete some file --- app/controllers/concerns/laboratory_helper.rb | 2 +- lib/gitcheck/myshixun_update.txt | 0 lib/gitcheck/myshixun_update_error.txt | 0 lib/gitcheck/readme_test.txt | 51 ------------- lib/gitcheck/shixun_update_error.txt | 72 ------------------- 5 files changed, 1 insertion(+), 124 deletions(-) delete mode 100644 lib/gitcheck/myshixun_update.txt delete mode 100644 lib/gitcheck/myshixun_update_error.txt delete mode 100644 lib/gitcheck/readme_test.txt delete mode 100644 lib/gitcheck/shixun_update_error.txt diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index b231b8484..ea6e00558 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -41,7 +41,7 @@ module LaboratoryHelper my_courses: "https://www.trustie.net/users/#{current_user.try(:login)}/user_courselist", my_projects: "/users/#{current_user.try(:login)}/projects", my_organ: "https://www.trustie.net/users/#{current_user.try(:login)}/user_organizations", - default_url: "https://www.trustie.net/", + default_url: Rails.application.config_for(:configuration)['platform_url'], tiding_url: "https://www.trustie.net/users/#{current_user.try(:login)}/user_messages", register_url: "https://www.trustie.net/login?login=false" } diff --git a/lib/gitcheck/myshixun_update.txt b/lib/gitcheck/myshixun_update.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/gitcheck/myshixun_update_error.txt b/lib/gitcheck/myshixun_update_error.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/gitcheck/readme_test.txt b/lib/gitcheck/readme_test.txt deleted file mode 100644 index 317af632c..000000000 --- a/lib/gitcheck/readme_test.txt +++ /dev/null @@ -1,51 +0,0 @@ -# 新版Git测试说明 -统一: -参考实训:http://47.96.87.25:48080/shixuns/ca9fvobr/repository -请求方式:POST -参数{repo_path: "educoder/ca9fvobr.git"} -公共方法: -['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', - 'file_content', 'commits'] - -1、仓库目录接口 - 测试方法:模拟1000个用户同时去访问接口,访问方式 - http://121.199.19.206:9000/api/file_tree - 参数: - {repo_path: "educoder/ca9fvobr.git", path: ''} // 如:{path: 'step1'} - -2、创建版本库 - 访问地址:http://121.199.19.206:9000/api/add_repository - 参数: - {repo_path: 比如:"Hjqreturn/aaass1.git"} - -3、fork版本库 - http://121.199.19.206:9000/api/fork_repository - 参数: - {repo_path: 'Hjqreturn/aaass1.git', fork_repository_path: 'educoder/ca9fvobr.git'} - 说明:fork_repository_path是新项目的repo_path, repo_path是源项目的 - - -4、更新文件 - 测试方法: - 1、更新同一个文件,并发量可以不用很大,可以用同一个用户并发10-100 - 2、更新不同的文件:可以依据创建的版本库去更新 - 访问地址:http://121.199.19.206:9000/api/update_file - 参数: - {repo_path: "educoder/ca9fvobr.git", - file_path: 'step1/main.py', - message: 'commit by test', - content: 'afdjadsjfj1111', - author_name: 'guange', - author_email: '8863824@gmil.com'} - -5、获取文件内容 - 访问地址:http://121.199.19.206:9000/api/file_content - 参数: - {repo_path: "educoder/ca9fvobr.git", path: 'step1/main.py',} - -6、获取提交记录 - 访问地址:http://121.199.19.206:9000/api/commits - 参数: - {repo_path: 比如:"educoder/ca9fvobr.git"} - - diff --git a/lib/gitcheck/shixun_update_error.txt b/lib/gitcheck/shixun_update_error.txt deleted file mode 100644 index ef9663c46..000000000 --- a/lib/gitcheck/shixun_update_error.txt +++ /dev/null @@ -1,72 +0,0 @@ -mbtclufr -9op3hs4j -96ctv7yr -rtmzxfke -ofqxthrf -czu9w4gj -9fpzj6et -pwhc865b -maozpx4l -y5wh2ofx -b5rzhpf3 -bs243nrl -47fn2yfb -kwotfxey -w5468sbp -fyekprio -q6ze5fih -b5hjq9zm -ky8pbqux -53phc7nq -b9j2yuix -9t3uphwk -iokm8ah2 -qlsy6xb4 -345bqhfi -v728fqia -4euftvf2 -f23sef5m -nhqis8m9 -qp72tb5x -gt3anszw -tng6heyf -nb9keawo -elgnbkp9 -4neslomg -lh35s6ma -xmc4rpay -qrpaxi6b -9fla2zry -efuibzrm -fzp3iu4w -pligsyn8 -glbksr29 -kfm7ghyc -p6hk3svf -p539gjhm -am5o73er -4x3qwrbe -fqosyl8g -of5z3fci -tb7hw62n -ie6zxg7r -4q2bmy9h -fpm3u5yb -nikx3ojt -vt82s9bq -ma59fefo -lxa39tfq -4gnockxf -nxwg84ey -fmie8nzb -w5nsr24v -4hn3efwc -h9ljfbq7 -nuv54t8b -2te9fmfq -vihnsayz -qhlyn82s -vw74kmfr -vcta36bz -henz425l -g529v38z From 36adfcf016faf599ba50eeac7e6fc5873980b55a Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 9 Sep 2021 17:34:09 +0800 Subject: [PATCH 05/10] =?UTF-8?q?FIX=20=E6=95=B4=E7=90=86=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .merge_file_a17580 | 529 ------------------ app/views/admins/laboratories/index.html.erb | 2 +- .../shared/_laboratory_item.html.erb | 38 +- .../admins/laboratories/shared/_list.html.erb | 3 - .../admins/laboratory_settings/show.html.erb | 8 +- .../admins/reversed_keywords/index.html.erb | 4 + app/views/admins/shared/_sidebar.html.erb | 3 +- 7 files changed, 17 insertions(+), 570 deletions(-) delete mode 100644 .merge_file_a17580 diff --git a/.merge_file_a17580 b/.merge_file_a17580 deleted file mode 100644 index 47e471767..000000000 --- a/.merge_file_a17580 +++ /dev/null @@ -1,529 +0,0 @@ -import React, {Component} from 'react'; -import logo from './logo.svg'; -import './App.css'; -import {LocaleProvider} from 'antd' -import zhCN from 'antd/lib/locale-provider/zh_CN'; -import { - BrowserRouter as Router, - Route, - Switch -} from 'react-router-dom'; -import axios from 'axios'; -import '@icedesign/base/dist/ICEDesignBase.css'; - -import '@icedesign/base/index.scss'; - -import LoginDialog from './modules/login/LoginDialog'; -import Notcompletedysl from './modules/user/Notcompletedysl'; -import Trialapplicationysl from './modules/login/Trialapplicationysl'; -import Trialapplicationreview from './modules/user/Trialapplicationreview'; -import Addcourses from "./modules/courses/coursesPublic/Addcourses"; -import AccountProfile from"./modules/user/AccountProfile"; - - -import Trialapplication from './modules/login/Trialapplication' - -import NotFoundPage from './NotFoundPage' - -import Loading from './Loading' - -import Loadable from 'react-loadable'; - - -import moment from 'moment' - -import {MuiThemeProvider, createMuiTheme} from 'material-ui/styles'; - -// import './AppConfig' - -import history from './history'; - -import {SnackbarHOC} from 'educoder' -import {initAxiosInterceptors} from './AppConfig' - - -// !!!tpi需要这个来加载css -import {TPMIndexHOC} from './modules/tpm/TPMIndexHOC'; - - -const theme = createMuiTheme({ - palette: { - primary: { - main: '#4CACFF', - contrastText: 'rgba(255, 255, 255, 0.87)' - }, - secondary: {main: '#4CACFF'}, // #11cb5f This is just green.A700 as hex. - }, -}); -// -// const Trialapplication= Loadable({ -// loader: () =>import('./modules/login/Trialapplication'), -// loading:Loading, -// }) -//登入 -const EducoderLogin = Loadable({ - loader: () => import('./modules/login/EducoderLogin'), - loading: Loading, -}) -const TestIndex = Loadable({ - loader: () => import('./modules/test'), - loading: Loading, -}) - -const IndexWrapperComponent = Loadable({ - loader: () => import('./modules/page/IndexWrapper'), - loading: Loading, -}) - -const CommentComponent = Loadable({ - loader: () => import('./modules/comment/CommentContainer'), - loading: Loading, -}) - -const TestMaterialDesignComponent = Loadable({ - loader: () => import('./modules/test/md/TestMaterialDesign'), - loading: Loading, -}) -const TestCodeMirrorComponent = Loadable({ - loader: () => import('./modules/test/codemirror/TestCodeMirror'), - loading: Loading, -}) - -const TestComponent = Loadable({ - loader: () => import('./modules/test/TestRC'), - loading: Loading, -}) -const TestUrlQueryComponent = Loadable({ - loader: () => import('./modules/test/urlquery/TestUrlQuery'), - loading: Loading, -}) - -const TPMIndexComponent = Loadable({ - loader: () => import('./modules/tpm/TPMIndex'), - loading: Loading, -}) -const TPMShixunsIndexComponent = Loadable({ - loader: () => import('./modules/tpm/shixuns/ShixunsIndex'), - loading: Loading, -}) - -//实训课程(原实训路径) -const ShixunPaths = Loadable({ - loader: () => import('./modules/paths/Index'), - loading: Loading, -}) - -//在线课堂 -const CoursesIndex = Loadable({ - loader: () => import('./modules/courses/Index'), - loading: Loading, -}) -const SearchPage = Loadable({ - loader: () => import('./search/SearchPage'), - loading: Loading, -}) - -//教学案例 -const MoopCases = Loadable({ - loader: () => import('./modules/moop_cases/index'), - loading: Loading, -}) - -// 课堂讨论 -// const BoardIndex = Loadable({ -// loader: () => import('./modules/courses/boards/BoardIndex'), -// loading:Loading, -// }) - -// //课堂普通作业&分组作业 -// const CoursesWorkIndex = Loadable({ -// loader: () => import('./modules/courses/busyWork/Index'), -// loading:Loading, -// }) -// - -// const TPMShixunchildIndexComponent = Loadable({ -// loader: () => import('./modules/tpm/shixunchild/ShixunChildIndex'), -// loading: Loading, -// }) - - -// const TPMshixunfork_listIndexComponent = Loadable({ -// loader: () => import('./modules/tpm/shixunchild/Shixunfork_list'), -// loading: Loading, -// }) - - -const ForumsIndexComponent = Loadable({ - loader: () => import('./modules/forums/ForumsIndex'), - loading: Loading, -}) - -// trustie plus forum -// const TPForumsIndexComponent = Loadable({ -// loader: () => import('./modules/tp-forums/TPForumsIndex'), -// loading: Loading, -// }) - - -// const TestPageComponent = Loadable({ -// loader: () => import('./modules/page/Index'), -// loading: Loading, -// }) - - -//新建实训 -const Newshixuns = Loadable({ - loader: () => import('./modules/tpm/newshixuns/Newshixuns'), - loading: Loading, -}) - - -//实训首页 -const ShixunsHome = Loadable({ - loader: () => import('./modules/home/shixunsHome'), - loading: Loading, -}) - - -const CompatibilityPageLoadable = Loadable({ - loader: () => import('./modules/common/CompatibilityPage'), - loading: Loading, -}) - -//403页面 -const Shixunauthority = Loadable({ - loader: () => import('./modules/403/Shixunauthority'), - loading: Loading, -}) - - -//404页面 -const Shixunnopage = Loadable({ - loader: () => import('./modules/404/Shixunnopage'), - loading: Loading, -}) - -//500页面 -const http500 = Loadable({ - loader: () => import('./modules/500/http500'), - loading: Loading, -}) - -// 登录注册 -const LoginRegisterPage = Loadable({ - loader: () => import('./modules/user/LoginRegisterPage'), - loading: Loading, -}) -const AccountPage = Loadable({ - loader: () => import('./modules/user/AccountPage'), - loading: Loading, -}) - -// 个人主页 -const UsersInfo = Loadable({ - loader: () => import('./modules/user/usersInfo/Infos'), - loading: Loading, -}) - -// 兴趣页面 -const Interestpage = Loadable({ - loader: () => import('./modules/login/EducoderInteresse'), - loading: Loading, -}) - -//众包创新 -const ProjectPackages=Loadable({ - loader: () => import('./modules/projectPackages/ProjectPackageIndex'), - loading: Loading, -}) - -class App extends Component { - constructor(props) { - super(props) - // this.state = { - // isRenders:false, - // } - - } - - componentDidMount() { - // force an update if the URL changes - history.listen(() => { - this.forceUpdate() - const $ = window.$ - // https://www.trustie.net/issues/21919 可能会有问题 - $("html").animate({ scrollTop: $('html').scrollTop() - 0 }) - }); - - initAxiosInterceptors(this.props) - - // - // axios.interceptors.response.use((response) => { - // // console.log("response"+response); - // if(response!=undefined) - // // console.log("response"+response.data.statu); - // if (response&&response.data.status === 407) { - // this.setState({ - // isRenders: true, - // }) - // } - // return response; - // }, (error) => { - // //TODO 这里如果样式变了会出现css不加载的情况 - // }); - } - //修改登录方法 - Modifyloginvalue=()=>{ - this.setState({ - isRender:false, - }) - } - - render() { - - - return ( - - - - - this.Modifyloginvalue()}> - - - - - - {/*{*/} - {/* isRender === true?*/} - {/* : ""*/} - {/*}*/} - - {/*{*/} - {/* isRenders === true?*/} - {/**/} - {/*:""*/} - {/*}*/} - - - - {/**/} - - {/*众包创新*/} - - {/*认证*/} - - - {/*403*/} - - - - - {/*404*/} - - - - - - () - }> - {/**/} - - - - - - - - - - - - {/*列表页*/} - - - {/* - - - */} - - {/**/} - {/**/} - - - {/*实训课程(原实训路径)*/} - - - () - } - > - - {/*课堂*/} - - - {/* 课堂讨论 */} - {/* */} - - {/* - */} - - {/* */} - {/* 兴趣页面*/} - {/**/} - - - - - - - - - {/* 教学案例 */} - () - }/> - - {/* */} - {/*列表页*/} - {/**/} - {/*首页*/} - - - - {/**/} - - - - - - ); - } -} - -// moment国际化,设置为中文 -moment.defineLocale('zh-cn', { - months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), - monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), - weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), - weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), - weekdaysMin: '日_一_二_三_四_五_六'.split('_'), - longDateFormat: { - LT: 'Ah点mm分', - LTS: 'Ah点m分s秒', - L: 'YYYY-MM-DD', - LL: 'YYYY年MMMD日', - LLL: 'YYYY年MMMD日Ah点mm分', - LLLL: 'YYYY年MMMD日ddddAh点mm分', - l: 'YYYY-MM-DD', - ll: 'YYYY年MMMD日', - lll: 'YYYY年MMMD日Ah点mm分', - llll: 'YYYY年MMMD日ddddAh点mm分' - }, - meridiemParse: /凌晨|早上|上午|中午|下午|晚上/, - meridiemHour: function (hour, meridiem) { - if (hour === 12) { - hour = 0; - } - if (meridiem === '凌晨' || meridiem === '早上' || - meridiem === '上午') { - return hour; - } else if (meridiem === '下午' || meridiem === '晚上') { - return hour + 12; - } else { - // '中午' - return hour >= 11 ? hour : hour + 12; - } - }, - meridiem: function (hour, minute, isLower) { - var hm = hour * 100 + minute; - if (hm < 600) { - return '凌晨'; - } else if (hm < 900) { - return '早上'; - } else if (hm < 1130) { - return '上午'; - } else if (hm < 1230) { - return '中午'; - } else if (hm < 1800) { - return '下午'; - } else { - return '晚上'; - } - }, - calendar: { - sameDay: function () { - return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT'; - }, - nextDay: function () { - return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT'; - }, - lastDay: function () { - return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT'; - }, - nextWeek: function () { - var startOfWeek, prefix; - startOfWeek = moment().startOf('week'); - prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]'; - return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm'; - }, - lastWeek: function () { - var startOfWeek, prefix; - startOfWeek = moment().startOf('week'); - prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]'; - return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm'; - }, - sameElse: 'LL' - }, - ordinalParse: /\d{1,2}(日|月|周)/, - ordinal: function (number, period) { - switch (period) { - case 'd': - case 'D': - case 'DDD': - return number + '日'; - case 'M': - return number + '月'; - case 'w': - case 'W': - return number + '周'; - default: - return number; - } - }, - relativeTime: { - future: '%s内', - past: '%s前', - s: '几秒', - m: '1分钟', - mm: '%d分钟', - h: '1小时', - hh: '%d小时', - d: '1天', - dd: '%d天', - M: '1个月', - MM: '%d个月', - y: '1年', - yy: '%d年' - }, - week: { - // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效 - dow: 1, // Monday is the first day of the week. - doy: 4 // The week that contains Jan 4th is the first week of the year. - } -}); -export default SnackbarHOC()(App); \ No newline at end of file diff --git a/app/views/admins/laboratories/index.html.erb b/app/views/admins/laboratories/index.html.erb index 397f50cbe..8811f4ab3 100644 --- a/app/views/admins/laboratories/index.html.erb +++ b/app/views/admins/laboratories/index.html.erb @@ -4,7 +4,7 @@
<%= form_tag(admins_laboratories_path(unsafe_params), method: :get, class: 'form-inline search-form flex-1', remote: true) do %> - <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-6 col-md-4 ml-3', placeholder: '学校名称/二级域名前缀检索') %> + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-6 col-md-4 ml-3', placeholder: '单位名称/二级域名前缀检索') %> <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> <% end %> diff --git a/app/views/admins/laboratories/shared/_laboratory_item.html.erb b/app/views/admins/laboratories/shared/_laboratory_item.html.erb index a121528e3..b4b4921ee 100644 --- a/app/views/admins/laboratories/shared/_laboratory_item.html.erb +++ b/app/views/admins/laboratories/shared/_laboratory_item.html.erb @@ -1,6 +1,6 @@ <% school = laboratory&.school %> <%= list_index_no((params[:page] || 1).to_i, index) %> -<%= school&.name || 'Trustie主站' %> +<%= school&.name || '主站' %> <% if laboratory.identifier %> <%= link_to laboratory.site, "https://#{laboratory.site}", target: '_blank' %> @@ -29,40 +29,10 @@
<%= laboratory.created_at.strftime('%Y-%m-%d %H:%M') %> - - <% if school.present? && laboratory.id != 1 %> - <%= check_box_tag :sync_course,!laboratory.sync_course,laboratory.sync_course,remote:true,data:{id:laboratory.id},class:"laboratory-sync-form" %> - <% end %> - - - <% if school.present? && laboratory.id != 1 %> - <%= check_box_tag :sync_subject,!laboratory.sync_subject,laboratory.sync_subject,remote:true,data:{id:laboratory.id},class:"laboratory-sync-form" %> - <% end %> - - - <% if school.present? && laboratory.id != 1 %> - <%= check_box_tag :sync_shixun,!laboratory.sync_shixun,laboratory.sync_shixun,remote:true,data:{id:laboratory.id},class:"laboratory-sync-form" %> - <% end %> - - <%= link_to '定制', admins_laboratory_laboratory_setting_path(laboratory), class: 'action' %> + <%= link_to '设置', admins_laboratory_laboratory_setting_path(laboratory), class: 'action' %> <% if school.present? && laboratory.id != 1 %> - <%= javascript_void_link '添加管理员', class: 'action', data: { laboratory_id: laboratory.id, toggle: 'modal', target: '.admin-add-laboratory-user-modal' } %> - <%= link_to '同步用户', synchronize_user_admins_laboratory_path(laboratory), remote: true, data: { confirm: '确认同步该单位下的所有用户到云上实验室吗?' }, class: 'action' %> -<% end %> - -
- <%= javascript_void_link('更多', class: 'action dropdown-toggle', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) %> - -
+ <%= delete_link '删除', admins_laboratory_path(laboratory, element: ".laboratory-item-#{laboratory.id}"), class: 'action' %> + <% end %> diff --git a/app/views/admins/laboratories/shared/_list.html.erb b/app/views/admins/laboratories/shared/_list.html.erb index 621ad7a41..0b6466039 100644 --- a/app/views/admins/laboratories/shared/_list.html.erb +++ b/app/views/admins/laboratories/shared/_list.html.erb @@ -7,9 +7,6 @@ 统计链接 管理员 <%= sort_tag('创建时间', name: 'id', path: admins_laboratories_path) %> - 同步课堂 - 同步实践课程 - 同步实训 操作 diff --git a/app/views/admins/laboratory_settings/show.html.erb b/app/views/admins/laboratory_settings/show.html.erb index 67536af24..735f19f0a 100644 --- a/app/views/admins/laboratory_settings/show.html.erb +++ b/app/views/admins/laboratory_settings/show.html.erb @@ -86,7 +86,9 @@ -
+ <% +=begin%> +
Banner设置
@@ -140,7 +142,9 @@
- + +<% +=end%>
diff --git a/app/views/admins/reversed_keywords/index.html.erb b/app/views/admins/reversed_keywords/index.html.erb index 3907b32fc..a5218c9c9 100644 --- a/app/views/admins/reversed_keywords/index.html.erb +++ b/app/views/admins/reversed_keywords/index.html.erb @@ -11,6 +11,10 @@ <%= link_to "新增", new_admins_reversed_keyword_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
+
+ 旨在为特殊用户群体、特殊场景、路由而保留的关键词,如:Gitlink、Trustie等;目前主要在用户注册、创建组织、创建项目等场景下做关键词的验证. +
+
<%= render partial: 'admins/reversed_keywords/list', locals: { keywords: @keywords } %>
diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index cffcf6583..b4959c3ff 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -26,10 +26,11 @@
  • <%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories') %>
  • <%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses') %>
  • <%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores') %>
  • -
  • <%= sidebar_item(admins_reversed_keywords_path, '系统保留关键词', icon: 'key', controller: 'admins-reversed_keywords') %>
  • <% end %> +
  • <%= sidebar_item(admins_reversed_keywords_path, '系统保留关键词', icon: 'key', controller: 'admins-reversed_keywords') %>
  • +
  • <%= sidebar_item(admins_laboratories_path, '云上实验室', icon: 'cloud', controller: 'admins-laboratories') %>
  • From 7549557a622d4e9d1f15f637e4e8ee75fa6a12e8 Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 9 Sep 2021 18:40:53 +0800 Subject: [PATCH 06/10] =?UTF-8?q?FIX=20=E6=9B=B4=E6=94=B9hovercard?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/hovercard.json.jbuilder | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/users/hovercard.json.jbuilder b/app/views/users/hovercard.json.jbuilder index 79f1793fe..3555be236 100644 --- a/app/views/users/hovercard.json.jbuilder +++ b/app/views/users/hovercard.json.jbuilder @@ -3,18 +3,18 @@ json.login @user.login json.name @user.full_name json.location @user.location json.image_url url_to_avatar(@user) -json.url "#{request.base_url }/users/#{@user.login}" +json.url "#{request.base_url }/#{@user.login}" json.followers_count @user.followers_count -json.followers_url "#{base_url}/users/#{@user.login}/fan_users" +json.followers_url "#{base_url}/#{@user.login}/fan_users" json.following_count @user.following_count -json.following_url "#{base_url}/users/#{@user.login}/watchers" +json.following_url "#{base_url}/#{@user.login}/watchers" json.projects_count @user.projects_count -json.projects_url "#{base_url}/users/#{@user.login}" +json.projects_url "#{base_url}/#{@user.login}" json.projects_count @user.projects_count json.is_watch current_user&.watched?(@user) json.organizations @user.organizations do |organization| json.login organization.login json.name organization.real_name json.image_url url_to_avatar(organization) - json.url "#{base_url}/organize/#{organization.login}" + json.url "#{base_url}/#{organization.login}" end \ No newline at end of file From 6d581de01850f913c1a80b4ac61ae1e1c9c340cb Mon Sep 17 00:00:00 2001 From: jasder Date: Fri, 10 Sep 2021 11:13:49 +0800 Subject: [PATCH 07/10] FIX migrate project api bug --- app/forms/projects/migrate_form.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/forms/projects/migrate_form.rb b/app/forms/projects/migrate_form.rb index 13a3af2cb..ccd854478 100644 --- a/app/forms/projects/migrate_form.rb +++ b/app/forms/projects/migrate_form.rb @@ -1,9 +1,13 @@ class Projects::MigrateForm < BaseForm - attr_accessor :user_id, :name, :repository_name, :project_category_id, :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner + attr_accessor :user_id, :name, :repository_name, :project_category_id, :description, + :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner validates :user_id, :name, :repository_name, :clone_addr, presence: true validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" } validates :clone_addr, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" } + validates :name, length: { maximum: 50 } + validates :repository_name, length: { maximum: 100 } + validates :description, length: { maximum: 200 } validate do check_project_name(user_id, name) unless name.blank? check_repository_name(user_id, repository_name) unless repository_name.blank? From 4c41d5050620f24c0ddc33a64ac69e14b06039e4 Mon Sep 17 00:00:00 2001 From: jasder Date: Fri, 10 Sep 2021 15:29:08 +0800 Subject: [PATCH 08/10] =?UTF-8?q?ADD=20=E5=90=8E=E5=8F=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/edu_settings_controller.rb | 55 ++++++++++++++++++ app/controllers/admins/sites_controller.rb | 56 +++++++++++++++++++ app/controllers/edu_settings_controller.rb | 5 -- app/models/application_record.rb | 8 +++ app/models/edu_setting.rb | 34 +++++------ app/models/site.rb | 7 ++- app/queries/admins/edu_setting_query.rb | 28 ++++++++++ app/queries/admins/site_query.rb | 35 ++++++++++++ app/views/admins/edu_settings/_form.html.erb | 38 +++++++++++++ app/views/admins/edu_settings/_list.html.erb | 36 ++++++++++++ app/views/admins/edu_settings/edit.js.erb | 2 + app/views/admins/edu_settings/index.html.erb | 22 ++++++++ app/views/admins/edu_settings/index.js.erb | 1 + app/views/admins/edu_settings/new.js.erb | 2 + app/views/admins/shared/_sidebar.html.erb | 6 ++ app/views/admins/sites/_form.html.erb | 42 ++++++++++++++ app/views/admins/sites/_list.html.erb | 38 +++++++++++++ app/views/admins/sites/edit.js.erb | 2 + app/views/admins/sites/index.html.erb | 24 ++++++++ app/views/admins/sites/index.js.erb | 1 + app/views/admins/sites/new.js.erb | 2 + app/views/edu_settings/_form.html.erb | 27 --------- app/views/edu_settings/edit.html.erb | 6 -- app/views/edu_settings/index.html.erb | 30 ---------- app/views/edu_settings/new.html.erb | 5 -- app/views/edu_settings/show.html.erb | 14 ----- config/routes.rb | 2 + .../admins/edu_settings_controller_spec.rb | 47 ++++++++++++++++ .../admins/sites_controller_spec.rb | 5 ++ .../edu_settings/create.html.erb_spec.rb | 5 ++ .../edu_settings/destroy.html.erb_spec.rb | 5 ++ .../admins/edu_settings/edit.html.erb_spec.rb | 5 ++ .../edu_settings/index.html.erb_spec.rb | 5 ++ .../admins/edu_settings/new.html.erb_spec.rb | 5 ++ .../edu_settings/update.html.erb_spec.rb | 5 ++ 35 files changed, 505 insertions(+), 105 deletions(-) create mode 100644 app/controllers/admins/edu_settings_controller.rb create mode 100644 app/controllers/admins/sites_controller.rb create mode 100644 app/queries/admins/edu_setting_query.rb create mode 100644 app/queries/admins/site_query.rb create mode 100644 app/views/admins/edu_settings/_form.html.erb create mode 100644 app/views/admins/edu_settings/_list.html.erb create mode 100644 app/views/admins/edu_settings/edit.js.erb create mode 100644 app/views/admins/edu_settings/index.html.erb create mode 100644 app/views/admins/edu_settings/index.js.erb create mode 100644 app/views/admins/edu_settings/new.js.erb create mode 100644 app/views/admins/sites/_form.html.erb create mode 100644 app/views/admins/sites/_list.html.erb create mode 100644 app/views/admins/sites/edit.js.erb create mode 100644 app/views/admins/sites/index.html.erb create mode 100644 app/views/admins/sites/index.js.erb create mode 100644 app/views/admins/sites/new.js.erb delete mode 100644 app/views/edu_settings/_form.html.erb delete mode 100644 app/views/edu_settings/edit.html.erb delete mode 100644 app/views/edu_settings/index.html.erb delete mode 100644 app/views/edu_settings/new.html.erb delete mode 100644 app/views/edu_settings/show.html.erb create mode 100644 spec/controllers/admins/edu_settings_controller_spec.rb create mode 100644 spec/controllers/admins/sites_controller_spec.rb create mode 100644 spec/views/admins/edu_settings/create.html.erb_spec.rb create mode 100644 spec/views/admins/edu_settings/destroy.html.erb_spec.rb create mode 100644 spec/views/admins/edu_settings/edit.html.erb_spec.rb create mode 100644 spec/views/admins/edu_settings/index.html.erb_spec.rb create mode 100644 spec/views/admins/edu_settings/new.html.erb_spec.rb create mode 100644 spec/views/admins/edu_settings/update.html.erb_spec.rb diff --git a/app/controllers/admins/edu_settings_controller.rb b/app/controllers/admins/edu_settings_controller.rb new file mode 100644 index 000000000..9d9334b23 --- /dev/null +++ b/app/controllers/admins/edu_settings_controller.rb @@ -0,0 +1,55 @@ +class Admins::EduSettingsController < Admins::BaseController + before_action :find_setting, only: [:edit,:update, :destroy] + + def index + default_sort('id', 'desc') + + edu_settings = Admins::EduSettingQuery.call(params) + @edu_settings = paginate edu_settings + end + + def new + @edu_setting = EduSetting.new + end + + def edit + end + + def create + @edu_setting = EduSetting.new(edu_setting_params) + if @edu_setting.save + redirect_to admins_edu_settings_path + flash[:success] = '创建成功' + else + redirect_to admins_edu_settings_path + flash[:danger] = @edu_setting.errors.full_messages.join(",") + end + end + + def update + if @edu_setting.update!(edu_setting_params) + flash[:success] = '更新成功' + else + flash[:danger] = @edu_setting.errors.full_messages.join(",") + end + redirect_to admins_edu_settings_path + end + + def destroy + if @edu_setting.destroy! + flash[:success] = '删除成功' + else + lash[:danger] = '删除失败' + end + redirect_to admins_edu_settings_path + end + + private + def find_setting + @edu_setting ||= EduSetting.find(params[:id]) + end + + def edu_setting_params + params.require(:edu_setting).permit(:name, :value, :description) + end +end diff --git a/app/controllers/admins/sites_controller.rb b/app/controllers/admins/sites_controller.rb new file mode 100644 index 000000000..f3da4ccf2 --- /dev/null +++ b/app/controllers/admins/sites_controller.rb @@ -0,0 +1,56 @@ +class Admins::SitesController < Admins::BaseController + before_action :find_site, only: [:edit,:update, :destroy] + + def index + default_sort('id', 'desc') + + sites = Admins::SiteQuery.call(params) + @sites = paginate sites + end + + def new + @site = Site.new + end + + def edit + end + + def create + @site = Site.new(site_params) + if @site.save + redirect_to admins_sites_path + flash[:success] = '创建成功' + else + redirect_to admins_sites_path + flash[:danger] = @site.errors.full_messages.join(",") + end + end + + def update + if @site.update!(site_params) + flash[:success] = '更新成功' + else + flash[:danger] = @site.errors.full_messages.join(",") + end + redirect_to admins_sites_path + end + + def destroy + if @site.destroy! + flash[:success] = '删除成功' + else + lash[:danger] = '删除失败' + end + redirect_to admins_sites_path + end + + private + def find_site + @site ||= Site.find(params[:id]) + end + + def site_params + params.require(:site).permit(:name, :url, :key, :site_type) + end + +end diff --git a/app/controllers/edu_settings_controller.rb b/app/controllers/edu_settings_controller.rb index d3b796da7..340b03ddc 100644 --- a/app/controllers/edu_settings_controller.rb +++ b/app/controllers/edu_settings_controller.rb @@ -29,10 +29,8 @@ class EduSettingsController < ApplicationController respond_to do |format| if @edu_setting.save - format.html { redirect_to @edu_setting, notice: 'Edu setting was successfully created.' } format.json { render :show, status: :created, location: @edu_setting } else - format.html { render :new } format.json { render json: @edu_setting.errors, status: :unprocessable_entity } end end @@ -43,10 +41,8 @@ class EduSettingsController < ApplicationController def update respond_to do |format| if @edu_setting.update(edu_setting_params) - format.html { redirect_to @edu_setting, notice: 'Edu setting was successfully updated.' } format.json { render :show, status: :ok, location: @edu_setting } else - format.html { render :edit } format.json { render json: @edu_setting.errors, status: :unprocessable_entity } end end @@ -57,7 +53,6 @@ class EduSettingsController < ApplicationController def destroy @edu_setting.destroy respond_to do |format| - format.html { redirect_to edu_settings_url, notice: 'Edu setting was successfully destroyed.' } format.json { head :no_content } end end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 3ab2b11e8..0b95d7a58 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -24,4 +24,12 @@ class ApplicationRecord < ActiveRecord::Base def reset_platform_cache_async_job ResetPlatformCacheJob.perform_later end + + def self.strip_param(key) + key.to_s.strip.presence + end + + def strip_param(key) + key.to_s.strip.presence + end end diff --git a/app/models/edu_setting.rb b/app/models/edu_setting.rb index 6968b008e..22575ff15 100644 --- a/app/models/edu_setting.rb +++ b/app/models/edu_setting.rb @@ -1,22 +1,24 @@ -# == Schema Information -# -# Table name: edu_settings -# -# id :integer not null, primary key -# name :string(255) -# value :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# description :string(255) -# -# Indexes -# -# index_edu_settings_on_name (name) UNIQUE -# - +# == Schema Information +# +# Table name: edu_settings +# +# id :integer not null, primary key +# name :string(255) +# value :string(255) +# created_at :datetime not null +# updated_at :datetime not null +# description :string(255) +# +# Indexes +# +# index_edu_settings_on_name (name) UNIQUE +# + class EduSetting < ApplicationRecord after_commit :expire_value_cache + scope :by_search, -> (keyword){ where("name LIKE :keyword OR value LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? } + def value_cache_key self.class.value_cache_key(name) end diff --git a/app/models/site.rb b/app/models/site.rb index 58daddf14..de352dcc5 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -17,6 +17,9 @@ class Site < ApplicationRecord # common: 普通链接 enum site_type: { add: 0, personal: 1, common: 2 } + scope :by_search, -> (keyword){ where("name LIKE :keyword OR url LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? } + scope :by_site_type, -> (site_type){ where(site_type: strip_param(site_type)) unless strip_param(site_type).blank? } + def self.set_default_menu set_add_menu! set_personal_menu! @@ -26,8 +29,8 @@ class Site < ApplicationRecord private def self.set_add_menu! adds= [ - {name: '新建镜像项目', key: 'add_mirror_project', url: '/projects/mirror/new'}, - {name: '新建托管项目', key: 'add_common', url: '/projects/deposit/new'}, + {name: '新建项目', key: 'add_mirror_project', url: '/projects/mirror/new'}, + {name: '导入项目', key: 'add_common', url: '/projects/deposit/new'}, {name: '新建组织', key: 'add_r', url: '/organize/new'}] adds.each { |ele| diff --git a/app/queries/admins/edu_setting_query.rb b/app/queries/admins/edu_setting_query.rb new file mode 100644 index 000000000..3e61ffd33 --- /dev/null +++ b/app/queries/admins/edu_setting_query.rb @@ -0,0 +1,28 @@ +class Admins::EduSettingQuery < ApplicationQuery + include CustomSortable + + attr_reader :params + + sort_columns :id, default_by: :id, default_direction: :desc + + def initialize(params) + @params = params + end + + def call + collection = EduSetting.all + collection = filter_settings(collection) + + custom_sort collection, params[:sort_by], params[:sort_direction] + end + + def filter_settings(collection) + by_search(collection) + end + + def by_search(collection) + keyword = strip_param(:search) + collection.by_search(keyword) + end + +end \ No newline at end of file diff --git a/app/queries/admins/site_query.rb b/app/queries/admins/site_query.rb new file mode 100644 index 000000000..1d15f0312 --- /dev/null +++ b/app/queries/admins/site_query.rb @@ -0,0 +1,35 @@ +class Admins::SiteQuery < ApplicationQuery + include CustomSortable + + attr_reader :params + + sort_columns :id, default_by: :id, default_direction: :desc + + def initialize(params) + @params = params + end + + def call + collection = Site.all + collection = filter_sites(collection) + + custom_sort collection, params[:sort_by], params[:sort_direction] + end + + def filter_sites(collection) + collection = by_search(collection) + collection = by_stie_type(collection) + collection + end + + def by_search(collection) + keyword = strip_param(:search) + collection.by_search(keyword) + end + + def by_stie_type(collection) + site_type = strip_param(:site_type) + collection.by_site_type(site_type) + end + +end \ No newline at end of file diff --git a/app/views/admins/edu_settings/_form.html.erb b/app/views/admins/edu_settings/_form.html.erb new file mode 100644 index 000000000..cce930f2a --- /dev/null +++ b/app/views/admins/edu_settings/_form.html.erb @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/app/views/admins/edu_settings/_list.html.erb b/app/views/admins/edu_settings/_list.html.erb new file mode 100644 index 000000000..a37cc9bef --- /dev/null +++ b/app/views/admins/edu_settings/_list.html.erb @@ -0,0 +1,36 @@ + + + + + + + + + + + + + <% if edu_settings.present? %> + <% edu_settings.each_with_index do |edu_setting, index| %> + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号变量名变量值备注说明<%= sort_tag('创建时间', name: 'created_at', path: admins_edu_settings_path) %>操作
    <%= list_index_no((params[:page] || 1).to_i, index) %> + <%= edu_setting.name %> + <%= edu_setting.value %><%= overflow_hidden_span display_text(edu_setting.description), width: 200 %><%= edu_setting.created_at&.strftime('%Y-%m-%d %H:%M') %> + <%= link_to "编辑", edit_admins_edu_setting_path(edu_setting), remote: true, class: "action" %> + <%= link_to "删除", admins_edu_setting_path(edu_setting), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: edu_settings } %> \ No newline at end of file diff --git a/app/views/admins/edu_settings/edit.js.erb b/app/views/admins/edu_settings/edit.js.erb new file mode 100644 index 000000000..c2e0405f2 --- /dev/null +++ b/app/views/admins/edu_settings/edit.js.erb @@ -0,0 +1,2 @@ +$("#edu_setting-modals").html("<%= j render(partial: 'admins/edu_settings/form', locals: {type: 'update'}) %>") +$(".edu_setting-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/edu_settings/index.html.erb b/app/views/admins/edu_settings/index.html.erb new file mode 100644 index 000000000..d52480bae --- /dev/null +++ b/app/views/admins/edu_settings/index.html.erb @@ -0,0 +1,22 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('全局变量配置') %> +<% end %> + +
    + <%= form_tag(admins_edu_settings_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '关键字检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_edu_setting_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + 说明:该界面适用于存储全局变量. +
    + +
    + <%= render partial: 'admins/edu_settings/list', locals: { edu_settings: @edu_settings } %> +
    +
    +
    diff --git a/app/views/admins/edu_settings/index.js.erb b/app/views/admins/edu_settings/index.js.erb new file mode 100644 index 000000000..92a4bfeff --- /dev/null +++ b/app/views/admins/edu_settings/index.js.erb @@ -0,0 +1 @@ +$('.edu_settings-list-container').html("<%= j( render partial: 'admins/edu_settings/list', locals: { edu_settings: @edu_settings } ) %>"); \ No newline at end of file diff --git a/app/views/admins/edu_settings/new.js.erb b/app/views/admins/edu_settings/new.js.erb new file mode 100644 index 000000000..21abf3895 --- /dev/null +++ b/app/views/admins/edu_settings/new.js.erb @@ -0,0 +1,2 @@ +$("#edu_setting-modals").html("<%= j render(partial: 'admins/edu_settings/form', locals: {type: 'create'}) %>") +$(".edu_setting-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index b4959c3ff..e58337c18 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -43,6 +43,12 @@
  • <%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %>
  • <% end %> +
  • + <%= sidebar_item_group('#setting-system', '系统配置', icon: 'wrench') do %> +
  • <%= sidebar_item(admins_sites_path, 'setting接口配置', icon: 'deaf', controller: 'admins-sites') %>
  • +
  • <%= sidebar_item(admins_edu_settings_path, '全局变量配置', icon: 'pencil-square', controller: 'admins-edu_settings') %>
  • + <% end %> +
  • <%= sidebar_item('/admins/sidekiq', '定时任务', icon: 'bell', controller: 'root') %>
  • diff --git a/app/views/admins/sites/_form.html.erb b/app/views/admins/sites/_form.html.erb new file mode 100644 index 000000000..1776bcd03 --- /dev/null +++ b/app/views/admins/sites/_form.html.erb @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/app/views/admins/sites/_list.html.erb b/app/views/admins/sites/_list.html.erb new file mode 100644 index 000000000..bef39cf1f --- /dev/null +++ b/app/views/admins/sites/_list.html.erb @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + <% if sites.present? %> + <% sites.each_with_index do |site, index| %> + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号名称路由标识类型<%= sort_tag('创建时间', name: 'created_at', path: admins_sites_path) %>操作
    <%= list_index_no((params[:page] || 1).to_i, index) %> + <%= overflow_hidden_span display_text(site.name), width: 150 %> + <%= site.url %><%= overflow_hidden_span display_text(site.key), width: 150 %><%= site.site_type.humanize %><%= site.created_at&.strftime('%Y-%m-%d %H:%M') %> + <%= link_to "编辑", edit_admins_site_path(site), remote: true, class: "action" %> + <%= link_to "删除", admins_site_path(site), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: sites } %> \ No newline at end of file diff --git a/app/views/admins/sites/edit.js.erb b/app/views/admins/sites/edit.js.erb new file mode 100644 index 000000000..6711ffc1f --- /dev/null +++ b/app/views/admins/sites/edit.js.erb @@ -0,0 +1,2 @@ +$("#site-modals").html("<%= j render(partial: 'admins/sites/form', locals: {type: 'update'}) %>") +$(".site-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/sites/index.html.erb b/app/views/admins/sites/index.html.erb new file mode 100644 index 000000000..8a5fa1bfc --- /dev/null +++ b/app/views/admins/sites/index.html.erb @@ -0,0 +1,24 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('Setting接口配置') %> +<% end %> + +
    + <%= form_tag(admins_sites_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> +
    + + <% type_options = [['全部', ''], ['Add', Site.site_types[:add]], ['Personal', Site.site_types[:personal]], ['Common', Site.site_types[:common]]] %> + <%= select_tag(:site_type, options_for_select(type_options), class: 'form-control') %> +
    + + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '关键字检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_site_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/sites/list', locals: { sites: @sites } %> +
    +
    +
    diff --git a/app/views/admins/sites/index.js.erb b/app/views/admins/sites/index.js.erb new file mode 100644 index 000000000..797d58296 --- /dev/null +++ b/app/views/admins/sites/index.js.erb @@ -0,0 +1 @@ +$('.sites-list-container').html("<%= j( render partial: 'admins/sites/list', locals: { sites: @sites } ) %>"); \ No newline at end of file diff --git a/app/views/admins/sites/new.js.erb b/app/views/admins/sites/new.js.erb new file mode 100644 index 000000000..6978fed32 --- /dev/null +++ b/app/views/admins/sites/new.js.erb @@ -0,0 +1,2 @@ +$("#site-modals").html("<%= j render(partial: 'admins/sites/form', locals: {type: 'create'}) %>") +$(".site-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/edu_settings/_form.html.erb b/app/views/edu_settings/_form.html.erb deleted file mode 100644 index 3b7f09f1c..000000000 --- a/app/views/edu_settings/_form.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<%= form_with(model: edu_setting, local: true) do |form| %> - <% if edu_setting.errors.any? %> -
    -

    <%= pluralize(edu_setting.errors.count, "error") %> prohibited this edu_setting from being saved:

    - -
      - <% edu_setting.errors.full_messages.each do |message| %> -
    • <%= message %>
    • - <% end %> -
    -
    - <% end %> - -
    - <%= form.label :name %> - <%= form.text_field :name %> -
    - -
    - <%= form.label :value %> - <%= form.text_field :value %> -
    - -
    - <%= form.submit %> -
    -<% end %> diff --git a/app/views/edu_settings/edit.html.erb b/app/views/edu_settings/edit.html.erb deleted file mode 100644 index 2a0796842..000000000 --- a/app/views/edu_settings/edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

    Editing Edu Setting

    - -<%= render 'form', edu_setting: @edu_setting %> - -<%= link_to 'Show', @edu_setting %> | -<%= link_to 'Back', edu_settings_path %> diff --git a/app/views/edu_settings/index.html.erb b/app/views/edu_settings/index.html.erb deleted file mode 100644 index d49977254..000000000 --- a/app/views/edu_settings/index.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -

    <%= notice %>

    - -

    EduCoder公共配置

    -

    说明:该界面适用于存储全局变量

    - - - - - - - - - - - - <% @edu_settings.each do |edu_setting| %> - - - - - - - - <% end %> - -
    变量名变量值
    <%= edu_setting.name %><%= edu_setting.value %><%= link_to 'Show', edu_setting %><%= link_to 'Edit', edit_edu_setting_path(edu_setting) %><%= link_to 'Destroy', edu_setting, method: :delete, data: { confirm: 'Are you sure?' } %>
    - -
    - -<%= link_to 'New Edu Setting', new_edu_setting_path %> diff --git a/app/views/edu_settings/new.html.erb b/app/views/edu_settings/new.html.erb deleted file mode 100644 index 8a70e3a63..000000000 --- a/app/views/edu_settings/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

    New Edu Setting

    - -<%= render 'form', edu_setting: @edu_setting %> - -<%= link_to 'Back', edu_settings_path %> diff --git a/app/views/edu_settings/show.html.erb b/app/views/edu_settings/show.html.erb deleted file mode 100644 index 9d027373f..000000000 --- a/app/views/edu_settings/show.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -

    <%= notice %>

    - -

    - Name: - <%= @edu_setting.name %> -

    - -

    - Value: - <%= @edu_setting.value %> -

    - -<%= link_to 'Edit', edit_edu_setting_path(@edu_setting) %> | -<%= link_to 'Back', edu_settings_path %> diff --git a/config/routes.rb b/config/routes.rb index 346468fb7..37b98b228 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -651,6 +651,8 @@ Rails.application.routes.draw do get :visits_static end end + resources :sites + resources :edu_settings resources :project_languages resources :project_categories resources :project_licenses diff --git a/spec/controllers/admins/edu_settings_controller_spec.rb b/spec/controllers/admins/edu_settings_controller_spec.rb new file mode 100644 index 000000000..ae5164879 --- /dev/null +++ b/spec/controllers/admins/edu_settings_controller_spec.rb @@ -0,0 +1,47 @@ +require 'rails_helper' + +RSpec.describe Admins::EduSettingsController, type: :controller do + + describe "GET #index" do + it "returns http success" do + get :index + expect(response).to have_http_status(:success) + end + end + + describe "GET #new" do + it "returns http success" do + get :new + expect(response).to have_http_status(:success) + end + end + + describe "GET #update" do + it "returns http success" do + get :update + expect(response).to have_http_status(:success) + end + end + + describe "GET #edit" do + it "returns http success" do + get :edit + expect(response).to have_http_status(:success) + end + end + + describe "GET #create" do + it "returns http success" do + get :create + expect(response).to have_http_status(:success) + end + end + + describe "GET #destroy" do + it "returns http success" do + get :destroy + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/controllers/admins/sites_controller_spec.rb b/spec/controllers/admins/sites_controller_spec.rb new file mode 100644 index 000000000..0c5f79b3d --- /dev/null +++ b/spec/controllers/admins/sites_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Admins::SitesController, type: :controller do + +end diff --git a/spec/views/admins/edu_settings/create.html.erb_spec.rb b/spec/views/admins/edu_settings/create.html.erb_spec.rb new file mode 100644 index 000000000..bc53b9f18 --- /dev/null +++ b/spec/views/admins/edu_settings/create.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "edu_settings/create.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/admins/edu_settings/destroy.html.erb_spec.rb b/spec/views/admins/edu_settings/destroy.html.erb_spec.rb new file mode 100644 index 000000000..51acd4901 --- /dev/null +++ b/spec/views/admins/edu_settings/destroy.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "edu_settings/destroy.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/admins/edu_settings/edit.html.erb_spec.rb b/spec/views/admins/edu_settings/edit.html.erb_spec.rb new file mode 100644 index 000000000..e381cbb04 --- /dev/null +++ b/spec/views/admins/edu_settings/edit.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "edu_settings/edit.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/admins/edu_settings/index.html.erb_spec.rb b/spec/views/admins/edu_settings/index.html.erb_spec.rb new file mode 100644 index 000000000..ba6e16ebc --- /dev/null +++ b/spec/views/admins/edu_settings/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "edu_settings/index.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/admins/edu_settings/new.html.erb_spec.rb b/spec/views/admins/edu_settings/new.html.erb_spec.rb new file mode 100644 index 000000000..00bc830cd --- /dev/null +++ b/spec/views/admins/edu_settings/new.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "edu_settings/new.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/admins/edu_settings/update.html.erb_spec.rb b/spec/views/admins/edu_settings/update.html.erb_spec.rb new file mode 100644 index 000000000..89ae0feb8 --- /dev/null +++ b/spec/views/admins/edu_settings/update.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "edu_settings/update.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end From 96c79ffade03a1dae19d0d26a8e3938d8442e386 Mon Sep 17 00:00:00 2001 From: jasder Date: Fri, 10 Sep 2021 15:35:57 +0800 Subject: [PATCH 09/10] =?UTF-8?q?FIX=20=E8=80=BF=E7=9B=B4=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E9=A1=B9=E7=9B=AE=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/base_form.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index a939b1991..c41a12993 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -11,7 +11,7 @@ class BaseForm def check_repository_name(user_id, repository_name) check_reversed_keyword(repository_name) - raise "仓库名称已被使用." if Repository.where(user_id: user_id, identifier: repository_name.strip).exists? + raise "项目标识已被使用." if Repository.where(user_id: user_id, identifier: repository_name.strip).exists? end def check_project_name(user_id, project_name) @@ -19,7 +19,7 @@ class BaseForm end def check_reversed_keyword(repository_name) - raise "仓库名称已被占用." if ReversedKeyword.is_reversed(repository_name).exists? + raise "项目标识已被占用." if ReversedKeyword.is_reversed(repository_name).exists? end end From c82635f6c382fbbf14dd2e3da11acacce459165f Mon Sep 17 00:00:00 2001 From: jasder Date: Fri, 10 Sep 2021 17:57:49 +0800 Subject: [PATCH 10/10] =?UTF-8?q?FIX=20=E7=BB=84=E7=BB=87=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89readme=E7=9A=84=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/gitea/organization/repository/create_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/gitea/organization/repository/create_service.rb b/app/services/gitea/organization/repository/create_service.rb index 060a8ab05..2990f711e 100644 --- a/app/services/gitea/organization/repository/create_service.rb +++ b/app/services/gitea/organization/repository/create_service.rb @@ -15,8 +15,8 @@ class Gitea::Organization::Repository::CreateService < Gitea::ClientService private def request_params - create_params = params.merge(readme: "readme") - Hash.new.merge(token: token, data: create_params) + # create_params = params.merge(readme: "readme") + Hash.new.merge(token: token, data: params) end def url