diff --git a/Gemfile b/Gemfile index 9d7499d82..7f0dcd0af 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,9 @@ gem 'jquery-ui-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' +# Fix sprockets on the +gem 'sprockets', '~> 3.6.3' + gem 'devise', '~> 3.5.7' gem 'devise_security_extension' # Use ActiveModel has_secure_password @@ -39,7 +42,7 @@ gem 'ckeditor', '~> 4.2.0' gem 'invisible_captcha', '~> 0.9.1' gem 'cancancan' gem 'social-share-button' -gem 'initialjs-rails', '0.2.0.1' +gem 'initialjs-rails', '0.2.0.4' gem 'unicorn', '~> 5.1.0' gem 'paranoia' gem 'rinku', require: 'rails_rinku' diff --git a/Gemfile.lock b/Gemfile.lock index e918a9648..619bc98e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,8 +199,8 @@ GEM parser (>= 2.2.3.0) term-ansicolor (>= 1.3.2) terminal-table (>= 1.5.1) - initialjs-rails (0.2.0.1) - railties (>= 3.1, < 5.0) + initialjs-rails (0.2.0.4) + railties (>= 3.1, < 6.0) invisible_captcha (0.9.1) rails jquery-rails (4.1.1) @@ -378,7 +378,7 @@ GEM spring (1.7.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.7.0) + sprockets (3.6.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-es6 (0.9.0) @@ -472,7 +472,7 @@ DEPENDENCIES fuubar groupdate i18n-tasks - initialjs-rails (= 0.2.0.1) + initialjs-rails (= 0.2.0.4) invisible_captcha (~> 0.9.1) jquery-rails jquery-ui-rails @@ -500,6 +500,7 @@ DEPENDENCIES social-share-button spring spring-commands-rspec + sprockets (~> 3.6.3) tolk turbolinks turnout diff --git a/README.md b/README.md index 27162bfd7..2690b84a7 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ Frontend tools used include [SCSS](http://sass-lang.com/) over [Foundation](http ## Configuration for development and test environments +**NOTE**: For more detailed instructions check the [docs](https://github.com/consul/consul/tree/master/doc/en/dev_test_setup.md) + Prerequisites: install git, Ruby 2.2.3, bundler gem, ghostscript and PostgreSQL (>=9.4). ``` diff --git a/README_ES.md b/README_ES.md index d8c394680..6051f1343 100644 --- a/README_ES.md +++ b/README_ES.md @@ -23,6 +23,8 @@ Las herramientas utilizadas para el frontend no están cerradas aún. Los estilo ## Configuración para desarrollo y tests +**NOTA**: para unas instrucciones más detalladas consulta la [documentación](https://github.com/consul/consul/tree/master/doc/es/dev_test_setup.md) + Prerequisitos: tener instalado git, Ruby 2.2.3, la gema `bundler`, ghostscript y PostgreSQL (9.4 o superior). ``` diff --git a/app/assets/fonts/icons.eot b/app/assets/fonts/icons.eot index f1420b532..c3c5d6289 100644 Binary files a/app/assets/fonts/icons.eot and b/app/assets/fonts/icons.eot differ diff --git a/app/assets/fonts/icons.svg b/app/assets/fonts/icons.svg index a7f352c4f..a548d9575 100644 --- a/app/assets/fonts/icons.svg +++ b/app/assets/fonts/icons.svg @@ -54,4 +54,8 @@ + + + + diff --git a/app/assets/fonts/icons.ttf b/app/assets/fonts/icons.ttf index 16401c79b..6f938f863 100644 Binary files a/app/assets/fonts/icons.ttf and b/app/assets/fonts/icons.ttf differ diff --git a/app/assets/fonts/icons.woff b/app/assets/fonts/icons.woff index 83689755d..f3c31e804 100644 Binary files a/app/assets/fonts/icons.woff and b/app/assets/fonts/icons.woff differ diff --git a/app/assets/images/ballot.gif b/app/assets/images/ballot.gif new file mode 100644 index 000000000..18cf0717f Binary files /dev/null and b/app/assets/images/ballot.gif differ diff --git a/app/assets/images/ballot_tiny.gif b/app/assets/images/ballot_tiny.gif new file mode 100644 index 000000000..976d37591 Binary files /dev/null and b/app/assets/images/ballot_tiny.gif differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index ca79ceb8b..7fb92b5e3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,7 +16,7 @@ //= require jquery-ui/datepicker-es //= require foundation //= require turbolinks -//= require ckeditor/init +//= require ckeditor/loader //= require_directory ./ckeditor //= require social-share-button //= require initial diff --git a/app/assets/javascripts/ckeditor/loader.js.erb b/app/assets/javascripts/ckeditor/loader.js.erb new file mode 100644 index 000000000..66e1d8347 --- /dev/null +++ b/app/assets/javascripts/ckeditor/loader.js.erb @@ -0,0 +1,3 @@ +//= require ckeditor/init + +CKEDITOR.config.customConfig = '<%= javascript_path 'ckeditor/config.js' %>'; diff --git a/app/assets/stylesheets/icons.scss b/app/assets/stylesheets/icons.scss index a92a3b61a..a4b0da4f7 100644 --- a/app/assets/stylesheets/icons.scss +++ b/app/assets/stylesheets/icons.scss @@ -172,3 +172,6 @@ .icon-arrow-right:before { content: "\55"; } +.icon-checkmark-circle:before { + content: "\59"; +} diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index ffe08617f..efd385c19 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -5,6 +5,7 @@ // 03. Show participation // 04. List participation // 05. Featured +// 06. Proposals successfull // // 01. Votes and supports @@ -269,6 +270,21 @@ } } +.message { + @include supports; + background: none; + border-top: 0; + + @include breakpoint(medium) { + border-left: 1px solid $border; + margin: $line-height rem-calc(-25) 0 rem-calc(12); + } + + p { + font-size: $small-font-size; + } +} + // 02. New participation // --------------------- @@ -548,14 +564,14 @@ .debates-list, .proposals-list, .investment-projects-list { - @include breakpoint(small) { + @include breakpoint(medium) { margin-bottom: rem-calc(48); } } .investment-projects-list { - @include breakpoint(small) { + @include breakpoint(medium) { min-height: $line-height*15; } } @@ -574,7 +590,7 @@ min-height: rem-calc(192); padding: rem-calc(12) rem-calc(12) 0 rem-calc(12); - @include breakpoint(small) { + @include breakpoint(medium) { margin-bottom: rem-calc(-1); padding-bottom: rem-calc(12); } @@ -732,7 +748,7 @@ border: 1px solid $votes-border; margin: 0 rem-calc(-12); - @include breakpoint(small) { + @include breakpoint(medium) { border-top-left-radius: 3px; border-bottom-left-radius: 3px; margin: 0 rem-calc(-25) 0 rem-calc(12); @@ -750,7 +766,7 @@ right: -1px; border-width: 13px 13px 0 0; - @include breakpoint(small) { + @include breakpoint(medium) { content: ""; } } @@ -762,7 +778,7 @@ padding-top: rem-calc(12); vertical-align: top; - @include breakpoint(small) { + @include breakpoint(medium) { display: block; float: none; line-height: $line-height*2; @@ -771,7 +787,7 @@ } } - @include breakpoint(small) { + @include breakpoint(medium) { .like, .unlike { span.percentage { @@ -790,7 +806,7 @@ border: 1px solid $proposals-border; margin: 0 rem-calc(-12); - @include breakpoint(small) { + @include breakpoint(medium) { border-top-left-radius: 3px; border-bottom-left-radius: 3px; margin: 0 rem-calc(-25) 0 rem-calc(12); @@ -808,7 +824,7 @@ right: -1px; border-width: 13px 13px 0 0; - @include breakpoint(small) { + @include breakpoint(medium) { content: ""; } } @@ -819,7 +835,7 @@ padding-top: rem-calc(12); vertical-align: top; - @include breakpoint(small) { + @include breakpoint(medium) { display: block; float: none; margin-left: 0; @@ -840,7 +856,7 @@ min-height: rem-calc(180); padding-top: 0; - @include breakpoint(small) { + @include breakpoint(medium) { padding-top: $line-height*1.5; } @@ -929,7 +945,8 @@ // 05. Featured // ------------ -.featured-debates, .featured-proposals { +.featured-debates, .featured-proposals, +.proposals-ballot, .proposals-ballot-list { padding: $line-height/2 0; @include breakpoint(medium) { @@ -1029,3 +1046,112 @@ } } } + +// 06. Proposals successfull +// ------------------------- + +.dark-heading { + background: #2D3E50; + color: white; + + @include breakpoint(medium) { + padding-bottom: $line-height; + } + + p { + margin-bottom: 0; + + &.title { + color: #FFD200; + } + } + + .info { + background: #314253; + padding-top: $line-height; + + @include breakpoint(medium) { + border-top: rem-calc(6) solid #FFD200; + } + } +} + +.featured-proposals-ballot-banner { + background: #2D3E50 image-url("ballot_tiny.gif") no-repeat; + background-position: 75% 0; + position: relative; + + h2, a:hover h2 { + color: #FFD200 !important; + } + + p { + color: white; + } + + @include breakpoint(medium) { + margin-left: 0 !important; + margin-right: 0 !important; + } + + @include breakpoint(large) { + background: #2D3E50 image-url("ballot.gif") no-repeat; + background-position: 90% 0; + } +} + +.featured-proposals-ballot-banner, +.successfull .panel { + + .icon-successfull { + border-right: 60px solid #FFD200; + border-top: 0; + border-bottom: 60px solid transparent; + height: 0; + position: absolute; + right: 0; + top: 0; + width: 0; + + &:after { + color: #1B254C; + content: "\59"; + font-family: "icons" !important; + left: 34px; + position: absolute; + top: 5px; + } + } +} + +.proposals-ballot-list { + + .proposal-sucessfull { + background: white; + border-top: 1px solid $border; + padding: $line-height 0; + position: relative; + } +} + +.successfull { + + .panel { + position: relative; + } + + .truncate { + display: none; + } + + .message { + @include supports; + background: none; + border-top: 0; + + @include breakpoint(medium) { + border-left: 1px solid $border; + margin: $line-height rem-calc(-25) 0 rem-calc(12); + } + } +} diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 3a79238ea..3f4398797 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -12,7 +12,7 @@ module CommentableActions @tag_cloud = tag_cloud @banners = Banner.with_active - + set_resource_votes(@resources) set_resources_instance end diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index e077e5e8a..7d2149cad 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -22,6 +22,7 @@ class DebatesController < ApplicationController def index_customization @featured_debates = @debates.featured + @proposal_successfull_exists = Proposal.successfull.exists? end def show diff --git a/app/controllers/proposal_ballots_controller.rb b/app/controllers/proposal_ballots_controller.rb new file mode 100644 index 000000000..4e3e99671 --- /dev/null +++ b/app/controllers/proposal_ballots_controller.rb @@ -0,0 +1,8 @@ +class ProposalBallotsController < ApplicationController + skip_authorization_check + + def index + @proposal_ballots = Proposal.successfull.sort_by_confidence_score + end + +end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 578395ab3..ede5b0f5d 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -12,7 +12,7 @@ class ProposalsController < ApplicationController invisible_captcha only: [:create, :update], honeypot: :subtitle - has_orders %w{hot_score confidence_score created_at relevance}, only: :index + has_orders %w{hot_score confidence_score created_at relevance archival_date}, only: :index has_orders %w{most_voted newest oldest}, only: :show load_and_authorize_resource @@ -26,8 +26,10 @@ class ProposalsController < ApplicationController end def index_customization + discard_archived load_retired - load_featured + load_proposal_ballots + load_featured unless @proposal_successfull_exists end def vote @@ -80,6 +82,10 @@ class ProposalsController < ApplicationController @featured_proposals_votes = current_user ? current_user.proposal_votes(proposals) : {} end + def discard_archived + @resources = @resources.not_archived unless @current_order == "archival_date" + end + def load_retired if params[:retired].present? @resources = @resources.retired @@ -90,11 +96,15 @@ class ProposalsController < ApplicationController end def load_featured - @featured_proposals = Proposal.all.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?) + @featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?) if @featured_proposals.present? set_featured_proposal_votes(@featured_proposals) @resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id)) end end + def load_proposal_ballots + @proposal_successfull_exists = Proposal.successfull.exists? + end + end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 9a92a8d18..7bd4b7a92 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -44,9 +44,13 @@ class Proposal < ActiveRecord::Base scope :sort_by_random, -> { reorder("RANDOM()") } scope :sort_by_relevance, -> { all } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } + scope :sort_by_archival_date, -> { archived.sort_by_confidence_score } + scope :archived, -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago)} + scope :not_archived, -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago)} scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :retired, -> { where.not(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) } + scope :successfull, -> { where("cached_votes_up + physical_votes >= ?", Proposal.votes_needed_for_success)} def to_param "#{id}-#{title}".parameterize @@ -119,7 +123,7 @@ class Proposal < ActiveRecord::Base end def register_vote(user, vote_value) - if votable_by?(user) + if votable_by?(user) && !archived? vote_by(voter: user, vote: vote_value) end end @@ -155,6 +159,14 @@ class Proposal < ActiveRecord::Base Setting['votes_for_proposal_success'].to_i end + def successfull? + total_votes >= Proposal.votes_needed_for_success + end + + def archived? + self.created_at <= Setting["months_to_archive_proposals"].to_i.months.ago + end + def notifications proposal_notifications end diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index 6809782b1..22d628c65 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -29,7 +29,11 @@ <%= render "shared/banner" %> <% end %> - <% unless @tag_filter || @search_terms || !has_featured? %> + <% if @proposal_successfull_exists %> + <%= render "proposals/proposal_ballots_banner" %> + <% end %> + + <% unless @tag_filter || @search_terms || !has_featured? || @proposal_ballots.present? || @proposal_successfull_exists %> <%= render "featured_debates" %> <% end %> diff --git a/app/views/proposal_ballots/_successfull_proposal.html.erb b/app/views/proposal_ballots/_successfull_proposal.html.erb new file mode 100644 index 000000000..870e61605 --- /dev/null +++ b/app/views/proposal_ballots/_successfull_proposal.html.erb @@ -0,0 +1,13 @@ +
+

