Skip to content

Commit

Permalink
Ignore context if allow_attachments_in_comments is disable for the or…
Browse files Browse the repository at this point in the history
…ganization
  • Loading branch information
entantoencuanto committed Nov 27, 2024
1 parent a62b389 commit c7f8b59
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ def cache_hash
end

def attachments_allowed?
@attachments_allowed ||= begin
if model.respond_to?(:component)
awesome_config_instance.context_from_component(model.component)
elsif model.is_a?(Decidim::Participable)
awesome_config_instance.context_from_participatory_space(model)
else
awesome_config_instance.context_from_request(request)
end

awesome_config_instance.enabled_in_context?(:allow_attachments_in_comments)
@attachments_allowed ||= attachments_config_from_context
end

def attachments_config_from_context
return false unless Decidim::DecidimAwesome::AwesomeConfig.find_by(var: :allow_attachments_in_comments, organization: current_organization)&.value

if model.respond_to?(:component)
awesome_config_instance.context_from_component(model.component)
elsif model.is_a?(Decidim::Participable)
awesome_config_instance.context_from_participatory_space(model)
else
awesome_config_instance.context_from_request(request)
end

awesome_config_instance.enabled_in_context?(:allow_attachments_in_comments)
end
end
end
Expand Down

0 comments on commit c7f8b59

Please sign in to comment.