From 78f757d429d3ec336ccbe36060d87769386a8bea Mon Sep 17 00:00:00 2001 From: f Date: Fri, 6 Sep 2024 16:01:52 -0300 Subject: [PATCH] feat: poder establecer una lista de esquemas para invitades #17343 --- app/models/site/layout_ordering.rb | 8 ++++++-- app/views/posts/index.haml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/site/layout_ordering.rb b/app/models/site/layout_ordering.rb index 9fecbf21..79e53c75 100644 --- a/app/models/site/layout_ordering.rb +++ b/app/models/site/layout_ordering.rb @@ -13,11 +13,15 @@ class Site # Por defecto, si el sitio no lo soporta, se obtienen los layouts # ordenados alfabéticamente por traducción. # + # @param [Usuarie,nil] # @return [Hash] - def schema_organization + def schema_organization(usuarie = nil) @schema_organization ||= begin - schema_organization = data.dig('schema', 'organization') + # XXX: retrocompatibilidad + key = (usuarie.blank? || usuarie?(usuarie)) ? 'organization' : 'organization_guest' + schema_organization = data.dig('schema', key) + schema_organization ||= data.dig('schema', 'organization') schema_organization&.symbolize_keys! schema_organization&.transform_values! do |ary| ary.map(&:to_sym) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 5d180518..0ff30799 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -16,7 +16,7 @@ %h3= t('posts.new') %table.table.table-sm.mb-3 %tbody - - @site.schema_organization.each do |schema, _| + - @site.schema_organization(current_usuarie).each do |schema, _| - schema = @site.layouts[schema] - next if schema.hidden? = render 'schemas/row', site: @site, schema: schema, filter: @filter_params