debian-mirror-gitlab/app/services/customer_relations/contacts/base_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
849 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module CustomerRelations
module Contacts
class BaseService < ::BaseGroupService
private
def allowed?
2021-12-11 22:18:48 +05:30
current_user&.can?(:admin_crm_contact, group)
2021-11-18 22:05:49 +05:30
end
def error(message)
ServiceResponse.error(message: Array(message))
end
2022-07-16 23:28:13 +05:30
def organization_valid?
return true unless params[:organization_id]
organization = Organization.find(params[:organization_id])
organization.group_id == group.id
rescue ActiveRecord::RecordNotFound
false
end
def error_organization_invalid
error('The specified organization was not found or does not belong to this group')
end
def error_no_permissions
error('You have insufficient permissions to manage contacts for this group')
end
2021-11-18 22:05:49 +05:30
end
end
end