<%= link_to proposal.title, proposal %>

+
+ <% if proposal.author.hidden? || proposal.author.erased? %> + <%= t("proposals.show.author_deleted") %> + <% else %> + <%= proposal.author.name %> + <% end %> + +  •  + <%= l proposal.created_at.to_date %> +
+
diff --git a/app/views/proposal_ballots/index.html.erb b/app/views/proposal_ballots/index.html.erb new file mode 100644 index 000000000..00a07fb9e --- /dev/null +++ b/app/views/proposal_ballots/index.html.erb @@ -0,0 +1,35 @@ +
+
+
+

+ <%= t("proposal_ballots.title") %> +

+

+ <%= t("proposal_ballots.description_html").html_safe %> +

+
+ +
+

<%= t("proposal_ballots.date_title") %>

+

<%= t("proposal_ballots.date") %>

+
+
+
+ +
+
+
+ <% if @proposal_ballots.present? %> +
+ <% @proposal_ballots.each do |proposal_for_vote| %> + <%= render "successfull_proposal", proposal: proposal_for_vote %> + <% end %> +
+ <% else %> +

+ <%= t("proposal_ballots.nothing_to_vote") %> +

+ <% end %> +
+
+
diff --git a/app/views/proposals/_featured_proposal.html.erb b/app/views/proposals/_featured_proposal.html.erb index 623932c38..5500b2418 100644 --- a/app/views/proposals/_featured_proposal.html.erb +++ b/app/views/proposals/_featured_proposal.html.erb @@ -7,7 +7,16 @@ <% else %> <%= proposal.author.name %> <% end %> +  •  + + <% if proposal.author.display_official_position_badge? %> + + <%= proposal.author.official_position %> + +  •  + <% end %> + <%= t("proposals.proposal.supports", count: proposal.total_votes) %> diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 70c2b9c89..2c7bb272a 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -1,10 +1,12 @@ -
+
Proposal.votes_needed_for_success) %>" + data-type="proposal">
+
- <% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %> <%= t("proposals.proposal.proposal") %> @@ -50,11 +52,26 @@
-
- <%= render 'votes', - { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% if proposal.successfull? %> +
+

+ <%= t("proposal_ballots.successfull", + voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %> +

+
+ <% elsif proposal.archived? %> +
+ <%= t("proposals.proposal.supports", count: proposal.total_votes) %> +

<%= t("proposals.proposal.archived") %>

+
+ <% else %> +
+ <%= render 'votes', + { proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %> +
+ <% end %>
-
diff --git a/app/views/proposals/_proposal_ballots_banner.html.erb b/app/views/proposals/_proposal_ballots_banner.html.erb new file mode 100644 index 000000000..df210a535 --- /dev/null +++ b/app/views/proposals/_proposal_ballots_banner.html.erb @@ -0,0 +1,9 @@ + diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 6f6516890..5efa3e24c 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -30,8 +30,10 @@ <% if has_banners %> <%= render "shared/banner" %> <% end %> - - <% if @featured_proposals.present? %> + + <% if @proposal_successfull_exists %> + <%= render "proposal_ballots_banner" %> + <% elsif @featured_proposals.present? %>
diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 3a9869d83..5cb7867af 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -102,11 +102,23 @@