Skip to content

Commit

Permalink
WIP fixing integration test [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
stbnrivas committed Jul 5, 2021
1 parent a1397cf commit 8c0344b
Show file tree
Hide file tree
Showing 110 changed files with 151 additions and 1,533 deletions.
7 changes: 0 additions & 7 deletions app/assets/stylesheets/module-consultations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ img.side_50 {
height: auto;
}

.gobierto_admin {
#check_participation,
#check_participation_results {
display: none;
}
}

.consultation_cont {
margin: 3em 0;

Expand Down
1 change: 0 additions & 1 deletion app/controllers/gobierto_admin/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def default_modules_home_paths
gobierto_budgets: admin_gobierto_budgets_options_path,
gobierto_budget_consultations: admin_budget_consultations_path,
gobierto_people: admin_people_people_path,
gobierto_participation: admin_participation_path,
gobierto_plans: admin_plans_plans_path,
gobierto_citizens_charters: admin_citizens_charters_path,
gobierto_investments: admin_investments_projects_path,
Expand Down
27 changes: 2 additions & 25 deletions app/controllers/gobierto_admin/gobierto_cms/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,8 @@ def destroy
load_page
process = find_process if params[:process_id]

redirect_path = if process
admin_participation_process_pages_path(process_id: process)
else
admin_common_collection_path(@page.collection)
end

if @page.destroyable?
@page.destroy
redirect_to redirect_path, notice: t(".success")
else
redirect_to redirect_path, alert: destroy_error_message
end
redirect_path = admin_common_collection_path(@page.collection)
redirect_to redirect_path, alert: t("gobierto_admin.gobierto_cms.pages.destroy.error_associated_items", links: associated_items_html).html_safe
end

def recover
Expand Down Expand Up @@ -161,19 +151,6 @@ def find_collection(collection_id)
::GobiertoCommon::Collection.find_by(id: collection_id)
end

def destroy_error_message
associated_items_html = @page.process_stage_pages.map do |stage_page|
edit_page_path = edit_admin_participation_process_process_stage_process_stage_page_path(
stage_page,
process_id: stage_page.process.id,
process_stage_id: stage_page.process_stage
)
"<a href='#{edit_page_path}'>#{stage_page.process.title}</a>"
end.join(", ").html_safe

t("gobierto_admin.gobierto_cms.pages.destroy.error_associated_items", links: associated_items_html).html_safe
end

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def ignored_collection_attributes
end

def container_items
[current_site, current_site.people, current_site.processes].flatten
[current_site, current_site.people].flatten
end

def find_containers
Expand All @@ -147,19 +147,9 @@ def load_collection

def redirect_to_custom_show
case @collection.item_type
when "GobiertoCms::News"
if @collection.container.is_a?(::GobiertoParticipation::Process)
redirect_to admin_participation_process_pages_path(@collection.container) and return false
end
when "GobiertoAttachments::Attachment"
if @collection.container.is_a?(::GobiertoParticipation::Process)
redirect_to admin_participation_process_file_attachments_path(@collection.container) and return false
end
when "GobiertoCalendars::Event"
if @collection.container.is_a?(::GobiertoPeople::Person)
redirect_to admin_calendars_events_path(collection_id: @collection.id) and return false
elsif @collection.container.is_a?(::GobiertoParticipation::Process)
redirect_to admin_participation_process_events_path(@collection.container) and return false
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ class AttachmentDocumentsController < GobiertoAttachments::ApplicationController

include ::PreviewTokenHelper

attr_reader :current_process
helper_method :current_process

before_action :load_attachment
before_render :set_context

Expand All @@ -33,11 +30,6 @@ def set_context
return unless @attachment

@current_module = @attachment.module
@current_process ||= begin
if @collection && @collection.container_type == "GobiertoParticipation::Process"
@collection.container
end
end
end
end
end
46 changes: 1 addition & 45 deletions app/controllers/gobierto_cms/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,7 @@ class ApplicationController < ::ApplicationController
include User::SessionHelper
include ::PreviewTokenHelper

DEFAULT_LAYOUT = "gobierto_cms/layouts/application"
layout "gobierto_cms/layouts/application"

layout :pick_layout

before_render :set_current_module

# FIXME
helper_method :current_process

private

# FIXME
def current_process
@current_process
end

protected

def set_current_module
return if @collection.nil?

if params[:process_id]
@current_module = "gobierto_participation"
else
case @collection.container_type
when "GobiertoParticipation"
@current_module = "gobierto_participation"
when "GobiertoParticipation::Process"
@current_module = "gobierto_participation"
@current_process ||= @collection.container
end
end
end

def pick_layout
return DEFAULT_LAYOUT if @collection.nil?

case (@page ? @page.context : @collection.container_type)
when "GobiertoParticipation"
"gobierto_participation/layouts/application"
when "GobiertoParticipation::Process"
"gobierto_participation/layouts/application"
else
DEFAULT_LAYOUT
end
end
end
end
9 changes: 1 addition & 8 deletions app/controllers/gobierto_cms/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module GobiertoCms
class PagesController < GobiertoCms::ApplicationController
before_action :load_section, :load_current_process, only: [:show]
before_render :load_collection_pages

def index
Expand Down Expand Up @@ -36,7 +35,7 @@ def find_page
if @collection.nil? || (!page.public? && !valid_preview_token?)
raise ActiveRecord::RecordNotFound
end
GobiertoCms::PageDecorator.new(page, @current_process.class.name || @collection.container_type, @collection.item_type)
GobiertoCms::PageDecorator.new(page, @collection.container_type, @collection.item_type)
end

def find_section_item
Expand All @@ -57,12 +56,6 @@ def check_collection_type
render_404 and return false if @collection.item_type != "GobiertoCms::Page"
end

def load_current_process
if params[:process_id]
@current_process = processes_scope.find_by!(slug: params[:process_id])
end
end

def processes_scope
valid_preview_token? ? current_site.processes : current_site.processes.active
end
Expand Down
15 changes: 1 addition & 14 deletions app/controllers/user/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,7 @@ def referrer_entity
end

def define_referrer_url
@referrer_url = if params[:answers].present? || params[:poll_id].present?
poll = if params[:answers].present?
answer_id = params[:answers].split(",").first
GobiertoParticipation::PollAnswerTemplate.find(answer_id).question.poll
elsif params[:poll_id].present?
GobiertoParticipation::Poll.find(params[:poll_id])
end
process = poll.process
new_gobierto_participation_process_poll_answer_url(process_id: process.slug,
poll_id: poll.id,
answers: params[:answers])
else
request.referrer
end
@referrer_url = request.referrer
end

def check_auth_modules
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/user/subscription_preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def user_subscription_params
modules: [],
gobierto_people_people: [],
gobierto_budget_consultations_consultations: [],
gobierto_participation_issue: [],
gobierto_participation_processes: []
)
end
end
15 changes: 1 addition & 14 deletions app/controllers/user/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ def index
@user_notification_modules = get_user_notification_modules
@user_notification_gobierto_people_people = get_user_notification_gobierto_people_people
@user_notification_gobierto_budget_consultations_consultations = get_user_notification_gobierto_budget_consultations_consultations
@user_notification_gobierto_participation_processes = get_user_notification_gobierto_participation_processes
@user_subscription_preferences_form = User::SubscriptionPreferencesForm.new(
user: current_user,
site: current_site,
notification_frequency: current_user.notification_frequency,
site_to_subscribe: get_current_user_subsciption_to_site,
modules: get_current_user_subscribed_modules,
gobierto_people_people: get_current_user_subscribed_gobierto_people_people,
gobierto_budget_consultations_consultations: get_current_user_subscribed_gobierto_budet_consultations_consultations,
gobierto_participation_processes: get_current_user_subscribed_gobierto_participation_processes
gobierto_budget_consultations_consultations: get_current_user_subscribed_gobierto_budet_consultations_consultations
)
end

