2
Gemfile
2
Gemfile
@@ -56,6 +56,8 @@ gem 'unicorn', '~> 5.4.0'
|
|||||||
gem 'whenever', '~> 0.10.0', require: false
|
gem 'whenever', '~> 0.10.0', require: false
|
||||||
gem 'globalize', '~> 5.0.0'
|
gem 'globalize', '~> 5.0.0'
|
||||||
gem 'globalize-accessors', '~> 0.2.1'
|
gem 'globalize-accessors', '~> 0.2.1'
|
||||||
|
gem 'wkhtmltopdf-binary', '~> 0.12.4'
|
||||||
|
gem 'wicked_pdf', '~> 1.1.0'
|
||||||
|
|
||||||
source 'https://rails-assets.org' do
|
source 'https://rails-assets.org' do
|
||||||
gem 'rails-assets-leaflet'
|
gem 'rails-assets-leaflet'
|
||||||
|
|||||||
@@ -495,6 +495,8 @@ GEM
|
|||||||
railties (>= 4.2)
|
railties (>= 4.2)
|
||||||
whenever (0.10.0)
|
whenever (0.10.0)
|
||||||
chronic (>= 0.6.3)
|
chronic (>= 0.6.3)
|
||||||
|
wicked_pdf (1.1.0)
|
||||||
|
wkhtmltopdf-binary (0.12.4)
|
||||||
xpath (3.0.0)
|
xpath (3.0.0)
|
||||||
nokogiri (~> 1.8)
|
nokogiri (~> 1.8)
|
||||||
|
|
||||||
@@ -586,6 +588,8 @@ DEPENDENCIES
|
|||||||
unicorn (~> 5.4.0)
|
unicorn (~> 5.4.0)
|
||||||
web-console (~> 3.3.0)
|
web-console (~> 3.3.0)
|
||||||
whenever (~> 0.10.0)
|
whenever (~> 0.10.0)
|
||||||
|
wicked_pdf (~> 1.1.0)
|
||||||
|
wkhtmltopdf-binary (~> 0.12.4)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.2
|
1.16.2
|
||||||
|
|||||||
BIN
app/assets/images/default_poster.jpg
Normal file
BIN
app/assets/images/default_poster.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 209 KiB |
@@ -11,6 +11,7 @@
|
|||||||
@import 'proposal';
|
@import 'proposal';
|
||||||
@import 'proposal-graph';
|
@import 'proposal-graph';
|
||||||
@import 'dashboard_mailer_preview';
|
@import 'dashboard_mailer_preview';
|
||||||
|
@import 'dashboard_poster_preview';
|
||||||
@import 'poll';
|
@import 'poll';
|
||||||
@import 'legislation';
|
@import 'legislation';
|
||||||
@import 'legislation_process';
|
@import 'legislation_process';
|
||||||
|
|||||||
81
app/assets/stylesheets/dashboard_poster_preview.scss
Normal file
81
app/assets/stylesheets/dashboard_poster_preview.scss
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
64
app/assets/stylesheets/pdf_fonts.scss.erb
Normal file
64
app/assets/stylesheets/pdf_fonts.scss.erb
Normal file
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
class Admin::SettingsController < Admin::BaseController
|
class Admin::SettingsController < Admin::BaseController
|
||||||
|
include Admin::ManagesProposalSettings
|
||||||
|
|
||||||
helper_method :successful_proposal_setting, :successful_proposals, :poll_feature_short_title_setting, :poll_feature_description_setting,
|
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
|
def index
|
||||||
all_settings = Setting.all.group_by { |s| s.type }
|
all_settings = Setting.all.group_by { |s| s.type }
|
||||||
@@ -28,32 +31,4 @@ class Admin::SettingsController < Admin::BaseController
|
|||||||
def settings_params
|
def settings_params
|
||||||
params.require(:setting).permit(:value)
|
params.require(:setting).permit(:value)
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
41
app/controllers/concerns/admin/manages_proposal_settings.rb
Normal file
41
app/controllers/concerns/admin/manages_proposal_settings.rb
Normal file
@@ -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
|
||||||
16
app/controllers/dashboard/poster_controller.rb
Normal file
16
app/controllers/dashboard/poster_controller.rb
Normal file
@@ -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
|
||||||
@@ -60,4 +60,11 @@ module ApplicationHelper
|
|||||||
def kaminari_path(url)
|
def kaminari_path(url)
|
||||||
"#{root_url.chomp("\/")}#{url}"
|
"#{root_url.chomp("\/")}#{url}"
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -30,14 +30,22 @@ module ProposalsDashboardHelper
|
|||||||
menu_entry(polls_menu_active?, &block)
|
menu_entry(polls_menu_active?, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def poster_menu(&block)
|
||||||
|
menu_entry(poster_menu_active?, &block)
|
||||||
|
end
|
||||||
|
|
||||||
def resources_menu_active?
|
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
|
end
|
||||||
|
|
||||||
def polls_menu_active?
|
def polls_menu_active?
|
||||||
controller_name == 'polls'
|
controller_name == 'polls'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def poster_menu_active?
|
||||||
|
controller_name == 'poster'
|
||||||
|
end
|
||||||
|
|
||||||
def mailing_menu(&block)
|
def mailing_menu(&block)
|
||||||
menu_entry(mailing_menu_active?, &block)
|
menu_entry(mailing_menu_active?, &block)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ module Abilities
|
|||||||
can :manage_mailing, Proposal do |proposal|
|
can :manage_mailing, Proposal do |proposal|
|
||||||
proposal.author.id == user.id
|
proposal.author.id == user.id
|
||||||
end
|
end
|
||||||
|
can :manage_poster, Proposal do |proposal|
|
||||||
|
proposal.author.id == user.id
|
||||||
|
end
|
||||||
|
|
||||||
can :results, Poll do |poll|
|
can :results, Poll do |poll|
|
||||||
poll.related&.author&.id == user.id
|
poll.related&.author&.id == user.id
|
||||||
|
|||||||
@@ -17,90 +17,15 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="small-12 medium-4">
|
<%= render 'setting_text_field', setting: poll_feature_short_title_setting %>
|
||||||
<strong><%= t("settings.#{poll_feature_short_title_setting.key}") %></strong>
|
<%= render 'setting_textarea_field', setting: poll_feature_description_setting %>
|
||||||
</td>
|
<%= render 'setting_text_field', setting: poll_feature_link_setting %>
|
||||||
<td class="small-12 medium-8">
|
|
||||||
<%= form_for poll_feature_short_title_setting,
|
<%= render 'setting_text_field', setting: email_feature_short_title_setting %>
|
||||||
url: admin_setting_path(poll_feature_short_title_setting),
|
<%= render 'setting_textarea_field', setting: email_feature_description_setting %>
|
||||||
html: { id: "edit_#{dom_id(poll_feature_short_title_setting)}"} do |f| %>
|
|
||||||
<div class="small-12 medium-6 large-9 column">
|
<%= render 'setting_text_field', setting: poster_feature_short_title_setting %>
|
||||||
<%= f.text_field :value, label: false, id: dom_id(poll_feature_short_title_setting) %>
|
<%= render 'setting_textarea_field', setting: poster_feature_description_setting %>
|
||||||
</div>
|
|
||||||
<div class="small-12 medium-6 large-3 column">
|
|
||||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="small-12 medium-4">
|
|
||||||
<strong><%= t("settings.#{poll_feature_description_setting.key}") %></strong>
|
|
||||||
</td>
|
|
||||||
<td class="small-12 medium-8">
|
|
||||||
<%= 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| %>
|
|
||||||
<div class="small-12 medium-6 large-9 column">
|
|
||||||
<%= f.cktext_area :value, label: false, id: dom_id(poll_feature_description_setting) %>
|
|
||||||
</div>
|
|
||||||
<div class="small-12 medium-6 large-3 column">
|
|
||||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="small-12 medium-4">
|
|
||||||
<strong><%= t("settings.#{poll_feature_link_setting.key}") %></strong>
|
|
||||||
</td>
|
|
||||||
<td class="small-12 medium-8">
|
|
||||||
<%= 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| %>
|
|
||||||
<div class="small-12 medium-6 large-9 column">
|
|
||||||
<%= f.text_field :value, label: false, id: dom_id(poll_feature_link_setting) %>
|
|
||||||
</div>
|
|
||||||
<div class="small-12 medium-6 large-3 column">
|
|
||||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="small-12 medium-4">
|
|
||||||
<strong><%= t("settings.#{email_feature_short_title_setting.key}") %></strong>
|
|
||||||
</td>
|
|
||||||
<td class="small-12 medium-8">
|
|
||||||
<%= 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| %>
|
|
||||||
<div class="small-12 medium-6 large-9 column">
|
|
||||||
<%= f.text_field :value, label: false, id: dom_id(email_feature_short_title_setting) %>
|
|
||||||
</div>
|
|
||||||
<div class="small-12 medium-6 large-3 column">
|
|
||||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="small-12 medium-4">
|
|
||||||
<strong><%= t("settings.#{email_feature_description_setting.key}") %></strong>
|
|
||||||
</td>
|
|
||||||
<td class="small-12 medium-8">
|
|
||||||
<%= 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| %>
|
|
||||||
<div class="small-12 medium-6 large-9 column">
|
|
||||||
<%= f.cktext_area :value, label: false, id: dom_id(email_feature_description_setting) %>
|
|
||||||
</div>
|
|
||||||
<div class="small-12 medium-6 large-3 column">
|
|
||||||
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
18
app/views/admin/settings/_setting_text_field.html.erb
Normal file
18
app/views/admin/settings/_setting_text_field.html.erb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<tr>
|
||||||
|
<td class="small-12 medium-4">
|
||||||
|
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||||
|
</td>
|
||||||
|
<td class="small-12 medium-8">
|
||||||
|
<%= form_for setting,
|
||||||
|
url: admin_setting_path(setting),
|
||||||
|
html: { id: "edit_#{dom_id(setting)}"} do |f| %>
|
||||||
|
<div class="small-12 medium-6 large-9 column">
|
||||||
|
<%= f.text_field :value, label: false, id: dom_id(setting) %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-6 large-3 column">
|
||||||
|
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
18
app/views/admin/settings/_setting_textarea_field.html.erb
Normal file
18
app/views/admin/settings/_setting_textarea_field.html.erb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<tr>
|
||||||
|
<td class="small-12 medium-4">
|
||||||
|
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||||
|
</td>
|
||||||
|
<td class="small-12 medium-8">
|
||||||
|
<%= form_for setting,
|
||||||
|
url: admin_setting_path(setting),
|
||||||
|
html: { id: "edit_#{dom_id(setting)}"} do |f| %>
|
||||||
|
<div class="small-12 medium-6 large-9 column">
|
||||||
|
<%= f.cktext_area :value, label: false, id: dom_id(setting) %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-6 large-3 column">
|
||||||
|
<%= f.submit(t('admin.settings.index.update_setting'), class: "button hollow expanded") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
@@ -42,6 +42,16 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if can?(:manage_poster, proposal) %>
|
||||||
|
<%= poster_menu do %>
|
||||||
|
<%= link_to new_proposal_dashboard_poster_path(proposal.to_param) do %>
|
||||||
|
<span data-tooltip title="<%= Setting['proposals.poster_short_title'] || t("dashboard.menu.poster") %>">
|
||||||
|
<%= t("dashboard.menu.poster") %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% resources.each do |resource| %>
|
<% resources.each do |resource| %>
|
||||||
<li <%= 'class=is-active' if is_request_active(resource.id) %>>
|
<li <%= 'class=is-active' if is_request_active(resource.id) %>>
|
||||||
<%= link_to new_request_proposal_dashboard_path(proposal, resource) do %>
|
<%= link_to new_request_proposal_dashboard_path(proposal, resource) do %>
|
||||||
|
|||||||
26
app/views/dashboard/_poster_resource.html.erb
Normal file
26
app/views/dashboard/_poster_resource.html.erb
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<% if can?(:manage_poster, proposal) %>
|
||||||
|
<div class="column">
|
||||||
|
<div class="card resource-card primary"
|
||||||
|
data-tooltip title="<%= t("dashboard.resource.request_resource") %>"
|
||||||
|
data-position="bottom" data-alignment="right">
|
||||||
|
<div class="card-section">
|
||||||
|
<p class="text-right">
|
||||||
|
<i class="fi-pencil resource-icon"></i>
|
||||||
|
</p>
|
||||||
|
<h4 class="text-center"><%= t("dashboard.menu.poster") %></h4>
|
||||||
|
<p class="text-center">
|
||||||
|
<%= Setting['proposals.poster_short_title'] %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-section text-center bottom-container">
|
||||||
|
<div class="bottom-element text-center">
|
||||||
|
<%= link_to t("dashboard.resource.request_resource"),
|
||||||
|
new_proposal_dashboard_poster_path(proposal.to_param),
|
||||||
|
class: 'button primary' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
<div class="row small-up-2 medium-up-3 large-up-4">
|
<div class="row small-up-2 medium-up-3 large-up-4">
|
||||||
<%= render 'poll_resource' %>
|
<%= render 'poll_resource' %>
|
||||||
<%= render 'mailing_resource' %>
|
<%= render 'mailing_resource' %>
|
||||||
|
<%= render 'poster_resource' %>
|
||||||
<%= render partial: 'resource', collection: active_resources %>
|
<%= render partial: 'resource', collection: active_resources %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
13
app/views/dashboard/poster/_options.html.erb
Normal file
13
app/views/dashboard/poster/_options.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<% 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' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
25
app/views/dashboard/poster/index.html.erb
Normal file
25
app/views/dashboard/poster/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<% content_for :action_title, t("dashboard.poster.index.title") %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-9 column dashboard-poster-preview">
|
||||||
|
<div class="header">
|
||||||
|
<h1><%= t("dashboard.poster.index.h1") %></h1>
|
||||||
|
<h2><%= t("dashboard.poster.index.h2") %></h2>
|
||||||
|
<p><%= t("dashboard.poster.index.intro_text") %></p>
|
||||||
|
<p class="image-caption"><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="proposal-image">
|
||||||
|
<%= 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? %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3><%= t("dashboard.poster.index.h3") %></h3>
|
||||||
|
|
||||||
|
<div class="proposal-title">"<%= proposal.title %>"</div>
|
||||||
|
|
||||||
|
<div class="poster-footer"><%= t("dashboard.poster.index.footer") %></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render 'options' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
32
app/views/dashboard/poster/index.pdf.erb
Normal file
32
app/views/dashboard/poster/index.pdf.erb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<%= wicked_pdf_stylesheet_link_tag 'application' -%>
|
||||||
|
<%= wicked_pdf_stylesheet_link_tag 'pdf_fonts' -%>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-9 column dashboard-poster-preview dashboard-poster-pdf">
|
||||||
|
<div class="header">
|
||||||
|
<h1><%= t("dashboard.poster.index.h1") %></h1>
|
||||||
|
<h2><%= t("dashboard.poster.index.h2") %></h2>
|
||||||
|
<p><%= t("dashboard.poster.index.intro_text") %></p>
|
||||||
|
<p class="image-caption"><%= t("dashboard.poster.index.proposal_code", code: proposal.code) %></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="proposal-image">
|
||||||
|
<%= 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? %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3><%= t("dashboard.poster.index.h3") %></h3>
|
||||||
|
|
||||||
|
<div class="proposal-title">"<%= proposal.title %>"</div>
|
||||||
|
|
||||||
|
<div class="poster-footer"><%= t("dashboard.poster.index.footer") %></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
8
app/views/dashboard/poster/new.html.erb
Normal file
8
app/views/dashboard/poster/new.html.erb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<% content_for :action_title, t("dashboard.poster.new.title") %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-9 column">
|
||||||
|
<%== Setting['proposals.poster_description'] %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render 'options' %>
|
||||||
|
</div>
|
||||||
@@ -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( print.css )
|
||||||
Rails.application.config.assets.precompile += %w( ie.css )
|
Rails.application.config.assets.precompile += %w( ie.css )
|
||||||
Rails.application.config.assets.precompile += %w( dashboard_mailer.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
|
# Loads app/assets/images/custom before app/assets/images
|
||||||
images_path = Rails.application.config.assets.paths
|
images_path = Rails.application.config.assets.paths
|
||||||
images_path = images_path.insert(0, Rails.root.join("app", "assets", "images", "custom").to_s)
|
images_path = images_path.insert(0, Rails.root.join("app", "assets", "images", "custom").to_s)
|
||||||
|
|
||||||
|
|||||||
21
config/initializers/wicked_pdf.rb
Normal file
21
config/initializers/wicked_pdf.rb
Normal file
@@ -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',
|
||||||
|
}
|
||||||
@@ -511,6 +511,7 @@ en:
|
|||||||
community: Community
|
community: Community
|
||||||
polls: Polls
|
polls: Polls
|
||||||
mailing: E-mail
|
mailing: E-mail
|
||||||
|
poster: Poster
|
||||||
form:
|
form:
|
||||||
request: Request
|
request: Request
|
||||||
create_request:
|
create_request:
|
||||||
@@ -587,6 +588,22 @@ en:
|
|||||||
add_answer: Add answer
|
add_answer: Add answer
|
||||||
question_answer_fields:
|
question_answer_fields:
|
||||||
remove_answer: Remove answer
|
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:
|
mailing:
|
||||||
index:
|
index:
|
||||||
title: E-mail preview
|
title: E-mail preview
|
||||||
|
|||||||
@@ -70,3 +70,5 @@ en:
|
|||||||
poll_link: Additional information link
|
poll_link: Additional information link
|
||||||
email_short_title: Subtitle for email feature
|
email_short_title: Subtitle for email feature
|
||||||
email_description: Description for email feature
|
email_description: Description for email feature
|
||||||
|
poster_short_title: Subtitle for poster feature
|
||||||
|
poster_description: Description for poster feature
|
||||||
|
|||||||
@@ -511,6 +511,7 @@ es:
|
|||||||
community: Comunidad
|
community: Comunidad
|
||||||
polls: Encuestas
|
polls: Encuestas
|
||||||
mailing: Correo electrónico
|
mailing: Correo electrónico
|
||||||
|
poster: Póster
|
||||||
form:
|
form:
|
||||||
request: Solicitar
|
request: Solicitar
|
||||||
create_request:
|
create_request:
|
||||||
@@ -587,6 +588,22 @@ es:
|
|||||||
add_answer: Añadir respuesta
|
add_answer: Añadir respuesta
|
||||||
question_answer_fields:
|
question_answer_fields:
|
||||||
remove_answer: Borrar respuesta
|
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:
|
mailing:
|
||||||
index:
|
index:
|
||||||
title: Previsualización del correo electrónico
|
title: Previsualización del correo electrónico
|
||||||
|
|||||||
@@ -70,3 +70,5 @@ es:
|
|||||||
poll_link: Enlace información adicional
|
poll_link: Enlace información adicional
|
||||||
email_short_title: Subtítulo funcionalidad de correo electrónico
|
email_short_title: Subtítulo funcionalidad de correo electrónico
|
||||||
email_description: Descripción 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
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ resources :proposals do
|
|||||||
resources :supports, only: [:index]
|
resources :supports, only: [:index]
|
||||||
resources :polls, except: [:show, :destroy]
|
resources :polls, except: [:show, :destroy]
|
||||||
resources :mailing, only: [:index, :new, :create]
|
resources :mailing, only: [:index, :new, :create]
|
||||||
|
resources :poster, only: [:index, :new]
|
||||||
end
|
end
|
||||||
|
|
||||||
member do
|
member do
|
||||||
|
|||||||
@@ -139,3 +139,5 @@ Setting['proposals.poll_description'] = nil
|
|||||||
Setting['proposals.poll_link'] = nil
|
Setting['proposals.poll_link'] = nil
|
||||||
Setting['proposals.email_short_title'] = nil
|
Setting['proposals.email_short_title'] = nil
|
||||||
Setting['proposals.email_description'] = nil
|
Setting['proposals.email_description'] = nil
|
||||||
|
Setting['proposals.poster_short_title'] = nil
|
||||||
|
Setting['proposals.poster_description'] = nil
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace :proposal_actions do
|
|||||||
proposals.poll_link
|
proposals.poll_link
|
||||||
proposals.email_short_title
|
proposals.email_short_title
|
||||||
proposals.email_description
|
proposals.email_description
|
||||||
|
proposals.poster_short_title
|
||||||
|
proposals.poster_description
|
||||||
].each do |key|
|
].each do |key|
|
||||||
Setting[key] = nil if Setting.find_by(key: key).nil?
|
Setting[key] = nil if Setting.find_by(key: key).nil?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ feature "Proposal's dashboard" do
|
|||||||
within 'div#available-resources-section' do
|
within 'div#available-resources-section' do
|
||||||
expect(page).to have_content('Polls')
|
expect(page).to have_content('Polls')
|
||||||
expect(page).to have_content('E-mail')
|
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(available.title)
|
||||||
expect(page).to have_content(unavailable.title)
|
expect(page).to have_content(unavailable.title)
|
||||||
expect(page).to have_content(requested.title)
|
expect(page).to have_content(requested.title)
|
||||||
@@ -104,6 +105,10 @@ feature "Proposal's dashboard" do
|
|||||||
expect(page).to have_link('E-mail')
|
expect(page).to have_link('E-mail')
|
||||||
end
|
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
|
scenario 'Dashboard has a link to resources on main menu' do
|
||||||
feature = create(:dashboard_action, :resource, :active)
|
feature = create(:dashboard_action, :resource, :active)
|
||||||
|
|
||||||
|
|||||||
33
spec/features/dashboard/poster_spec.rb
Normal file
33
spec/features/dashboard/poster_spec.rb
Normal file
@@ -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
|
||||||
|
|
||||||
@@ -180,6 +180,11 @@ describe Abilities::Common do
|
|||||||
it { should_not be_able_to(:manage_mailing, proposal) }
|
it { should_not be_able_to(:manage_mailing, proposal) }
|
||||||
end
|
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
|
describe 'publishing proposals' do
|
||||||
let(:draft_own_proposal) { create(:proposal, :draft, author: user) }
|
let(:draft_own_proposal) { create(:proposal, :draft, author: user) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user