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

履歴が大きすぎる場合に表示させないよう修正 #359

Merged
merged 4 commits into from
Apr 5, 2022
Merged
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
26 changes: 26 additions & 0 deletions app/controllers/decidim/debates/versions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module Decidim
module Debates
# Exposes Debates versions so users can see how a Debate has been updated
# through time.
class VersionsController < Decidim::Proposals::ApplicationController
include Decidim::ApplicationHelper
include Decidim::ResourceVersionsConcern

OBJECT_CHANGE_SIZE_LIMIT = 1_000_000

def versioned_resource
@versioned_resource ||= present(Debate.where(component: current_component).find(params[:debate_id]))
end

def show
description = current_version.object_changes
if description.size > OBJECT_CHANGE_SIZE_LIMIT
flash[:alert] = I18n.t("debates.versions.too_large_changeset", scope: "decidim.debates")
redirect_to action: :index
end
end
end
end
end
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ en:
occupation: Occupation
real_name: Real Name
decidim:
debates:
debates:
versions:
too_large_changeset: This changeset is too large to show.
following:
non_public_followings: Some of the resources followed are not public.
enums:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ ja:
citizens: 一般参加者
official: 事務局
origin: 起案者
versions:
too_large_changeset: 履歴のサイズが大きすぎるため表示できません
devise:
registrations:
new:
Expand Down
4 changes: 4 additions & 0 deletions docs/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Decidim本体のバージョンを更新する際、特に注意が必要な内

https://github.com/decidim/decidim/pull/7781 で本家にフィードバックしたので、これが取り込まれたバージョン(v0.25.0以降)になればファイルごと削除できるはずです。

* `app/controllers/decidim/debates/versions_controller.rb`

https://github.com/codeforjapan/decidim-cfj/pull/359 で追加したファイル。履歴の差分が巨大になるとサーバ負荷が大きいため、renderを実行させないよう表示前にredirectさせるものです。

* `app/forms/decidim/proposals/proposal_wizard_create_step_form.rb`, `app/forms/decidim/proposals/admin/proposal_form.rb`

https://github.com/codeforjapan/decidim-cfj/issues/23 の対応のために追加されたもの。対応するPRは https://github.com/codeforjapan/decidim-cfj/pull/60 https://github.com/codeforjapan/decidim-cfj/pull/163 です。
Expand Down
2 changes: 1 addition & 1 deletion spec/sytem/needs_user_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
context "without user extension" do
it "redirect to account page" do
visit decidim.notifications_path
expect(page).to have_current_path(decidim.account_path)
expect(page).to have_current_path(decidim.account_path, ignore_query: true)
end

it "not redirect in root page" do
Expand Down