forked from Trustie/forgeplus
FIX delete some mandatory field with projects list api
This commit is contained in:
parent
3e8df9316c
commit
67d4544d6b
|
@ -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|镜像源仓库的登录秘密 |
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue