Merge pull request #2946 from consul/backport-customize_proposals_view
Simplify legislation proposals customization
This commit is contained in:
@@ -2,13 +2,13 @@ class Legislation::ProposalsController < Legislation::BaseController
|
||||
include CommentableActions
|
||||
include FlagActions
|
||||
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
load_and_authorize_resource :proposal, class: "Legislation::Proposal", through: :process
|
||||
|
||||
before_action :parse_tag_filter, only: :index
|
||||
before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary]
|
||||
before_action :load_geozones, only: [:edit, :map, :summary]
|
||||
|
||||
before_action :authenticate_user!, except: [:index, :show, :map, :summary]
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
load_and_authorize_resource :proposal, class: "Legislation::Proposal", through: :process
|
||||
|
||||
invisible_captcha only: [:create, :update], honeypot: :subtitle
|
||||
|
||||
|
||||
@@ -6,4 +6,8 @@ module LegislationHelper
|
||||
def format_date_for_calendar_form(date)
|
||||
l(date, format: "%d/%m/%Y") if date
|
||||
end
|
||||
|
||||
def new_legislation_proposal_link_text(process)
|
||||
t("proposals.index.start_proposal")
|
||||
end
|
||||
end
|
||||
|
||||
28
app/views/legislation/processes/_proposals_content.html.erb
Normal file
28
app/views/legislation/processes/_proposals_content.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
<div class="row">
|
||||
<div class="debate-chooser">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="legislation-proposals">
|
||||
<% if proposals.empty? %>
|
||||
<div class="callout primary">
|
||||
<p><%= t("legislation.processes.proposals.empty_proposals") %></p>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render proposals %>
|
||||
<%= paginate proposals %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<% if process.proposals_phase.open? %>
|
||||
<p><%= link_to new_legislation_proposal_link_text(process),
|
||||
new_legislation_process_proposal_path(process),
|
||||
class: 'button expanded',
|
||||
id: 'create-new-proposal' %></p>
|
||||
<% end %>
|
||||
<%= render 'legislation/proposals/categories', taggable: process %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,28 +4,4 @@
|
||||
|
||||
<%= render 'key_dates', process: @process, phase: :proposals %>
|
||||
|
||||
<div class="row">
|
||||
<div class="debate-chooser">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="legislation-proposals">
|
||||
<% if @proposals.empty? %>
|
||||
<div class="callout primary">
|
||||
<p><%= t('.empty_proposals') %></p>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render @proposals %>
|
||||
<%= paginate @proposals %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<% if @process.proposals_phase.open? %>
|
||||
<p><%= link_to t("proposals.index.start_proposal"), new_legislation_process_proposal_path(@process), class: 'button expanded' %></p>
|
||||
<% end %>
|
||||
<%= render 'legislation/proposals/categories', taggable: @process %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= render 'proposals_content', process: @process, proposals: @proposals %>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
section "Creating legislation processes" do
|
||||
5.times do
|
||||
9.times do |i|
|
||||
Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60),
|
||||
description: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
summary: Faker::Lorem.paragraph,
|
||||
additional_info: Faker::Lorem.paragraphs.join("\n\n"),
|
||||
proposals_description: Faker::Lorem.paragraph,
|
||||
start_date: Date.current - 3.days,
|
||||
end_date: Date.current + 3.days,
|
||||
debate_start_date: Date.current - 3.days,
|
||||
debate_end_date: Date.current - 1.day,
|
||||
proposals_phase_start_date: Date.current - 3.days,
|
||||
proposals_phase_end_date: Date.current - 1.day,
|
||||
draft_publication_date: Date.current + 1.day,
|
||||
allegations_start_date: Date.current + 2.days,
|
||||
allegations_end_date: Date.current + 3.days,
|
||||
result_publication_date: Date.current + 4.days,
|
||||
start_date: Date.current + (i - 7).days,
|
||||
end_date: Date.current + (i - 1).days,
|
||||
debate_start_date: Date.current + (i - 7).days,
|
||||
debate_end_date: Date.current + (i - 5).days,
|
||||
proposals_phase_start_date: Date.current + (i - 7).days,
|
||||
proposals_phase_end_date: Date.current + (i - 5).days,
|
||||
draft_publication_date: Date.current + (i - 3).days,
|
||||
allegations_start_date: Date.current + (i - 2).days,
|
||||
allegations_end_date: Date.current + (i - 1).days,
|
||||
result_publication_date: Date.current + i.days,
|
||||
debate_phase_enabled: true,
|
||||
allegations_phase_enabled: true,
|
||||
draft_publication_enabled: true,
|
||||
|
||||
@@ -255,6 +255,16 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("There are no proposals")
|
||||
end
|
||||
|
||||
scenario 'create proposal button redirects to register path if user is not logged in' do
|
||||
process = create(:legislation_process, :in_proposals_phase)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
click_link "Create a proposal"
|
||||
|
||||
expect(page).to have_current_path new_user_session_path
|
||||
expect(page).to have_content "You must sign in or register to continue"
|
||||
end
|
||||
|
||||
include_examples "not published permissions", :legislation_process_proposals_path
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user