项目名称和描述增加敏感词检测
This commit is contained in:
parent
e76822eb34
commit
dc787a35d4
|
@ -138,6 +138,8 @@ class Project < ApplicationRecord
|
||||||
delegate :content, to: :project_detail, allow_nil: true
|
delegate :content, to: :project_detail, allow_nil: true
|
||||||
delegate :name, to: :license, prefix: true, allow_nil: true
|
delegate :name, to: :license, prefix: true, allow_nil: true
|
||||||
|
|
||||||
|
validate :validate_sensitive_string
|
||||||
|
|
||||||
def self.all_visible(user_id=nil)
|
def self.all_visible(user_id=nil)
|
||||||
user_projects_sql = Project.joins(:owner).where(users: {type: 'User'}).to_sql
|
user_projects_sql = Project.joins(:owner).where(users: {type: 'User'}).to_sql
|
||||||
org_public_projects_sql = Project.joins(:owner).merge(Organization.joins(:organization_extension).where(organization_extensions: {visibility: 'common'})).to_sql
|
org_public_projects_sql = Project.joins(:owner).merge(Organization.joins(:organization_extension).where(organization_extensions: {visibility: 'common'})).to_sql
|
||||||
|
@ -409,4 +411,9 @@ class Project < ApplicationRecord
|
||||||
def is_transfering
|
def is_transfering
|
||||||
applied_transfer_project&.common? ? true : false
|
applied_transfer_project&.common? ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_sensitive_string
|
||||||
|
raise("项目名称包含敏感词汇,请重新输入") if name && !HarmoniousDictionary.clean?(name)
|
||||||
|
raise("项目描述包含敏感词汇,请重新输入") if description && !HarmoniousDictionary.clean?(description)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue