Merge branch 'master' into polling-views-plus

This commit is contained in:
Juanjo Bazán
2016-10-19 13:50:08 +02:00
68 changed files with 1063 additions and 136 deletions

Binary file not shown.

View File

@@ -54,4 +54,8 @@
<glyph glyph-name="arrow-down" unicode="&#82;" d="M402 311c0-5-2-9-5-13l-128-128c-4-4-8-5-13-5-5 0-9 1-13 5l-128 128c-3 4-5 8-5 13 0 5 2 9 5 13 4 3 8 5 13 5l256 0c5 0 9-2 13-5 3-4 5-8 5-13z"/>
<glyph glyph-name="arrow-left" unicode="&#84;" d="M347 384l0-256c0-5-1-9-5-13-4-3-8-5-13-5-5 0-9 2-13 5l-128 128c-3 4-5 8-5 13 0 5 2 9 5 13l128 128c4 3 8 5 13 5 5 0 9-2 13-5 4-4 5-8 5-13z"/>
<glyph glyph-name="arrow-right" unicode="&#85;" d="M329 256c0-5-2-9-5-13l-128-128c-4-3-8-5-13-5-5 0-9 2-13 5-4 4-5 8-5 13l0 256c0 5 1 9 5 13 4 3 8 5 13 5 5 0 9-2 13-5l128-128c3-4 5-8 5-13z"/>
<glyph glyph-name="check-circle" unicode="&#86;" d="M256 480c-124 0-224-100-224-224 0-124 100-224 224-224 124 0 224 100 224 224 0 124-100 224-224 224z m115-149l-139-179c-1-1-3-3-5-3-3 0-4 1-5 3-2 1-79 76-79 76l-2 1c0 1-1 2-1 3 0 2 1 3 1 4 1 0 1 0 1 1 8 8 24 24 25 25 1 2 2 3 4 3 3 0 5-2 6-3 1-1 45-43 45-43l111 143c1 0 2 1 4 1 1 0 2 0 3-1l31-24c0-1 1-3 1-4 0-1 0-2-1-3z"/>
<glyph glyph-name="arrow-top" unicode="&#87;" d="M402 165c0-5-2-10-5-13-4-4-8-6-13-6l-256 0c-5 0-9 2-13 6-3 3-5 8-5 13 0 5 2 9 5 12l128 128c4 4 8 6 13 6 5 0 9-2 13-6l128-128c3-3 5-7 5-12z"/>
<glyph glyph-name="help-1" unicode="&#88;" d="M345 435c-27 21-58 28-98 28-29 0-55-6-75-20-30-20-44-54-44-108l77 0c0 14-2 30 7 43 8 13 20 24 40 24 20 0 31-6 41-18 8-11 11-23 11-36 0-12-5-22-12-32-4-5-9-10-15-15 0 0-42-25-56-48-11-18-15-40-16-66 0-2 0-5 7-5 7 0 56 0 62 0 6 0 7 4 7 6 0 9 2 24 3 29 4 11 10 20 20 28l21 14c18 15 33 26 40 36 11 15 19 34 19 57 0 36-13 64-39 83z m-103-293c-26 1-47-17-48-46-1-28 19-46 45-47 27-1 48 17 49 45 1 28-19 47-46 48z"/>
<glyph glyph-name="checkmark-circle" unicode="&#89;" d="M171 296l-29-30 93-93 208 208-29 29-179-178z m251-40c0-92-74-166-166-166-92 0-166 74-166 166 0 92 74 166 166 166 16 0 31-2 46-6l32 32c-24 11-50 16-78 16-114 0-208-94-208-208 0-114 94-208 208-208 114 0 208 94 208 208z"/>
</font></defs></svg>

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -172,3 +172,6 @@
.icon-arrow-right:before {
content: "\55";
}
.icon-checkmark-circle:before {
content: "\59";
}

View File

