6772312ea7
The primary license of the project is changing to: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later with some specific files to be licensed under the one of two licenses: CC0-1.0 LGPL-3.0-or-later This commit is one of the many steps to relicense the entire codebase. Documentation granting permission for this relicensing (from all past contributors who hold copyrights) is on file with Software Freedom Conservancy, Inc.
28 lines
No EOL
698 B
Ruby
28 lines
No EOL
698 B
Ruby
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
class SlugCopyNamingAlgorithm < CopyNamingAlgorithm
|
|
|
|
attr_accessor :klass, :nonprofit_id
|
|
# @param [Class] klass
|
|
def initialize(klass, nonprofit_id)
|
|
@klass = klass
|
|
@nonprofit_id = nonprofit_id
|
|
end
|
|
|
|
def copy_addition
|
|
"_copy"
|
|
end
|
|
|
|
def max_copies
|
|
30
|
|
end
|
|
|
|
def get_name_for_entity(name_entity)
|
|
name_entity.slug
|
|
end
|
|
|
|
def get_already_used_name_entities(base_name)
|
|
end_name = "\\_copy\\_\\d{2}"
|
|
@klass.method(:where).call('slug SIMILAR TO ? AND nonprofit_id = ? AND (deleted IS NULL OR deleted = false)', base_name + end_name, nonprofit_id).select('slug')
|
|
end
|
|
|
|
end |