| @@ -4,7 +4,7 @@ class Projects::CreateForm < BaseForm | |||||
| :blockchain, :blockchain_token_all, :blockchain_init_token | :blockchain, :blockchain_token_all, :blockchain_init_token | ||||
| validates :user_id, :name, :repository_name, presence: true | validates :user_id, :name, :repository_name, presence: true | ||||
| validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } | |||||
| validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } | |||||
| validates :name, length: { maximum: 50 } | validates :name, length: { maximum: 50 } | ||||
| validates :repository_name, length: { maximum: 100 } | validates :repository_name, length: { maximum: 100 } | ||||
| @@ -3,7 +3,7 @@ class Projects::MigrateForm < BaseForm | |||||
| :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner | :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner | ||||
| validates :user_id, :name, :repository_name, :clone_addr, presence: true | validates :user_id, :name, :repository_name, :clone_addr, presence: true | ||||
| validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "项目标识只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } | |||||
| validates :repository_name, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: "长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾" } | |||||
| validates :clone_addr, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" } | validates :clone_addr, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" } | ||||
| validates :name, length: { maximum: 50 } | validates :name, length: { maximum: 50 } | ||||
| validates :repository_name, length: { maximum: 100 } | validates :repository_name, length: { maximum: 100 } | ||||
| @@ -3,7 +3,7 @@ class Projects::UpdateForm < BaseForm | |||||
| validates :name, presence: true | validates :name, presence: true | ||||
| validates :name, length: { maximum: 50 } | validates :name, length: { maximum: 50 } | ||||
| validates :description, length: { maximum: 200 } | validates :description, length: { maximum: 200 } | ||||
| validates :identifier, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: '项目标识只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾' } | |||||
| validates :identifier, format: { with: CustomRegexp::REPOSITORY_NAME_REGEX, multiline: true, message: '长度为2~100, 只能包含数字,字母,下划线(_),中划线(-),英文句号(.),必须以数字和字母开头,不能以下划线/中划线/英文句号开头和结尾' } | |||||
| validate do | validate do | ||||
| check_project_category(project_category_id) | check_project_category(project_category_id) | ||||
| @@ -221,6 +221,8 @@ class Gitea::ClientService < ApplicationService | |||||
| end | end | ||||
| [body, message] | [body, message] | ||||
| rescue | |||||
| return [{}, ""] | |||||
| end | end | ||||
| def json_parse!(body) | def json_parse!(body) | ||||
| @@ -2,6 +2,10 @@ | |||||
| activemodel: | activemodel: | ||||
| attributes: | attributes: | ||||
| projects/create_form: | projects/create_form: | ||||
| name: 项目名称 | |||||
| repository_name: 项目标识 | |||||
| description: 项目简介 | |||||
| projects/migrate_form: | |||||
| name: 项目名称 | name: 项目名称 | ||||
| repository_name: 项目标识 | repository_name: 项目标识 | ||||
| description: 项目简介 | description: 项目简介 | ||||