diff --git a/Gemfile b/Gemfile
index 509673e4e..c701fc38e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -56,6 +56,8 @@ gem 'unicorn', '~> 5.4.0'
gem 'whenever', '~> 0.10.0', require: false
gem 'globalize', '~> 5.0.0'
gem 'globalize-accessors', '~> 0.2.1'
+gem 'wkhtmltopdf-binary', '~> 0.12.4'
+gem 'wicked_pdf', '~> 1.1.0'
source 'https://rails-assets.org' do
gem 'rails-assets-leaflet'
diff --git a/Gemfile.lock b/Gemfile.lock
index 1cbd74edf..3cf8dc7ac 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -495,6 +495,8 @@ GEM
railties (>= 4.2)
whenever (0.10.0)
chronic (>= 0.6.3)
+ wicked_pdf (1.1.0)
+ wkhtmltopdf-binary (0.12.4)
xpath (3.0.0)
nokogiri (~> 1.8)
@@ -586,6 +588,8 @@ DEPENDENCIES
unicorn (~> 5.4.0)
web-console (~> 3.3.0)
whenever (~> 0.10.0)
+ wicked_pdf (~> 1.1.0)
+ wkhtmltopdf-binary (~> 0.12.4)
BUNDLED WITH
1.16.2
diff --git a/app/assets/images/default_poster.jpg b/app/assets/images/default_poster.jpg
new file mode 100644
index 000000000..b067bc081
Binary files /dev/null and b/app/assets/images/default_poster.jpg differ
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 704b3a52a..6fb2948b2 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -11,6 +11,7 @@
@import 'proposal';
@import 'proposal-graph';
@import 'dashboard_mailer_preview';
+@import 'dashboard_poster_preview';
@import 'poll';
@import 'legislation';
@import 'legislation_process';
diff --git a/app/assets/stylesheets/dashboard_poster_preview.scss b/app/assets/stylesheets/dashboard_poster_preview.scss
new file mode 100644
index 000000000..418ec2a56
--- /dev/null
+++ b/app/assets/stylesheets/dashboard_poster_preview.scss
@@ -0,0 +1,81 @@
+.dashboard-poster-preview {
+
+ .header {
+ background-color: #3700fd;
+ color: white;
+ padding: 40pt 40pt 80pt 40pt;
+ margin-bottom: 0;
+ border-bottom: 0;
+
+ h1 {
+ font-size: 40pt;
+ color: #dcf5fe;
+ }
+
+ h2 {
+ font-size: 40pt;
+ }
+
+ p {
+ text-align: justify;
+ width: 60%;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 40pt;
+ font-size: 18pt;
+ }
+
+ .image-caption {
+ margin-bottom: 0;
+ text-align: center;
+ color: white;
+ font-weight: bold;
+ font-size: 18pt;
+ }
+ }
+
+ .proposal-image {
+ display: block;
+ margin-top: -75pt;
+ margin-bottom: 40pt;
+
+ img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ }
+
+ h3 {
+ display: block;
+ width: 60%;
+ margin-left: auto;
+ margin-right: auto;
+ font-size: 18pt;
+ font-weight: bold;
+ color: #505050;
+ }
+
+ .proposal-title {
+ display: block;
+ font-size: 40pt;
+ font-weight: bold;
+ text-align: left;
+ margin-left: auto;
+ margin-right: auto;
+ color: #3800ff;
+ width: 60%;
+ margin-bottom: 40pt;
+ }
+
+ .poster-footer {
+ font-size: 15pt;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ width: 50%;
+ padding-left: 10pt;
+ border-left: 1pt solid darkgray;
+ text-align: left;
+ }
+}
diff --git a/app/assets/stylesheets/pdf_fonts.scss.erb b/app/assets/stylesheets/pdf_fonts.scss.erb
new file mode 100644
index 000000000..bbf549949
--- /dev/null
+++ b/app/assets/stylesheets/pdf_fonts.scss.erb
@@ -0,0 +1,64 @@
+// Fonts
+//
+// 01. Source Sans Pro (https://www.google.com/fonts/specimen/Source+Sans+Pro)
+// 02. Lato (https://www.google.com/fonts/specimen/Lato)
+//
+
+// 01. Source Sans Pro
+// - - - - - - - - - - - - - - - - - - - - - - - - -
+
+@font-face {
+ font-family: 'Source Sans Pro PDF';
+ font-style: normal;
+ font-weight: 300;
+ src: url("<%= ApplicationHelper.asset_data_base64('sourcesanspro-light-webfont.ttf') %>");
+}
+
+@font-face {
+ font-family: 'Source Sans Pro PDF';
+ font-style: normal;
+ font-weight: 400;
+ src: url("<%= ApplicationHelper.asset_data_base64('sourcesanspro-regular-webfont.ttf') %>");
+}
+
+@font-face {
+ font-family: 'Source Sans Pro PDF';
+ font-style: italic;
+ font-weight: 400;
+ src: url("<%= ApplicationHelper.asset_data_base64('sourcesanspro-italic-webfont.ttf') %>");
+}
+
+@font-face {
+ font-family: 'Source Sans Pro PDF';
+ font-style: normal;
+ font-weight: 700;
+ src: url("<%= ApplicationHelper.asset_data_base64('sourcesanspro-bold-webfont.ttf') %>");
+}
+
+// 02. Lato
+// - - - - - - - - - - - - - - - - - - - - - - - - -
+
+@font-face {
+ font-family: 'Lato PDF';
+ src: url("<%= ApplicationHelper.asset_data_base64('lato-light.ttf') %>");
+ font-weight: lighter;
+ font-style: normal;
+}
+
+@font-face {
+ font-family: 'Lato PDF';
+ src: url("<%= ApplicationHelper.asset_data_base64('lato-regular.ttf') %>");
+ font-weight: normal;
+ font-style: normal;
+}
+
+@font-face {
+ font-family: 'Lato PDF';
+ src: url("<%= ApplicationHelper.asset_data_base64('lato-bold.ttf') %>");
+ font-weight: bold;
+ font-style: normal;
+}
+
+body, h1, h2, h3 {
+ font-family: Source Sans Pro PDF !important;
+}
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index 2ae6e57fe..3e42480c9 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -1,6 +1,9 @@
class Admin::SettingsController < Admin::BaseController
+ include Admin::ManagesProposalSettings
+
helper_method :successful_proposal_setting, :successful_proposals, :poll_feature_short_title_setting, :poll_feature_description_setting,
- :poll_feature_link_setting, :email_feature_short_title_setting, :email_feature_description_setting
+ :poll_feature_link_setting, :email_feature_short_title_setting, :email_feature_description_setting,
+ :poster_feature_short_title_setting, :poster_feature_description_setting
def index
all_settings = Setting.all.group_by { |s| s.type }
@@ -28,32 +31,4 @@ class Admin::SettingsController < Admin::BaseController
def settings_params
params.require(:setting).permit(:value)
end
-
- def successful_proposal_setting
- @successful_proposal_setting ||= Setting.find_by(key: 'proposals.successful_proposal_id')
- end
-
- def successful_proposals
- Proposal.successful
- end
-
- def poll_feature_short_title_setting
- @poll_feature_short_title_setting ||= Setting.find_by(key: 'proposals.poll_short_title')
- end
-
- def poll_feature_description_setting
- @poll_feature_description_setting ||= Setting.find_by(key: 'proposals.poll_description')
- end
-
- def poll_feature_link_setting
- @poll_feature_link_setting ||= Setting.find_by(key: 'proposals.poll_link')
- end
-
- def email_feature_short_title_setting
- @email_feature_short_title_setting ||= Setting.find_by(key: 'proposals.email_short_title')
- end
-
- def email_feature_description_setting
- @email_feature_description_setting ||= Setting.find_by(key: 'proposals.email_description')
- end
end
diff --git a/app/controllers/concerns/admin/manages_proposal_settings.rb b/app/controllers/concerns/admin/manages_proposal_settings.rb
new file mode 100644
index 000000000..f0c185d8b
--- /dev/null
+++ b/app/controllers/concerns/admin/manages_proposal_settings.rb
@@ -0,0 +1,41 @@
+module Admin::ManagesProposalSettings
+ extend ActiveSupport::Concern
+
+ included do
+ def successful_proposal_setting
+ @successful_proposal_setting ||= Setting.find_by(key: 'proposals.successful_proposal_id')
+ end
+
+ def successful_proposals
+ Proposal.successful
+ end
+
+ def poll_feature_short_title_setting
+ @poll_feature_short_title_setting ||= Setting.find_by(key: 'proposals.poll_short_title')
+ end
+
+ def poll_feature_description_setting
+ @poll_feature_description_setting ||= Setting.find_by(key: 'proposals.poll_description')
+ end
+
+ def poll_feature_link_setting
+ @poll_feature_link_setting ||= Setting.find_by(key: 'proposals.poll_link')
+ end
+
+ def email_feature_short_title_setting
+ @email_feature_short_title_setting ||= Setting.find_by(key: 'proposals.email_short_title')
+ end
+
+ def email_feature_description_setting
+ @email_feature_description_setting ||= Setting.find_by(key: 'proposals.email_description')
+ end
+
+ def poster_feature_short_title_setting
+ @poster_feature_short_title_setting ||= Setting.find_by(key: 'proposals.poster_short_title')
+ end
+
+ def poster_feature_description_setting
+ @poster_feature_description_setting ||= Setting.find_by(key: 'proposals.poster_description')
+ end
+ end
+end
diff --git a/app/controllers/dashboard/poster_controller.rb b/app/controllers/dashboard/poster_controller.rb
new file mode 100644
index 000000000..5fbd85adf
--- /dev/null
+++ b/app/controllers/dashboard/poster_controller.rb
@@ -0,0 +1,16 @@
+class Dashboard::PosterController < Dashboard::BaseController
+ def index
+ authorize! :manage_poster, proposal
+
+ respond_to do |format|
+ format.html
+ format.pdf do
+ render pdf: 'poster', page_size: 'A3'
+ end
+ end
+ end
+
+ def new
+ authorize! :manage_poster, proposal
+ end
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 486759e03..b9017beb2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -60,4 +60,11 @@ module ApplicationHelper
def kaminari_path(url)
"#{root_url.chomp("\/")}#{url}"
end
+
+ def self.asset_data_base64(path)
+ asset = Rails.application.assets.find_asset(path)
+ throw "Could not find asset '#{path}'" if asset.nil?
+ base64 = Base64.encode64(asset.to_s).gsub(/\s+/, "")
+ "data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
+ end
end
diff --git a/app/helpers/proposals_dashboard_helper.rb b/app/helpers/proposals_dashboard_helper.rb
index 9c7ebf92d..b5e25378e 100644
--- a/app/helpers/proposals_dashboard_helper.rb
+++ b/app/helpers/proposals_dashboard_helper.rb
@@ -30,14 +30,22 @@ module ProposalsDashboardHelper
menu_entry(polls_menu_active?, &block)
end
+ def poster_menu(&block)
+ menu_entry(poster_menu_active?, &block)
+ end
+
def resources_menu_active?
- polls_menu_active? || mailing_menu_active? || is_resource_request?
+ poster_menu_active? || polls_menu_active? || mailing_menu_active? || is_resource_request?
end
def polls_menu_active?
controller_name == 'polls'
end
+ def poster_menu_active?
+ controller_name == 'poster'
+ end
+
def mailing_menu(&block)
menu_entry(mailing_menu_active?, &block)
end
diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb
index d2e4b326b..d2d51cfe9 100644
--- a/app/models/abilities/common.rb
+++ b/app/models/abilities/common.rb
@@ -28,6 +28,9 @@ module Abilities
can :manage_mailing, Proposal do |proposal|
proposal.author.id == user.id
end
+ can :manage_poster, Proposal do |proposal|
+ proposal.author.id == user.id
+ end
can :results, Poll do |poll|
poll.related&.author&.id == user.id
diff --git a/app/views/admin/settings/_proposals.html.erb b/app/views/admin/settings/_proposals.html.erb
index c18d7bf11..e9c9b4a28 100644
--- a/app/views/admin/settings/_proposals.html.erb
+++ b/app/views/admin/settings/_proposals.html.erb
@@ -17,90 +17,15 @@
<% end %>
-
- |
- <%= t("settings.#{poll_feature_short_title_setting.key}") %>
- |
-
- <%= form_for poll_feature_short_title_setting,
- url: admin_setting_path(poll_feature_short_title_setting),
- html: { id: "edit_#{dom_id(poll_feature_short_title_setting)}"} do |f| %>
-
- <%= f.text_field :value, label: false, id: dom_id(poll_feature_short_title_setting) %>
-
-
- <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
-
- <% end %>
- |
-
-
- |
- <%= t("settings.#{poll_feature_description_setting.key}") %>
- |
-
- <%= form_for poll_feature_description_setting,
- url: admin_setting_path(poll_feature_description_setting),
- html: { id: "edit_#{dom_id(poll_feature_description_setting)}"} do |f| %>
-
- <%= f.cktext_area :value, label: false, id: dom_id(poll_feature_description_setting) %>
-
-
- <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
-
- <% end %>
- |
-
-
- |
- <%= t("settings.#{poll_feature_link_setting.key}") %>
- |
-
- <%= form_for poll_feature_link_setting,
- url: admin_setting_path(poll_feature_link_setting),
- html: { id: "edit_#{dom_id(poll_feature_link_setting)}"} do |f| %>
-
- <%= f.text_field :value, label: false, id: dom_id(poll_feature_link_setting) %>
-
-
- <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
-
- <% end %>
- |
-
-
- |
- <%= t("settings.#{email_feature_short_title_setting.key}") %>
- |
-
- <%= form_for email_feature_short_title_setting,
- url: admin_setting_path(email_feature_short_title_setting),
- html: { id: "edit_#{dom_id(email_feature_short_title_setting)}"} do |f| %>
-
- <%= f.text_field :value, label: false, id: dom_id(email_feature_short_title_setting) %>
-
-
- <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
-
- <% end %>
- |
-
-
- |
- <%= t("settings.#{email_feature_description_setting.key}") %>
- |
-
- <%= form_for email_feature_description_setting,
- url: admin_setting_path(email_feature_description_setting),
- html: { id: "edit_#{dom_id(email_feature_description_setting)}"} do |f| %>
-
- <%= f.cktext_area :value, label: false, id: dom_id(email_feature_description_setting) %>
-
-
- <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
-
- <% end %>
- |
-
+
+ <%= render 'setting_text_field', setting: poll_feature_short_title_setting %>
+ <%= render 'setting_textarea_field', setting: poll_feature_description_setting %>
+ <%= render 'setting_text_field', setting: poll_feature_link_setting %>
+
+ <%= render 'setting_text_field', setting: email_feature_short_title_setting %>
+ <%= render 'setting_textarea_field', setting: email_feature_description_setting %>
+
+ <%= render 'setting_text_field', setting: poster_feature_short_title_setting %>
+ <%= render 'setting_textarea_field', setting: poster_feature_description_setting %>
diff --git a/app/views/admin/settings/_setting_text_field.html.erb b/app/views/admin/settings/_setting_text_field.html.erb
new file mode 100644
index 000000000..5d61d98f0
--- /dev/null
+++ b/app/views/admin/settings/_setting_text_field.html.erb
@@ -0,0 +1,18 @@
+
+ |
+ <%= t("settings.#{setting.key}") %>
+ |
+
+ <%= form_for setting,
+ url: admin_setting_path(setting),
+ html: { id: "edit_#{dom_id(setting)}"} do |f| %>
+
+ <%= f.text_field :value, label: false, id: dom_id(setting) %>
+
+
+ <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
+
+ <% end %>
+ |
+
+
diff --git a/app/views/admin/settings/_setting_textarea_field.html.erb b/app/views/admin/settings/_setting_textarea_field.html.erb
new file mode 100644
index 000000000..1d382fc09
--- /dev/null
+++ b/app/views/admin/settings/_setting_textarea_field.html.erb
@@ -0,0 +1,18 @@
+
+ |
+ <%= t("settings.#{setting.key}") %>
+ |
+
+ <%= form_for setting,
+ url: admin_setting_path(setting),
+ html: { id: "edit_#{dom_id(setting)}"} do |f| %>
+
+ <%= f.cktext_area :value, label: false, id: dom_id(setting) %>
+
+
+ <%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
+
+ <% end %>
+ |
+
+
diff --git a/app/views/dashboard/_menu.html.erb b/app/views/dashboard/_menu.html.erb
index 02a926866..c40257d87 100644
--- a/app/views/dashboard/_menu.html.erb
+++ b/app/views/dashboard/_menu.html.erb
@@ -42,6 +42,16 @@
<% end %>
<% end %>
+ <% if can?(:manage_poster, proposal) %>
+ <%= poster_menu do %>
+ <%= link_to new_proposal_dashboard_poster_path(proposal.to_param) do %>
+ ">
+ <%= t("dashboard.menu.poster") %>
+
+ <% end %>
+ <% end %>
+ <% end %>
+
<% resources.each do |resource| %>
>
<%= link_to new_request_proposal_dashboard_path(proposal, resource) do %>
diff --git a/app/views/dashboard/_poster_resource.html.erb b/app/views/dashboard/_poster_resource.html.erb
new file mode 100644
index 000000000..035fc2143
--- /dev/null
+++ b/app/views/dashboard/_poster_resource.html.erb
@@ -0,0 +1,26 @@
+<% if can?(:manage_poster, proposal) %>
+
+
"
+ data-position="bottom" data-alignment="right">
+
+
+
+
+
<%= t("dashboard.menu.poster") %>
+
+ <%= Setting['proposals.poster_short_title'] %>
+
+
+
+
+
+ <%= link_to t("dashboard.resource.request_resource"),
+ new_proposal_dashboard_poster_path(proposal.to_param),
+ class: 'button primary' %>
+
+
+
+
+<% end %>
+
diff --git a/app/views/dashboard/_resources.html.erb b/app/views/dashboard/_resources.html.erb
index 4cbe04dca..b66e6315c 100644
--- a/app/views/dashboard/_resources.html.erb
+++ b/app/views/dashboard/_resources.html.erb
@@ -8,6 +8,7 @@
<%= render 'poll_resource' %>
<%= render 'mailing_resource' %>
+ <%= render 'poster_resource' %>
<%= render partial: 'resource', collection: active_resources %>
diff --git a/app/views/dashboard/poster/_options.html.erb b/app/views/dashboard/poster/_options.html.erb
new file mode 100644
index 000000000..64820f0d0
--- /dev/null
+++ b/app/views/dashboard/poster/_options.html.erb
@@ -0,0 +1,13 @@
+
+ <% if action_name != 'index' %>
+ <%= link_to t("dashboard.poster.options.preview"),
+ proposal_dashboard_poster_index_path(proposal),
+ class: 'button expanded' %>
+ <% end %>
+
+ <%= link_to t("dashboard.poster.options.download"),
+ proposal_dashboard_poster_index_path(proposal, format: :pdf),
+ target: '_blank',
+ class: 'button expanded' %>
+
+
diff --git a/app/views/dashboard/poster/index.html.erb b/app/views/dashboard/poster/index.html.erb
new file mode 100644
index 000000000..9f22cdfc2
--- /dev/null
+++ b/app/views/dashboard/poster/index.html.erb
@@ -0,0 +1,25 @@
+<% content_for :action_title, t("dashboard.poster.index.title") %>
+
+
+
+
+
+ <%= image_tag proposal.image.attachment.url(:large), class: 'proposal-image' if proposal.image.present? %>
+ <%= image_tag 'default_mailing.jpg', class: 'proposal-image' unless proposal.image.present? %>
+
+
+
<%= t("dashboard.poster.index.h3") %>
+
+
"<%= proposal.title %>"
+
+
+
+
+ <%= render 'options' %>
+
+
diff --git a/app/views/dashboard/poster/index.pdf.erb b/app/views/dashboard/poster/index.pdf.erb
new file mode 100644
index 000000000..30d3633bb
--- /dev/null
+++ b/app/views/dashboard/poster/index.pdf.erb
@@ -0,0 +1,32 @@
+
+
+
+
+
+ <%= wicked_pdf_stylesheet_link_tag 'application' -%>
+ <%= wicked_pdf_stylesheet_link_tag 'pdf_fonts' -%>
+
+
+
+
+
+
+
+ <%= wicked_pdf_image_tag proposal.image.attachment.url(:large), class: 'proposal-image' if proposal.image.present? %>
+ <%= wicked_pdf_image_tag 'default_mailing.jpg', class: 'proposal-image' unless proposal.image.present? %>
+
+
+
<%= t("dashboard.poster.index.h3") %>
+
+
"<%= proposal.title %>"
+
+
+
+
+
+
diff --git a/app/views/dashboard/poster/new.html.erb b/app/views/dashboard/poster/new.html.erb
new file mode 100644
index 000000000..d1d28ba31
--- /dev/null
+++ b/app/views/dashboard/poster/new.html.erb
@@ -0,0 +1,8 @@
+<% content_for :action_title, t("dashboard.poster.new.title") %>
+
+
+ <%== Setting['proposals.poster_description'] %>
+
+
+ <%= render 'options' %>
+
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 556384c00..03469442d 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -16,7 +16,9 @@ Rails.application.config.assets.precompile += %w( dashboard_graphs.js )
Rails.application.config.assets.precompile += %w( print.css )
Rails.application.config.assets.precompile += %w( ie.css )
Rails.application.config.assets.precompile += %w( dashboard_mailer.css )
+Rails.application.config.assets.precompile += %w( pdf_fonts.css )
# Loads app/assets/images/custom before app/assets/images
images_path = Rails.application.config.assets.paths
images_path = images_path.insert(0, Rails.root.join("app", "assets", "images", "custom").to_s)
+
diff --git a/config/initializers/wicked_pdf.rb b/config/initializers/wicked_pdf.rb
new file mode 100644
index 000000000..824095dc3
--- /dev/null
+++ b/config/initializers/wicked_pdf.rb
@@ -0,0 +1,21 @@
+# WickedPDF Global Configuration
+#
+# Use this to set up shared configuration options for your entire application.
+# Any of the configuration options shown here can also be applied to single
+# models by passing arguments to the `render :pdf` call.
+#
+# To learn more, check out the README:
+#
+# https://github.com/mileszs/wicked_pdf/blob/master/README.md
+
+WickedPdf.config = {
+ # Path to the wkhtmltopdf executable: This usually isn't needed if using
+ # one of the wkhtmltopdf-binary family of gems.
+ # exe_path: '/usr/local/bin/wkhtmltopdf',
+ # or
+ # exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')
+
+ # Layout file to be used for all PDFs
+ # (but can be overridden in `render :pdf` calls)
+ # layout: 'pdf.html',
+}
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index f8558489c..6eff2e122 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -511,6 +511,7 @@ en:
community: Community
polls: Polls
mailing: E-mail
+ poster: Poster
form:
request: Request
create_request:
@@ -587,6 +588,22 @@ en:
add_answer: Add answer
question_answer_fields:
remove_answer: Remove answer
+ poster:
+ index:
+ title: Poster preview
+ h1: Do not keep looking,
+ h2: back me up! ;)
+ intro_text:
+ I am participating in Decide Madrid with my own citizen proposal and only if you also add you can I achieve the
+ necessary support to make Madrid the city we all want.
+ proposal_code: "Code of the proposal: %{code}"
+ h3: Support my proposal
+ footer: Visit decide.madrid.es and support this proposal. We need to be many. Decide your too. Thank you!
+ new:
+ title: Poster feature
+ options:
+ preview: Preview
+ download: Download
mailing:
index:
title: E-mail preview
diff --git a/config/locales/en/settings.yml b/config/locales/en/settings.yml
index efbdd6021..76ed6652a 100644
--- a/config/locales/en/settings.yml
+++ b/config/locales/en/settings.yml
@@ -70,3 +70,5 @@ en:
poll_link: Additional information link
email_short_title: Subtitle for email feature
email_description: Description for email feature
+ poster_short_title: Subtitle for poster feature
+ poster_description: Description for poster feature
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 717e6bdc0..c795903fb 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -511,6 +511,7 @@ es:
community: Comunidad
polls: Encuestas
mailing: Correo electrónico
+ poster: Póster
form:
request: Solicitar
create_request:
@@ -587,6 +588,22 @@ es:
add_answer: Añadir respuesta
question_answer_fields:
remove_answer: Borrar respuesta
+ poster:
+ index:
+ title: Previsualización del poster
+ h1: No te quedes mirando,
+ h2: ¡apóyame! ;)
+ intro_text:
+ Estoy participando en Decide Madrid con mi propia propuesta ciudadana y sólo si tú también te sumas podré lograr el
+ apoyo necesario para hacer de madrid la ciudad que todos queremos.
+ proposal_code: "Código de la propuesta: %{code}"
+ h3: Apoya mi propuesta
+ footer: Entra en decide.madrid.es y apoya esta propuesta. Necesitamos ser muchos. Decide tu también. ¡Gracias!
+ new:
+ title: Funcionalidad de póster
+ options:
+ preview: Previsualizar
+ download: Descargar
mailing:
index:
title: Previsualización del correo electrónico
diff --git a/config/locales/es/settings.yml b/config/locales/es/settings.yml
index 8bdf33f08..b51f5efdc 100644
--- a/config/locales/es/settings.yml
+++ b/config/locales/es/settings.yml
@@ -70,3 +70,5 @@ es:
poll_link: Enlace información adicional
email_short_title: Subtítulo funcionalidad de correo electrónico
email_description: Descripción funcionalidad de correo electrónico
+ poster_short_title: Subtítulo funcionalidad póster
+ poster_description: Descripción funcionalidad póster
diff --git a/config/routes/proposal.rb b/config/routes/proposal.rb
index 701aed1cd..9c3655515 100644
--- a/config/routes/proposal.rb
+++ b/config/routes/proposal.rb
@@ -20,6 +20,7 @@ resources :proposals do
resources :supports, only: [:index]
resources :polls, except: [:show, :destroy]
resources :mailing, only: [:index, :new, :create]
+ resources :poster, only: [:index, :new]
end
member do
diff --git a/db/seeds.rb b/db/seeds.rb
index 1c8c19ed5..94c48ec7f 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -139,3 +139,5 @@ Setting['proposals.poll_description'] = nil
Setting['proposals.poll_link'] = nil
Setting['proposals.email_short_title'] = nil
Setting['proposals.email_description'] = nil
+Setting['proposals.poster_short_title'] = nil
+Setting['proposals.poster_description'] = nil
diff --git a/lib/tasks/proposal_actions.rake b/lib/tasks/proposal_actions.rake
index 7dcf9a6cf..5104cf501 100644
--- a/lib/tasks/proposal_actions.rake
+++ b/lib/tasks/proposal_actions.rake
@@ -22,6 +22,8 @@ namespace :proposal_actions do
proposals.poll_link
proposals.email_short_title
proposals.email_description
+ proposals.poster_short_title
+ proposals.poster_description
].each do |key|
Setting[key] = nil if Setting.find_by(key: key).nil?
end
diff --git a/spec/features/dashboard/dashboard_spec.rb b/spec/features/dashboard/dashboard_spec.rb
index 2afe1f2d5..269eb567a 100644
--- a/spec/features/dashboard/dashboard_spec.rb
+++ b/spec/features/dashboard/dashboard_spec.rb
@@ -73,6 +73,7 @@ feature "Proposal's dashboard" do
within 'div#available-resources-section' do
expect(page).to have_content('Polls')
expect(page).to have_content('E-mail')
+ expect(page).to have_content('Poster')
expect(page).to have_content(available.title)
expect(page).to have_content(unavailable.title)
expect(page).to have_content(requested.title)
@@ -104,6 +105,10 @@ feature "Proposal's dashboard" do
expect(page).to have_link('E-mail')
end
+ scenario 'Dashboard has a link to poster feature' do
+ expect(page).to have_link('Poster')
+ end
+
scenario 'Dashboard has a link to resources on main menu' do
feature = create(:dashboard_action, :resource, :active)
diff --git a/spec/features/dashboard/poster_spec.rb b/spec/features/dashboard/poster_spec.rb
new file mode 100644
index 000000000..b245dead3
--- /dev/null
+++ b/spec/features/dashboard/poster_spec.rb
@@ -0,0 +1,33 @@
+require 'rails_helper'
+
+feature 'Poster' do
+ let!(:proposal) { create(:proposal, :draft) }
+
+ before do
+ login_as(proposal.author)
+ visit new_proposal_dashboard_poster_path(proposal)
+ end
+
+ scenario 'Has a link to preview the poster' do
+ expect(page).to have_link('Preview')
+ end
+
+ scenario 'Has a link to download the poster' do
+ expect(page).to have_link('Download')
+ end
+
+ scenario 'Preview contains the proposal details' do
+ click_link 'Preview'
+
+ expect(page).to have_content(proposal.title)
+ expect(page).to have_content(proposal.code)
+ end
+
+ scenario 'Preview page can download the poster as well' do
+ click_link 'Preview'
+
+ expect(page).not_to have_link('Preview')
+ expect(page).to have_link('Download')
+ end
+end
+
diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb
index 09ca0ccd8..7a19c7d96 100644
--- a/spec/models/abilities/common_spec.rb
+++ b/spec/models/abilities/common_spec.rb
@@ -180,6 +180,11 @@ describe Abilities::Common do
it { should_not be_able_to(:manage_mailing, proposal) }
end
+ describe 'proposal poster' do
+ it { should be_able_to(:manage_poster, own_proposal) }
+ it { should_not be_able_to(:manage_poster, proposal) }
+ end
+
describe 'publishing proposals' do
let(:draft_own_proposal) { create(:proposal, :draft, author: user) }