Merge pull request '项目设置可更改项目标识' (#193) from yystopf/forgeplus:hh_fix_bug into develop
This commit is contained in:
commit
a8972276ec
|
@ -127,9 +127,9 @@ class ProjectsController < ApplicationController
|
|||
Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params)
|
||||
else
|
||||
validate_params = project_params.slice(:name, :description,
|
||||
:project_category_id, :project_language_id, :private)
|
||||
:project_category_id, :project_language_id, :private, :identifier)
|
||||
|
||||
Projects::UpdateForm.new(validate_params).validate!
|
||||
Projects::UpdateForm.new(validate_params.merge(user_id: @project.user_id)).validate!
|
||||
|
||||
private = @project.forked_from_project.present? ? !@project.forked_from_project.is_public : params[:private] || false
|
||||
|
||||
|
@ -139,12 +139,11 @@ class ProjectsController < ApplicationController
|
|||
gitea_params = {
|
||||
private: private,
|
||||
default_branch: @project.default_branch,
|
||||
website: @project.website
|
||||
website: @project.website,
|
||||
name: @project.identifier
|
||||
}
|
||||
if [true, false].include? private
|
||||
Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params)
|
||||
@project.repository.update_column(:hidden, private)
|
||||
end
|
||||
gitea_repo = Gitea::Repository::UpdateService.call(@owner, @project&.repository&.identifier, gitea_params)
|
||||
@project.repository.update_attributes({hidden: gitea_repo["private"], identifier: gitea_repo["name"]})
|
||||
end
|
||||
SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, @project.previous_changes.slice(:name, :description, :project_category_id, :project_language_id, :is_public))
|
||||
end
|
||||
|
@ -229,7 +228,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
private
|
||||
def project_params
|
||||
params.permit(:user_id, :name, :description, :repository_name, :website, :lesson_url, :default_branch,
|
||||
params.permit(:user_id, :name, :description, :repository_name, :website, :lesson_url, :default_branch, :identifier,
|
||||
:project_category_id, :project_language_id, :license_id, :ignore_id, :private)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
class Projects::UpdateForm < BaseForm
|
||||
attr_accessor :name, :description, :project_category_id, :project_language_id, :private
|
||||
attr_accessor :name, :description, :project_category_id, :project_language_id, :private, :identifier, :user_id
|
||||
validates :name, presence: true
|
||||
validates :name, length: { maximum: 50 }
|
||||
validates :description, length: { maximum: 200 }
|
||||
validate do
|
||||
check_project_category(project_category_id)
|
||||
check_project_language(project_language_id)
|
||||
check_repository_name(user_id, identifier) unless identifier.blank?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -19,7 +19,8 @@ class Gitea::Repository::UpdateService < Gitea::ClientService
|
|||
end
|
||||
|
||||
def call
|
||||
patch(url, data_params)
|
||||
response = patch(url, data_params)
|
||||
render_200_response(response)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in New Issue