diff --git a/app/models/concerns/with_publication.rb b/app/models/concerns/with_publication.rb index ae94dce5f572b66cb4f4ffd8b0047384bb9521bb..539d96deff7f035789bc681c706b24d3ade950a6 100644 --- a/app/models/concerns/with_publication.rb +++ b/app/models/concerns/with_publication.rb @@ -13,7 +13,7 @@ module WithPublication end def draft? - !published || published_in_the_future? + !published end def published_in_the_future? diff --git a/app/views/admin/application/property/_publication.html.erb b/app/views/admin/application/property/_publication.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..55171777d6fe4cd8b958fabfae37e57d9a15498d --- /dev/null +++ b/app/views/admin/application/property/_publication.html.erb @@ -0,0 +1,14 @@ +<% +object ||= about +# admin.communication.website.posts +i18n_key = "admin.#{object.class.to_s.pluralize.downcase.gsub('::', '.')}" +%> +<% if object.draft? %> + <span class="badge bg-secondary"> + <%= t("#{i18n_key}.draft") %> + </span> +<% elsif object.published_in_the_future? %> + <span class="badge bg-secondary"> + <%= t("#{i18n_key}.published_on", date: l(object.published_at.to_date)) %> + </span> +<% end %> diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index c7ba609be7eb3ae6249496570a331dd811d9edaa..947ce7aba8c46b1a25069fc530c1087e54e9e851 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -5,11 +5,7 @@ <div class="col-lg-7"> <%= osuny_panel Communication::Website::Page.human_attribute_name(:title), small: true do %> <p class="lead mb-1"><%= @page.title %></p> - <% if @page.draft? %> - <span class="badge bg-secondary"> - <%= t('admin.communication.website.posts.draft') %> - </span> - <% end %> + <%= render 'admin/application/property/publication', about: @page %> <% end %> </div> <div class="offset-lg-1 col-lg-4"> diff --git a/app/views/admin/communication/websites/posts/show.html.erb b/app/views/admin/communication/websites/posts/show.html.erb index 89590fee099a1d5fa0321775ee2cde20c1a94fa5..49e0b63289b89466b55b920a20af8b07befcc56c 100644 --- a/app/views/admin/communication/websites/posts/show.html.erb +++ b/app/views/admin/communication/websites/posts/show.html.erb @@ -5,11 +5,7 @@ <div class="col-lg-7"> <%= osuny_panel Communication::Website::Post.human_attribute_name(:title), small: true do %> <p class="lead mb-1"><%= @post.title %></p> - <% if @post.draft? %> - <span class="badge bg-secondary"> - <%= t('admin.communication.website.posts.draft') %> - </span> - <% end %> + <%= render 'admin/application/property/publication', about: @post %> <% end %> </div> <div class="offset-lg-1 col-lg-4">