@@ -732,6 +732,56 @@ form {
// 07. Callout
// -----------
.callout-slide {
animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-fill-mode: both;
-webkit-animation-fill-mode: both;
animation-name: slide;
-webkit-animation-name: slide;
}
@-webkit-keyframes slide {
from {
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
@keyframes slide {
from {
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
.notice-container {
min-width: $line-height*12;
position: absolute;
right: 24px;
top: 24px;
.notice {
height: $line-height*4;
.notice-text {
width: 95%;
}
}
}
.callout {
font-size: $small-font-size;

View File

@@ -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);
}
}
}

View File

@@ -12,7 +12,7 @@ module CommentableActions
@tag_cloud = tag_cloud
@banners = Banner.with_active
set_resource_votes(@resources)
set_resources_instance
end

View File

@@ -22,6 +22,7 @@ class DebatesController < ApplicationController
def index_customization
@featured_debates = @debates.featured
@proposal_successfull_exists = Proposal.successfull.exists?
end
def show

View File

@@ -0,0 +1,8 @@
class ProposalBallotsController < ApplicationController
skip_authorization_check
def index
@proposal_ballots = Proposal.successfull.sort_by_confidence_score
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -2,8 +2,8 @@ class User < ActiveRecord::Base
include Verification
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, :async
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable,
:trackable, :validatable, :omniauthable, :async, :password_expirable, :secure_validatable
acts_as_voter
acts_as_paranoid column: :hidden_at

View File

@@ -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 %>

View File

@@ -0,0 +1,13 @@
<h2><%= t("devise.password_expired.expire_password") %></h2>
<%= form_for(resource, :as => resource_name, :url => [resource_name, :password_expired], :html => { :method => :put }) do |f| %>
<%= f.password_field :current_password %></p>
<%= f.label t("devise.password_expired.new_password") %>
<%= f.password_field :password, label: false %></p>
<%= f.password_field :password_confirmation %></p>
<p><%= f.submit t("devise.password_expired.change_password") %></p>
<% end %>

View File

@@ -13,6 +13,6 @@
</div>
<h1><%= @direct_message.title %></h1>
<p><%= @direct_message.body %></p>
<p><%= simple_format text_with_links(@direct_message.body), {}, sanitize: false %></p>
</div>
</div>

View File

@@ -1,10 +1,12 @@
<% flash.each do |flash_key, flash_message| %>
<div id="<%= flash_key %>" data-alert class="row" data-closable>
<div class="callout <%= flash_key %>">
<div id="<%= flash_key %>" data-alert class="notice-container callout-slide" data-closable>
<div class="callout notice <%= flash_key %>">
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<%= flash_message %>
<div class="notice-text">
<%= flash_message %>
</div>
</div>
</div>
<% end %>

View File

@@ -3,9 +3,9 @@
<%= @direct_message.title %>
</h1>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= @direct_message.body %>
</p>
<div style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= simple_format text_with_links(@direct_message.body), {}, sanitize: false %>
</div>
<table style="width: 100%; border-top: 1px solid #DEE0E3; margin-top: 60px;">
<tbody>

View File

@@ -9,7 +9,7 @@
<%= @direct_message.title %>
</h2>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= @direct_message.body %>
</p>
<div style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= simple_format text_with_links(@direct_message.body), {}, sanitize: false %>
</div>
</td>

View File

@@ -0,0 +1,13 @@
<div id="<%= dom_id(proposal) %>" class="proposal-sucessfull">
<h3><%= link_to proposal.title, proposal %></h3>
<div class="info">
<% if proposal.author.hidden? || proposal.author.erased? %>
<%= t("proposals.show.author_deleted") %>
<% else %>
<%= proposal.author.name %>
<% end %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= l proposal.created_at.to_date %>
</div>
</div>

View File

@@ -0,0 +1,35 @@
<div class="expanded no-margin-top margin-bottom dark-heading">
<div class="row" data-equalizer>
<div class="small-12 medium-6 column padding" data-equalizer-watch>
<h2>
<%= t("proposal_ballots.title") %>
</h2>
<p>
<%= t("proposal_ballots.description_html").html_safe %>
</p>
</div>
<div class="small-12 medium-4 column info" data-equalizer-watch>
<p class="title"><strong><%= t("proposal_ballots.date_title") %></strong></p>
<h3><%= t("proposal_ballots.date") %></h3>
</div>
</div>
</div>
<main>
<div class="row">
<div class="small-12 column">
<% if @proposal_ballots.present? %>
<div class="proposals-ballot-list">
<% @proposal_ballots.each do |proposal_for_vote| %>
<%= render "successfull_proposal", proposal: proposal_for_vote %>
<% end %>
</div>
<% else %>
<p>
<%= t("proposal_ballots.nothing_to_vote") %>
</p>
<% end %>
</div>
</div>
</main>

View File

@@ -1,10 +1,12 @@
<div id="<%= dom_id(proposal) %>" class="proposal clear" data-type="proposal">
<div id="<%= dom_id(proposal) %>"
class="proposal clear <%= ("successfull" if proposal.total_votes > Proposal.votes_needed_for_success) %>"
data-type="proposal">
<div class="panel">
<div class="icon-successfull"></div>
<div class="row">
<div class="small-12 medium-9 column">
<div class="proposal-content">
<% cache [locale_and_user_status(proposal), 'index', proposal, proposal.author] do %>
<span class="label-proposal float-left"><%= t("proposals.proposal.proposal") %></span>
<span class="icon-proposals"></span>
@@ -50,11 +52,26 @@
</div>
</div>
<div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column text-center">
<%= render 'votes',
{ proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %>
<div id="<%= dom_id(proposal) %>_votes" class="small-12 medium-3 column">
<% if proposal.successfull? %>
<div class="message">
<p>
<%= t("proposal_ballots.successfull",
voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %>
</p>
</div>
<% elsif proposal.archived? %>
<div class="message">
<strong><%= t("proposals.proposal.supports", count: proposal.total_votes) %></strong>
<p><%= t("proposals.proposal.archived") %></p>
</div>
<% else %>
<div class="text-center">
<%= render 'votes',
{ proposal: proposal, vote_url: vote_proposal_path(proposal, value: 'yes') } %>
</div>
<% end %>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,9 @@
<div id="next-voting" class="row featured-proposals-ballot-banner">
<%= link_to proposal_ballots_path do %>
<div class="small-12 column padding">
<div class="icon-successfull"></div>
<h2><%= t("proposal_ballots.featured_title") %></h2>
<p><%= t("proposal_ballots.info") %></p>
</div>
<% end %>
</div>

View File

@@ -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? %>
<div id="featured-proposals" class="row featured-proposals">
<div class="small-12 column">
<h2>
@@ -52,8 +54,10 @@
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %>
</div>
<%= render partial: 'proposals/proposal', collection: @proposals %>
<%= paginate @proposals %>
<div id="proposals-list">
<%= render partial: 'proposals/proposal', collection: @proposals %>
<%= paginate @proposals %>
</div>
</div>
<div class="small-12 medium-3 column">

View File

@@ -102,11 +102,23 @@
<aside class="small-12 medium-3 column">
<div class="sidebar-divider"></div>
<h3><%= t("votes.supports") %></h3>
<div class="text-center">
<div id="<%= dom_id(@proposal) %>_votes">
<%= render 'votes',
{ proposal: @proposal, vote_url: vote_proposal_path(@proposal, value: 'yes') } %>
</div>
<div id="<%= dom_id(@proposal) %>_votes">
<% if @proposal.successfull? %>
<p>
<%= t("proposal_ballots.successfull",
voting: link_to(t("proposal_ballots.voting"), proposal_ballots_path)).html_safe %>
</p>
<% elsif @proposal.archived? %>
<p class="text-center">
<strong><%= t("proposals.proposal.supports", count: @proposal.total_votes) %></strong>
</p>
<p><%= t("proposals.proposal.archived") %></p>
<% else %>
<div class="text-center">
<%= render 'votes',
{ proposal: @proposal, vote_url: vote_proposal_path(@proposal, value: 'yes') } %>
</div>
<% end %>
</div>
<div id="social-share" class="sidebar-divider"></div>
<h3><%= t("proposals.show.share") %></h3>

View File

@@ -8,6 +8,9 @@
<li>
<%= link_to t("layouts.header.proposals"), proposals_path, class: ("active" if controller_name == "proposals"), accesskey: "p" %>
</li>
<li>
<%= link_to t("layouts.header.proposal_ballot"), proposal_ballots_path, class: ("active" if controller_name == "proposal_ballots"), accesskey: "v" %>
</li>
<% if feature?(:spending_proposals) %>
<li>
<%= link_to t("layouts.header.spending_proposals"), spending_proposals_path, class: ("active" if controller_name == "spending_proposals"), accesskey: "s" %>