Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect /pages/accessibilitat #572

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions app/controllers/decidim/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

module Decidim
# This controller serves static pages using HighVoltage.
class PagesController < Decidim::ApplicationController
layout "layouts/decidim/application"

helper_method :page, :pages, :page_content_blocks
helper CtaButtonHelper
helper Decidim::SanitizeHelper

before_action :legacy_redirect, :set_default_request_format, :accessibility_redirect

def index
enforce_permission_to :read, :public_page
@topics = StaticPageTopic.where(organization: current_organization)
@orphan_pages = StaticPage.where(topic: nil, organization: current_organization)
end

def show
@page = current_organization.static_pages.find_by!(slug: params[:id])
enforce_permission_to :read, :public_page, page: @page
@topic = @page.topic
@pages = @topic&.pages
raise
end

private

def legacy_redirect
redirect_to decidim.page_path("terms-of-service") if params[:id] == "terms-and-conditions"
end

def accessibility_redirect
if params[:id] == "accessibilitat"
if params[:locale] == "es"
redirect_to "https://ajuntament.barcelona.cat/declaracio-accessibilitat/es/decidim-barcelona"
else
redirect_to "https://ajuntament.barcelona.cat/declaracio-accessibilitat/ca/decidim-barcelona"
end
end
end

def set_default_request_format
request.format = :html
end

def page_content_blocks
return [] unless Decidim.page_blocks.include?(@page.slug)

@page_content_blocks ||= Decidim::ContentBlock.published
.for_scope(:static_page, organization: current_organization)
.where(scoped_resource_id: @page.id)
.reject { |content_block| content_block.manifest.nil? }
end
end
end
3 changes: 2 additions & 1 deletion spec/lib/overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"/app/cells/decidim/activities_cell.rb" => "dd17416a8d1efe7f26b1e759613e4db4",
"/app/cells/decidim/user_profile_cell.rb" => "71216a17c7eea8dd8ebc1ea3907efaef",
"/lib/decidim/search_resource_fields_mapper.rb" => "ff2cc476eb72c2942cf2e69ae21b84fa",
"/app/views/layouts/decidim/header/_main.html.erb" => "a6496ec11e073062743a927ee3c8bd3c"
"/app/views/layouts/decidim/header/_main.html.erb" => "a6496ec11e073062743a927ee3c8bd3c",
"/app/controllers/decidim/pages_controller.rb" => "f91d3b04c66db579dfaa7f230d28a381"
}
},
{
Expand Down
Loading