From a81b59035645410f659318383b3b667e83d5a0e1 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 19 Jul 2022 14:15:06 -0300 Subject: [PATCH] =?UTF-8?q?no=20fallar=20si=20el=20sitio=20no=20existe=20m?= =?UTF-8?q?=C3=A1s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/sites/index.haml | 85 ++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index b3d99ca5..4b483e75 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -14,47 +14,50 @@ %table.table.table-condensed %tbody - @sites.each do |site| + -# Los sitios pueden fallar en cargar si los eliminamos físicamente del disco - begin - next unless site.jekyll - - rol = current_usuarie.rol_for_site(site) - -# - TODO: Solo les usuaries cachean porque tenemos que separar - les botones por permisos. - - cache_if (rol.usuarie? && !rol.temporal), [site, I18n.locale] do - %tr - %td - %h2 - - if policy(site).show? - = link_to site.title, site_posts_path(site, locale: site.default_locale) - - else - = site.title - %p.lead= site.description - %br - = link_to t('.visit'), site.url, class: 'btn' - - if rol.temporal - = button_to t('sites.invitations.accept'), - site_usuaries_accept_invitation_path(site), - method: :patch, - title: t('help.sites.invitations.accept'), - class: 'btn' - = button_to t('sites.invitations.reject'), - site_usuaries_reject_invitation_path(site), - method: :patch, - title: t('help.sites.invitations.reject'), - class: 'btn' + - rescue StandardError => e + - ExceptionNotifier.notify_exception(e, data: { site: @site.name, usuarie: current_usuarie.id }) + - next + + - rol = current_usuarie.rol_for_site(site) + -# + TODO: Solo les usuaries cachean porque tenemos que separar + les botones por permisos. + - cache_if (rol.usuarie? && !rol.temporal), [site, I18n.locale] do + %tr + %td + %h2 + - if policy(site).show? + = link_to site.title, site_posts_path(site, locale: site.default_locale) - else - - if policy(site).show? - = render 'layouts/btn_with_tooltip', - tooltip: t('help.sites.edit_posts'), - type: 'success', - link: site_path(site), - text: t('sites.posts') - - if policy(SiteUsuarie.new(site, current_usuarie)).index? - = render 'layouts/btn_with_tooltip', - tooltip: t('usuaries.index.help.self'), - text: t('usuaries.index.title'), - type: 'info', - link: site_usuaries_path(site) - = render 'sites/build', site: site - - rescue ActionView::Template::Error => e - - ExceptionNotifier.notify_exception(e.cause, data: { site: @site.name, usuarie: current_usuarie.id }) + = site.title + %p.lead= site.description + %br + = link_to t('.visit'), site.url, class: 'btn' + - if rol.temporal + = button_to t('sites.invitations.accept'), + site_usuaries_accept_invitation_path(site), + method: :patch, + title: t('help.sites.invitations.accept'), + class: 'btn' + = button_to t('sites.invitations.reject'), + site_usuaries_reject_invitation_path(site), + method: :patch, + title: t('help.sites.invitations.reject'), + class: 'btn' + - else + - if policy(site).show? + = render 'layouts/btn_with_tooltip', + tooltip: t('help.sites.edit_posts'), + type: 'success', + link: site_path(site), + text: t('sites.posts') + - if policy(SiteUsuarie.new(site, current_usuarie)).index? + = render 'layouts/btn_with_tooltip', + tooltip: t('usuaries.index.help.self'), + text: t('usuaries.index.title'), + type: 'info', + link: site_usuaries_path(site) + = render 'sites/build', site: site