Expand Down Expand Up @@ -124,21 +122,10 @@ def get_user_notification_gobierto_budget_consultations_consultations
current_site.budget_consultations.active
end

def get_user_notification_gobierto_participation_processes
current_site.processes.active
end

def get_current_user_subscribed_gobierto_budet_consultations_consultations
get_user_notification_gobierto_budget_consultations_consultations.select do |consultation|
current_user.subscribed_to?(consultation, current_site)
end.map(&:id)
end

def get_current_user_subscribed_gobierto_participation_processes
if current_user.subscribed_to?(GobiertoParticipation::Process.new, current_site, :user_subscribed_by_broader_subscription_to?)
get_user_notification_gobierto_participation_processes.map(&:id)
else
current_user.subscriptions.specific.where(subscribable_type: "GobiertoParticipation::Process", site: current_site).pluck(:subscribable_id)
end
end
end
6 changes: 0 additions & 6 deletions app/decorators/gobierto_attachments/attachment_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ module GobiertoAttachments
class AttachmentDecorator < BaseDecorator
DEFAULT_TEMPLATE = ->(sub_template) { "gobierto_attachments/attachment_documents/templates/#{sub_template}" }
CONTEXT_CONFIGURATION = {
"GobiertoParticipation::Process" => { template: ->(sub_template) { "gobierto_participation/processes/attachments/templates/#{sub_template}" },
layout: 'gobierto_participation/layouts/application',
module: 'gobierto_participation' },
"GobiertoParticipation" => { template: ->(sub_template) { "gobierto_participation/attachments/templates/#{sub_template}" },
layout: 'gobierto_participation/layouts/application',
module: 'gobierto_participation' },
:default => { template: DEFAULT_TEMPLATE,
layout: nil,
module: nil },
Expand Down
13 changes: 1 addition & 12 deletions app/decorators/gobierto_cms/page_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ def initialize(page, context = nil, item_type = nil)
attr_reader :context

def template
case context
when "GobiertoParticipation"
"gobierto_participation/pages/templates/#{sub_template}"
when "GobiertoParticipation::Process"
"gobierto_participation/processes/pages/templates/#{sub_template}"
else
default_template
end
"gobierto_cms/pages/templates/#{@object.template || sub_template}"
end

def main_image
Expand All @@ -40,9 +33,5 @@ def sub_template
item_type.split('::').last.downcase
end

def default_template
"gobierto_cms/pages/templates/#{@object.template || sub_template}"
end

end
end
3 changes: 0 additions & 3 deletions app/forms/gobierto_admin/gobierto_common/collection_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def save_collection
collection_attributes.slug = slug
if container
collection_attributes.container = container
else
collection_attributes.container_type = "GobiertoParticipation"
collection_attributes.container_id = nil
end
collection_attributes.item_type = item_type
end
Expand Down
11 changes: 0 additions & 11 deletions app/forms/user/subscription_preferences_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class User::SubscriptionPreferencesForm < BaseForm
:modules,
:gobierto_people_people,
:gobierto_budget_consultations_consultations,
:gobierto_participation_processes,
:site_to_subscribe
)

Expand Down Expand Up @@ -47,7 +46,6 @@ def save_subscriptions
update_subscriptions_to_modules
update_subscriptions_to_people(gobierto_people_people)
update_subscriptions_to_consultations(gobierto_budget_consultations_consultations)
update_subscriptions_to_participation
end

@user
Expand Down Expand Up @@ -113,15 +111,6 @@ def update_subscriptions_to_consultations(budget_consultations)
end
end

def update_subscriptions_to_participation
return if broader_level_subscription_to?(GobiertoParticipation::Process.new)
return if gobierto_participation_processes.nil?

site.processes.active.each do |process|
gobierto_participation_processes.include?(process.id.to_s) ? user.subscribe_to!(process, site) : user.unsubscribe_from!(process, site)
end
end

def broader_level_subscription_to?(subscribable)
user.subscribed_to?(subscribable, site, :user_subscribed_by_broader_subscription_to?)
end
Expand Down
Loading

0 comments on commit 8c0344b

Please sign in to comment.