diff --git a/decidim-accountability/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb b/decidim-accountability/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb index dba15a314a849..c55efeac40f88 100644 --- a/decidim-accountability/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +++ b/decidim-accountability/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb @@ -31,6 +31,18 @@ def results_to_render def results_count @results_count ||= results.count end + + def cache_hash + hash = [] + hash << "decidim/accountability/highlighted_results_for_component" + hash << results.cache_key_with_version + hash << I18n.locale.to_s + hash.join(Decidim.cache_key_separator) + end + + def expiry_time + 10.minutes + end end end end diff --git a/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb b/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb index 13b746f733b51..97fef224a4c8c 100644 --- a/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb +++ b/decidim-assemblies/app/cells/decidim/assemblies/content_blocks/highlighted_assemblies_cell.rb @@ -6,10 +6,6 @@ module ContentBlocks class HighlightedAssembliesCell < Decidim::ViewModel delegate :current_user, to: :controller - cache :show, expires_in: 10.minutes, if: :perform_caching? do - cache_hash - end - def show render if highlighted_assemblies.any? end @@ -42,6 +38,10 @@ def cache_hash hash.push(I18n.locale) hash.join(Decidim.cache_key_separator) end + + def expiry_time + 10.minutes + end end end end diff --git a/decidim-conferences/app/cells/decidim/conferences/content_blocks/highlighted_conferences_cell.rb b/decidim-conferences/app/cells/decidim/conferences/content_blocks/highlighted_conferences_cell.rb index e81f0782ae191..eb9ad846eb1b5 100644 --- a/decidim-conferences/app/cells/decidim/conferences/content_blocks/highlighted_conferences_cell.rb +++ b/decidim-conferences/app/cells/decidim/conferences/content_blocks/highlighted_conferences_cell.rb @@ -6,10 +6,6 @@ module ContentBlocks class HighlightedConferencesCell < Decidim::ViewModel delegate :current_user, to: :controller - cache :show, expires_in: 10.minutes, if: :perform_caching? do - cache_hash - end - def show render if highlighted_conferences.any? end @@ -33,6 +29,10 @@ def cache_hash hash.push(I18n.locale) hash.join(Decidim.cache_key_separator) end + + def expiry_time + 10.minutes + end end end end diff --git a/decidim-core/app/cells/decidim/content_blocks/stats_cell.rb b/decidim-core/app/cells/decidim/content_blocks/stats_cell.rb index c3d4398c00e04..e6fab66c55c88 100644 --- a/decidim-core/app/cells/decidim/content_blocks/stats_cell.rb +++ b/decidim-core/app/cells/decidim/content_blocks/stats_cell.rb @@ -3,10 +3,6 @@ module Decidim module ContentBlocks class StatsCell < Decidim::ViewModel - cache :show, expires_in: 10.minutes, if: :perform_caching? do - cache_hash - end - def stats @stats ||= HomeStatsPresenter.new(organization: current_organization) end @@ -18,6 +14,10 @@ def cache_hash hash.push(I18n.locale) hash.join(Decidim.cache_key_separator) end + + def expiry_time + 10.minutes + end end end end diff --git a/decidim-core/app/views/decidim/application/_attachments.html.erb b/decidim-core/app/views/decidim/application/_attachments.erb similarity index 100% rename from decidim-core/app/views/decidim/application/_attachments.html.erb rename to decidim-core/app/views/decidim/application/_attachments.erb diff --git a/decidim-core/app/views/decidim/application/_document.html.erb b/decidim-core/app/views/decidim/application/_document.erb similarity index 100% rename from decidim-core/app/views/decidim/application/_document.html.erb rename to decidim-core/app/views/decidim/application/_document.erb diff --git a/decidim-core/app/views/decidim/application/_documents.html.erb b/decidim-core/app/views/decidim/application/_documents.erb similarity index 100% rename from decidim-core/app/views/decidim/application/_documents.html.erb rename to decidim-core/app/views/decidim/application/_documents.erb diff --git a/decidim-core/app/views/decidim/application/_photos.html.erb b/decidim-core/app/views/decidim/application/_photos.erb similarity index 100% rename from decidim-core/app/views/decidim/application/_photos.html.erb rename to decidim-core/app/views/decidim/application/_photos.erb diff --git a/decidim-core/lib/decidim/view_model.rb b/decidim-core/lib/decidim/view_model.rb index 07d7b3f0ac321..94c0c138d0eb2 100644 --- a/decidim-core/lib/decidim/view_model.rb +++ b/decidim-core/lib/decidim/view_model.rb @@ -19,7 +19,7 @@ class ViewModel < Cell::ViewModel delegate :current_organization, to: :controller - cache :show, if: :perform_caching? do + cache :show, if: :perform_caching?, expires_in: :expiry_time do cache_hash end @@ -60,6 +60,10 @@ def cache_hash nil end + def expiry_time + nil + end + def decidim Decidim::Core::Engine.routes.url_helpers end diff --git a/decidim-elections/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb b/decidim-elections/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb index bdc35213516c5..69866883ea98c 100644 --- a/decidim-elections/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb +++ b/decidim-elections/app/cells/decidim/votings/content_blocks/highlighted_votings_cell.rb @@ -6,10 +6,6 @@ module ContentBlocks class HighlightedVotingsCell < Decidim::ViewModel delegate :current_user, to: :controller - cache :show, expires_in: 10.minutes, if: :perform_caching? do - cache_hash - end - def show render if highlighted_votings.any? end @@ -39,6 +35,10 @@ def cache_hash hash.push(I18n.locale) hash.join(Decidim.cache_key_separator) end + + def expiry_time + 10.minutes + end end end end diff --git a/decidim-elections/config/locales/en.yml b/decidim-elections/config/locales/en.yml index 3bed6a892015c..362b5e1effdaf 100644 --- a/decidim-elections/config/locales/en.yml +++ b/decidim-elections/config/locales/en.yml @@ -1276,8 +1276,8 @@ en: check_status: Check status description: Here, you have the option to check your census data to know if you have the right to participate in this voting. You should have an access code already but if you lost it, you can ask for it again, when your data is correct. error: - info: 'Please try again. If you think the data in the system is incorrect, you can report it here: %{census_contact_information}.' - title: Your census data is incorrect! + info: 'Please try again. If you think the data in the system is incorrect, you can report it here: %{census_contact_information}' + title: The data you have entered are not in the census for this vote form_title: 'Fill the following form to check your census data:' invalid: There was a problem checking the census. success: diff --git a/decidim-elections/spec/cells/decidim/votings/content_blocks/landing_page/attachments_and_folders_cell_spec.rb b/decidim-elections/spec/cells/decidim/votings/content_blocks/landing_page/attachments_and_folders_cell_spec.rb new file mode 100644 index 0000000000000..69c345cdb7f1e --- /dev/null +++ b/decidim-elections/spec/cells/decidim/votings/content_blocks/landing_page/attachments_and_folders_cell_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe Decidim::Votings::ContentBlocks::LandingPage::AttachmentsAndFoldersCell, type: :cell do + subject { cell(content_block.cell, content_block).call } + + controller Decidim::Votings::VotingsController + + let(:organization) { create(:organization) } + let(:voting) { create(:voting, :published, organization: organization) } + let(:content_block) { create :content_block, organization: organization, manifest_name: :attachments_and_folders, scope_name: :voting_landing_page } + let!(:attachment_pdf) { create(:attachment, :with_pdf, attached_to: voting) } + let!(:attachment_img) { create(:attachment, :with_image, attached_to: voting) } + + before do + allow(controller).to receive(:current_participatory_space).and_return(voting) + allow(controller).to receive(:current_organization).and_return(organization) + end + + context "when rendering attachments" do + it "shows image attachment" do + expect(subject).to have_selector(".attachments .thumbnail", count: 1) + end + + it "shows pdf attachment" do + expect(subject).to have_selector(".documents .card__link", count: 1) + end + end +end diff --git a/decidim-elections/spec/system/check_census_spec.rb b/decidim-elections/spec/system/check_census_spec.rb index 21b3afee88638..32ba39f5a8ef5 100644 --- a/decidim-elections/spec/system/check_census_spec.rb +++ b/decidim-elections/spec/system/check_census_spec.rb @@ -135,7 +135,7 @@ it "shows note that census data is not correct" do within ".wrapper" do - expect(page).to have_content("Your census data is incorrect") + expect(page).to have_content("The data you have entered are not in the census for this vote") expect(page).to have_content("Fill the following form to check your census data:") end end diff --git a/decidim-meetings/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb b/decidim-meetings/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb index 5155628c23bad..ebcf7290b9310 100644 --- a/decidim-meetings/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +++ b/decidim-meetings/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb @@ -44,6 +44,15 @@ def past_meetings_count def upcoming_meetings_count @upcoming_meetings_count ||= meetings.upcoming.count end + + def cache_hash + hash = [] + hash << "decidim/meetings/highlighted_meetings_for_component" + hash << meetings.cache_key_with_version + hash.push(current_user.try(:id)) + hash << I18n.locale.to_s + hash.join(Decidim.cache_key_separator) + end end end end diff --git a/decidim-meetings/app/jobs/decidim/meetings/upcoming_meeting_notification_job.rb b/decidim-meetings/app/jobs/decidim/meetings/upcoming_meeting_notification_job.rb index be41fa381cdbf..f9f4376e802f8 100644 --- a/decidim-meetings/app/jobs/decidim/meetings/upcoming_meeting_notification_job.rb +++ b/decidim-meetings/app/jobs/decidim/meetings/upcoming_meeting_notification_job.rb @@ -7,7 +7,10 @@ class UpcomingMeetingNotificationJob < ApplicationJob def perform(meeting_id, checksum) meeting = Decidim::Meetings::Meeting.find(meeting_id) - send_notification(meeting) if verify_checksum(meeting, checksum) + return if meeting.hidden? || meeting.withdrawn? + return unless verify_checksum(meeting, checksum) + + send_notification(meeting) end def self.generate_checksum(meeting) diff --git a/decidim-meetings/spec/jobs/decidim/meetings/upcoming_meeting_notification_job_spec.rb b/decidim-meetings/spec/jobs/decidim/meetings/upcoming_meeting_notification_job_spec.rb index 3a0a34759ada0..7a7949a5598c3 100644 --- a/decidim-meetings/spec/jobs/decidim/meetings/upcoming_meeting_notification_job_spec.rb +++ b/decidim-meetings/spec/jobs/decidim/meetings/upcoming_meeting_notification_job_spec.rb @@ -39,4 +39,26 @@ subject.perform_now(meeting.id, checksum) end end + + context "when the meeting is hidden" do + let!(:moderation) { create(:moderation, reportable: meeting, report_count: 1, hidden_at: Time.current) } + + it "doesn't notify the upcoming meeting" do + expect(Decidim::EventsManager) + .not_to receive(:publish) + + subject.perform_now(meeting.id, checksum) + end + end + + context "when the meeting is withdrawn" do + let(:meeting) { create :meeting, :withdrawn, start_time: start_time } + + it "doesn't notify the upcoming meeting" do + expect(Decidim::EventsManager) + .not_to receive(:publish) + + subject.perform_now(meeting.id, checksum) + end + end end diff --git a/decidim-participatory_processes/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb b/decidim-participatory_processes/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb index a719f550b1d4f..4830239bbd634 100644 --- a/decidim-participatory_processes/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb +++ b/decidim-participatory_processes/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb @@ -4,12 +4,12 @@
<%= decidim_sanitize_editor translated_attribute(participatory_process_group.description) %>
-
+
<%= icon "grid-three-up", role: "img", "aria-hidden": true, class: "mr-xs" %> <%= t("decidim.participatory_process_groups.content_blocks.title.participatory_processes", count: participatory_processes_count) %>
<% if has_meta_scope? %> -
+
<%= icon "globe", class: "mr-xs" %> <%= t("decidim.participatory_process_groups.content_blocks.title.meta_scope") %> <%= translated_attribute(meta_scope) %> diff --git a/decidim-proposals/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb b/decidim-proposals/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb index 79959bba28204..a32757b4cef41 100644 --- a/decidim-proposals/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +++ b/decidim-proposals/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb @@ -29,6 +29,14 @@ def proposals_to_render def proposals_count @proposals_count ||= proposals.count end + + def cache_hash + hash = [] + hash << "decidim/proposals/highlighted_proposals_for_component" + hash << proposals.cache_key_with_version + hash << I18n.locale.to_s + hash.join(Decidim.cache_key_separator) + end end end end