Validate project limit only when create project
This commit is contained in:
parent
34c97a311c
commit
a36195bd28
2 changed files with 8 additions and 5 deletions
|
@ -46,11 +46,14 @@ module Projects
|
||||||
@project.creator = current_user
|
@project.creator = current_user
|
||||||
|
|
||||||
if @project.save
|
if @project.save
|
||||||
unless @project.group
|
|
||||||
@project.users_projects.create(project_access: UsersProject::MASTER, user: current_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
@project.discover_default_branch
|
@project.discover_default_branch
|
||||||
|
|
||||||
|
unless @project.group
|
||||||
|
@project.users_projects.create(
|
||||||
|
project_access: UsersProject::MASTER,
|
||||||
|
user: current_user
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@project
|
@project
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Project < ActiveRecord::Base
|
||||||
format: { with: URI::regexp(%w(git http https)), message: "should be a valid url" },
|
format: { with: URI::regexp(%w(git http https)), message: "should be a valid url" },
|
||||||
if: :import?
|
if: :import?
|
||||||
|
|
||||||
validate :check_limit
|
validate :check_limit, on: :create
|
||||||
|
|
||||||
# Scopes
|
# Scopes
|
||||||
scope :without_user, ->(user) { where("projects.id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) }
|
scope :without_user, ->(user) { where("projects.id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) }
|
||||||
|
|
Loading…
Reference in a new issue