@@ -4,9 +4,10 @@ class PetitionsController < ApplicationController
44 before_action :avoid_unknown_state_filters , only : :index
55 before_action :do_not_cache , except : %i[ index show ]
66
7- before_action :retrieve_petition , only : [ :show , :count , :moderation_info ]
8- before_action :redirect_to_moderation_info_url , if : :not_moderated? , only : :show
9- before_action :redirect_to_petition_url , if : :moderated? , only : :moderation_info
7+ before_action :retrieve_petition , only : [ :show , :count , :gathering_support , :moderation_info ]
8+ before_action :redirect_to_gathering_support_url , if : :collecting_sponsors? , only : [ :moderation_info , :show ]
9+ before_action :redirect_to_moderation_info_url , if : :in_moderation? , only : [ :gathering_support , :show ]
10+ before_action :redirect_to_petition_url , if : :moderated? , only : [ :gathering_support , :moderation_info ]
1011
1112 before_action :set_cors_headers , only : [ :index , :show , :count ] , if : :json_request?
1213
@@ -91,8 +92,16 @@ def avoid_unknown_state_filters
9192 redirect_to url_for ( params . merge ( state : 'all' ) ) unless public_petition_facets . include? params [ :state ] . to_sym
9293 end
9394
94- def not_moderated?
95- !@petition . moderated?
95+ def collecting_sponsors?
96+ @petition . collecting_sponsors?
97+ end
98+
99+ def redirect_to_gathering_support_url
100+ redirect_to gathering_support_petition_url ( @petition )
101+ end
102+
103+ def in_moderation?
104+ @petition . in_moderation?
96105 end
97106
98107 def redirect_to_moderation_info_url
0 commit comments