Merge branch 'master' into budgets
This commit is contained in:
@@ -34,3 +34,4 @@
|
||||
@include foundation-thumbnail;
|
||||
@include foundation-title-bar;
|
||||
@include foundation-top-bar;
|
||||
@include foundation-menu-icon;
|
||||
|
||||
@@ -221,7 +221,6 @@ a {
|
||||
float: left;
|
||||
}
|
||||
|
||||
//<<<<<<< HEAD
|
||||
//.table-fixed {
|
||||
// table-layout: fixed;
|
||||
//=======
|
||||
@@ -261,9 +260,46 @@ a {
|
||||
//
|
||||
//.button.float-right ~ .button.float-right {
|
||||
// margin: 0 $line-height/2;
|
||||
//>>>>>>> budget
|
||||
//}
|
||||
|
||||
.tabs-content {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
border: {
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
};
|
||||
margin-bottom: $line-height;
|
||||
|
||||
.tabs-title > a {
|
||||
color: $text-medium;
|
||||
margin-bottom: rem-calc(-1);
|
||||
margin-right: $line-height;
|
||||
|
||||
&[aria-selected='true'],
|
||||
&.is-active {
|
||||
color: $brand;
|
||||
border-bottom: 2px solid $brand;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
font-size: $base-font-size;
|
||||
}
|
||||
}
|
||||
|
||||
.no-max-width {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.button.float-right ~ .button.float-right {
|
||||
margin: 0 $line-height/2;
|
||||
}
|
||||
|
||||
.pagination .current {
|
||||
background: $brand;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
|
||||
has_filters %w{all with_active with_inactive}, only: :index
|
||||
|
||||
before_action :find_banner, only: [:edit, :update, :destroy]
|
||||
before_action :banner_styles, only: [:edit, :new, :create, :update]
|
||||
before_action :banner_imgs, only: [:edit, :new, :create, :update]
|
||||
|
||||
@@ -24,7 +23,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def update
|
||||
@banner.assign_attributes(banner_params)
|
||||
if @banner.update(banner_params)
|
||||
redirect_to admin_banners_path
|
||||
else
|
||||
@@ -43,10 +41,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at)
|
||||
end
|
||||
|
||||
def find_banner
|
||||
@banner = Banner.find(params[:id])
|
||||
end
|
||||
|
||||
def banner_styles
|
||||
@banner_styles = Setting.all.banner_style.map { |banner_style| [banner_style.value, banner_style.key.split('.')[1]] }
|
||||
end
|
||||
|
||||
49
app/controllers/admin/geozones_controller.rb
Normal file
49
app/controllers/admin/geozones_controller.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
class Admin::GeozonesController < Admin::BaseController
|
||||
|
||||
respond_to :html
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@geozones = Geozone.all.order("LOWER(name)")
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@geozone = Geozone.new(geozone_params)
|
||||
|
||||
if @geozone.save
|
||||
redirect_to admin_geozones_path
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @geozone.update(geozone_params)
|
||||
redirect_to admin_geozones_path
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @geozone.safe_to_destroy?
|
||||
@geozone.destroy
|
||||
redirect_to admin_geozones_path, notice: t('admin.geozones.delete.success')
|
||||
else
|
||||
redirect_to admin_geozones_path, flash: { error: t('admin.geozones.delete.error') }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def geozone_params
|
||||
params.require(:geozone).permit(:name, :external_code, :census_code, :html_map_coordinates)
|
||||
end
|
||||
end
|
||||
32
app/controllers/admin/signature_sheets_controller.rb
Normal file
32
app/controllers/admin/signature_sheets_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class Admin::SignatureSheetsController < Admin::BaseController
|
||||
|
||||
def index
|
||||
@signature_sheets = SignatureSheet.all
|
||||
end
|
||||
|
||||
def new
|
||||
@signature_sheet = SignatureSheet.new
|
||||
end
|
||||
|
||||
def create
|
||||
@signature_sheet = SignatureSheet.new(signature_sheet_params)
|
||||
@signature_sheet.author = current_user
|
||||
if @signature_sheet.save
|
||||
@signature_sheet.delay.verify_signatures
|
||||
redirect_to [:admin, @signature_sheet], notice: I18n.t('flash.actions.create.signature_sheet')
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@signature_sheet = SignatureSheet.find(params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def signature_sheet_params
|
||||
params.require(:signature_sheet).permit(:signable_type, :signable_id, :document_numbers)
|
||||
end
|
||||
|
||||
end
|
||||
12
app/helpers/layouts_helper.rb
Normal file
12
app/helpers/layouts_helper.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module LayoutsHelper
|
||||
|
||||
def layout_menu_link_to(text, path, is_active, options)
|
||||
if is_active
|
||||
content_tag(:span, t('shared.you_are_in'), class: 'sr-only') + ' ' +
|
||||
link_to(text, path, options.merge(class: "active"))
|
||||
else
|
||||
link_to(text, path, options)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
8
app/helpers/signature_sheets_helper.rb
Normal file
8
app/helpers/signature_sheets_helper.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
module SignatureSheetsHelper
|
||||
|
||||
def signable_options
|
||||
[[t("activerecord.models.proposal", count: 1), Proposal],
|
||||
[t("activerecord.models.spending_proposal", count: 1), SpendingProposal]]
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
helper :settings
|
||||
default from: "Consul <no-reply@consul.es>"
|
||||
default from: "#{Setting['mailer_from_name']} <#{Setting['mailer_from_address']}>"
|
||||
layout 'mailer'
|
||||
end
|
||||
|
||||
@@ -50,6 +50,7 @@ module Abilities
|
||||
can :create, Budget::ValuatorAssignment
|
||||
|
||||
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
||||
can [:index, :create, :edit, :update, :destroy], Geozone
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
class Geozone < ActiveRecord::Base
|
||||
has_many :proposals
|
||||
has_many :spending_proposals
|
||||
has_many :debates
|
||||
has_many :users
|
||||
validates :name, presence: true
|
||||
|
||||
def self.names
|
||||
Geozone.pluck(:name)
|
||||
end
|
||||
|
||||
def safe_to_destroy?
|
||||
Geozone.reflect_on_all_associations(:has_many).all? do |association|
|
||||
association.klass.where(geozone: self).empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
85
app/models/signature.rb
Normal file
85
app/models/signature.rb
Normal file
@@ -0,0 +1,85 @@
|
||||
class Signature < ActiveRecord::Base
|
||||
belongs_to :signature_sheet
|
||||
belongs_to :user
|
||||
|
||||
validates :document_number, presence: true
|
||||
validates :signature_sheet, presence: true
|
||||
|
||||
scope :verified, -> { where(verified: true) }
|
||||
scope :unverified, -> { where(verified: false) }
|
||||
|
||||
delegate :signable, to: :signature_sheet
|
||||
|
||||
def verified?
|
||||
user_exists? || in_census?
|
||||
end
|
||||
|
||||
def verify
|
||||
if verified?
|
||||
assign_vote
|
||||
mark_as_verified
|
||||
end
|
||||
end
|
||||
|
||||
def assign_vote
|
||||
if user_exists?
|
||||
assign_vote_to_user
|
||||
else
|
||||
create_user
|
||||
assign_vote_to_user
|
||||
end
|
||||
end
|
||||
|
||||
def assign_vote_to_user
|
||||
set_user
|
||||
signable.register_vote(user, "yes")
|
||||
assign_signature_to_vote
|
||||
end
|
||||
|
||||
def assign_signature_to_vote
|
||||
vote = Vote.where(votable: signable, voter: user).first
|
||||
vote.update(signature: self)
|
||||
end
|
||||
|
||||
def user_exists?
|
||||
User.where(document_number: document_number).any?
|
||||
end
|
||||
|
||||
def create_user
|
||||
user_params = {
|
||||
document_number: document_number,
|
||||
created_from_signature: true,
|
||||
verified_at: Time.now,
|
||||
erased_at: Time.now,
|
||||
password: random_password,
|
||||
terms_of_service: '1',
|
||||
email: nil
|
||||
}
|
||||
User.create!(user_params)
|
||||
end
|
||||
|
||||
def random_password
|
||||
(0...20).map { ('a'..'z').to_a[rand(26)] }.join
|
||||
end
|
||||
|
||||
def in_census?
|
||||
response = document_types.detect do |document_type|
|
||||
CensusApi.new.call(document_type, document_number).valid?
|
||||
end
|
||||
response.present?
|
||||
end
|
||||
|
||||
def set_user
|
||||
user = User.where(document_number: document_number).first
|
||||
update(user: user)
|
||||
end
|
||||
|
||||
def mark_as_verified
|
||||
update(verified: true)
|
||||
end
|
||||
|
||||
def document_types
|
||||
%w(1 2 3 4)
|
||||
end
|
||||
|
||||
end
|
||||
38
app/models/signature_sheet.rb
Normal file
38
app/models/signature_sheet.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
class SignatureSheet < ActiveRecord::Base
|
||||
belongs_to :signable, polymorphic: true
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
|
||||
VALID_SIGNABLES = %w( Proposal SpendingProposal )
|
||||
|
||||
has_many :signatures
|
||||
|
||||
validates :author, presence: true
|
||||
validates :signable_type, inclusion: {in: VALID_SIGNABLES}
|
||||
validates :document_numbers, presence: true
|
||||
validates :signable, presence: true
|
||||
validate :signable_found
|
||||
|
||||
def name
|
||||
"#{signable_name} #{signable_id}"
|
||||
end
|
||||
|
||||
def signable_name
|
||||
I18n.t("activerecord.models.#{signable_type.underscore}", count: 1)
|
||||
end
|
||||
|
||||
def verify_signatures
|
||||
parsed_document_numbers.each do |document_number|
|
||||
signature = signatures.create(document_number: document_number)
|
||||
signature.verify
|
||||
end
|
||||
update(processed: true)
|
||||
end
|
||||
|
||||
def parsed_document_numbers
|
||||
document_numbers.split(/\W+/)
|
||||
end
|
||||
|
||||
def signable_found
|
||||
errors.add(:signable_id, :not_found) if errors.messages[:signable].present?
|
||||
end
|
||||
end
|
||||
@@ -169,7 +169,6 @@ class User < ActiveRecord::Base
|
||||
username: nil,
|
||||
email: nil,
|
||||
unconfirmed_email: nil,
|
||||
document_number: nil,
|
||||
phone_number: nil,
|
||||
encrypted_password: "",
|
||||
confirmation_token: nil,
|
||||
|
||||
@@ -10,7 +10,7 @@ class Verification::Management::Document
|
||||
delegate :username, :email, to: :user, allow_nil: true
|
||||
|
||||
def user
|
||||
@user = User.by_document(document_type, document_number).first
|
||||
@user = User.active.by_document(document_type, document_number).first
|
||||
end
|
||||
|
||||
def user?
|
||||
|
||||
@@ -35,13 +35,21 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<%# if feature?(:budgets) %>
|
||||
<% if feature?(:budgets) %>
|
||||
<li <%= "class=active" if controller_name == "budgets" %>>
|
||||
<%= link_to admin_budgets_path do %>
|
||||
<span class="icon-budget"></span><%= t("admin.menu.budgets") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<%# end %>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:signature_sheets) %>
|
||||
<li <%= "class=active" if controller_name == "signature_sheets" %>>
|
||||
<%= link_to admin_signature_sheets_path do %>
|
||||
<span class="icon-budget"></span><%= t("admin.menu.signature_sheets") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<li <%= "class=active" if controller_name == "banners" %>>
|
||||
<%= link_to admin_banners_path do %>
|
||||
@@ -91,6 +99,12 @@
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li <%= 'class=active' if controller_name == 'geozones' %>>
|
||||
<%= link_to admin_geozones_path do %>
|
||||
<span class="icon-settings"></span><%= t('admin.menu.geozones') %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li <%= 'class=active' if controller_name == 'activity' %>>
|
||||
<%= link_to admin_activity_path do %>
|
||||
<span class="icon-eye"></span><%= t('admin.menu.activity') %>
|
||||
|
||||
15
app/views/admin/geozones/_errors.html.erb
Normal file
15
app/views/admin/geozones/_errors.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
<% if @geozone.errors.any? %>
|
||||
|
||||
<div id="error_explanation" data-alert class="callout alert" data-closable>
|
||||
<button class="close-button" aria-label="<%= t("application.close") %>" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
<strong>
|
||||
<%= @geozone.errors.count %>
|
||||
<%= t("admin.geozones.errors.form.error", count: @geozone.errors.count) %>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
29
app/views/admin/geozones/_form.html.erb
Normal file
29
app/views/admin/geozones/_form.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<%= form_for [:admin, @geozone] do |f| %>
|
||||
|
||||
<%= render 'errors' %>
|
||||
|
||||
<div clas="row">
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= f.label :name, t("admin.geozones.geozone.name") %>
|
||||
<%= f.text_field :name, label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= f.label :html_map_coordinates, t("admin.geozones.geozone.coordinates") %>
|
||||
<%= f.text_field :html_map_coordinates, label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-2 column">
|
||||
<%= f.label :external_code, t("admin.geozones.geozone.external_code") %>
|
||||
<%= f.text_field :external_code, label: false %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-2 column">
|
||||
<%= f.label :census_code, t("admin.geozones.geozone.census_code") %>
|
||||
<%= f.text_field :census_code, label: false %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="actions small-12 large-3 medium-3 column">
|
||||
<%= f.submit(class: "button expanded", value: t("admin.geozones.edit.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
13
app/views/admin/geozones/edit.html.erb
Normal file
13
app/views/admin/geozones/edit.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_geozones_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.geozones.edit.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= t("admin.geozones.edit.editing") %></h1>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
33
app/views/admin/geozones/index.html.erb
Normal file
33
app/views/admin/geozones/index.html.erb
Normal file
@@ -0,0 +1,33 @@
|
||||
<%= link_to t("admin.geozones.index.create"),
|
||||
new_admin_geozone_path, class: "button success float-right" %>
|
||||
|
||||
<h2 class="inline-block"><%= t("admin.geozones.index.title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.geozones.geozone.name") %></th>
|
||||
<th><%= t("admin.geozones.geozone.external_code") %></th>
|
||||
<th><%= t("admin.geozones.geozone.census_code") %></th>
|
||||
<th><%= t("admin.geozones.geozone.coordinates") %></th>
|
||||
<th colspan="2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @geozones.each do |geozone| %>
|
||||
<tr id="<%= dom_id(geozone) %>">
|
||||
<td><%= geozone.name %></td>
|
||||
<td><%= geozone.external_code %></td>
|
||||
<td><%= geozone.census_code %></td>
|
||||
<td><%= geozone.html_map_coordinates %></td>
|
||||
<td>
|
||||
<%= link_to t("admin.geozones.index.edit"), edit_admin_geozone_path(geozone), class: 'edit-banner button hollow' %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.geozones.index.delete"), admin_geozone_path(geozone), method: :delete, class: 'button hollow alert' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
13
app/views/admin/geozones/new.html.erb
Normal file
13
app/views/admin/geozones/new.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="geozone-new row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= link_to admin_geozones_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("admin.geozones.new.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= t("admin.geozones.new.creating") %></h1>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
</div>
|
||||
31
app/views/admin/signature_sheets/index.html.erb
Normal file
31
app/views/admin/signature_sheets/index.html.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
<h2 class="inline-block"><%= t("admin.signature_sheets.index.title") %></h2>
|
||||
|
||||
<%= link_to t("admin.signature_sheets.index.new"), new_admin_signature_sheet_path,
|
||||
class: "button success float-right" %>
|
||||
|
||||
<% if @signature_sheets.any? %>
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t("admin.signature_sheets.name") %></th>
|
||||
<th><%= t("admin.signature_sheets.author") %></th>
|
||||
<th><%= t("admin.signature_sheets.created_at") %></th>
|
||||
</tr>
|
||||
<% @signature_sheets.each do |signature_sheet| %>
|
||||
<tr id="<%= dom_id(signature_sheet) %>" class="signature_sheet">
|
||||
<td>
|
||||
<%= link_to signature_sheet.name, [:admin, signature_sheet] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= signature_sheet.author.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= l(signature_sheet.created_at, format: :short) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% else %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.signature_sheets.no_signature_sheets") %>
|
||||
</div>
|
||||
<% end %>
|
||||
22
app/views/admin/signature_sheets/new.html.erb
Normal file
22
app/views/admin/signature_sheets/new.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<%= render 'shared/back_link' %>
|
||||
|
||||
<h2><%= t("admin.signature_sheets.new.title") %></h2>
|
||||
|
||||
<%= form_for [:admin, @signature_sheet] do |f| %>
|
||||
<%= render 'shared/errors',
|
||||
resource: @signature_sheet %>
|
||||
|
||||
<div class="small-12 medium-6 large-4">
|
||||
<%= f.select :signable_type, signable_options %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-6 large-4">
|
||||
<%= f.text_field :signable_id %>
|
||||
</div>
|
||||
|
||||
<%= f.label :document_numbers %>
|
||||
<p class="note"><%= t("admin.signature_sheets.new.document_numbers_note") %></p>
|
||||
<%= f.text_area :document_numbers, rows: "6", label: false %>
|
||||
|
||||
<%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %>
|
||||
<% end %>
|
||||
39
app/views/admin/signature_sheets/show.html.erb
Normal file
39
app/views/admin/signature_sheets/show.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<h2 class="inline-block"><%= @signature_sheet.name %></h2>
|
||||
|
||||
<div class="callout secondary float-right">
|
||||
<%= t("admin.signature_sheets.show.created_at") %>
|
||||
<strong><%= l(@signature_sheet.created_at, format: :short) %></strong>
|
||||
<span class="bullet"> • </span>
|
||||
<%= t("admin.signature_sheets.show.author") %>
|
||||
<strong><%= @signature_sheet.author.name %></strong>
|
||||
</div>
|
||||
|
||||
<div class="callout margin-top">
|
||||
<p><strong><%= t("admin.signature_sheets.show.documents") %></strong></p>
|
||||
<%= simple_format @signature_sheet.document_numbers %>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="verified_signatures" class="callout success">
|
||||
<strong>
|
||||
<%= t("admin.signature_sheets.show.verified",
|
||||
count: @signature_sheet.signatures.verified.count ) %>
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div id="unverified_signatures" class="callout alert">
|
||||
<p>
|
||||
<strong>
|
||||
<%= t("admin.signature_sheets.show.unverified",
|
||||
count: @signature_sheet.signatures.unverified.count ) %>
|
||||
<%= t("admin.signature_sheets.show.unverified_error") %>
|
||||
</strong>
|
||||
</p>
|
||||
<%= @signature_sheet.signatures.unverified.map(&:document_number).join(", ") %>
|
||||
</div>
|
||||
|
||||
<% unless @signature_sheet.processed? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.signature_sheets.show.loading") %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,7 +1,7 @@
|
||||
<% comment_flags ||= @comment_flags %>
|
||||
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>
|
||||
<div class="row">
|
||||
<div id="<%= dom_id(comment) %>" class="comment small-12 column">
|
||||
<ul id="<%= dom_id(comment) %>" class="comment no-bullet small-12 column">
|
||||
|
||||
<% if comment.hidden? || comment.user.hidden? %>
|
||||
<% if comment.children.size > 0 %>
|
||||
@@ -24,7 +24,7 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="comment-body">
|
||||
<li class="comment-body">
|
||||
<div class="comment-info">
|
||||
|
||||
<% if comment.as_administrator? %>
|
||||
@@ -93,14 +93,13 @@
|
||||
<%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<div id="<%= dom_id(comment) %>_children" class="comment-children">
|
||||
<ul id="<%= dom_id(comment) %>_children" class="no-bullet comment-children">
|
||||
<% child_comments_of(comment).each do |child| %>
|
||||
<%= render 'comments/comment', comment: child %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@debate), @comment_tree.comments, @comment_tree.comment_authors, @debate.comments_count, @comment_flags] do %>
|
||||
<section class="row-full comments">
|
||||
<div class="row">
|
||||
<div id="comments" class="small-12 column">
|
||||
<h2>
|
||||
<%= t("debates.show.comments_title") %>
|
||||
<span class="js-comments-count">(<%= @debate.comments_count %>)</span>
|
||||
</h2>
|
||||
<div class="row comments">
|
||||
<div id="comments" class="small-12 column">
|
||||
<h3>
|
||||
<%= t("debates.show.comments_title") %>
|
||||
<span class="js-comments-count">(<%= @debate.comments_count %>)</span>
|
||||
</h3>
|
||||
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @debate, parent_id: nil, toggeable: false} %>
|
||||
<% else %>
|
||||
<br>
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @debate, parent_id: nil, toggeable: false} %>
|
||||
<% else %>
|
||||
<br>
|
||||
|
||||
<div data-alert class="callout primary">
|
||||
<%= t("debates.show.login_to_comment",
|
||||
signin: link_to(t("votes.signin"), new_user_session_path),
|
||||
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div data-alert class="callout primary">
|
||||
<%= t("debates.show.login_to_comment",
|
||||
signin: link_to(t("votes.signin"), new_user_session_path),
|
||||
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% @comment_tree.root_comments.each do |comment| %>
|
||||
<%= render 'comments/comment', comment: comment %>
|
||||
<% end %>
|
||||
<%= paginate @comment_tree.root_comments %>
|
||||
</div>
|
||||
<% @comment_tree.root_comments.each do |comment| %>
|
||||
<%= render 'comments/comment', comment: comment %>
|
||||
<% end %>
|
||||
<%= paginate @comment_tree.root_comments %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<%= form_for(@debate) do |f| %>
|
||||
|
||||
|
||||
<%= render 'shared/errors', resource: @debate %>
|
||||
|
||||
<div class="row">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% provide :title do %><%= @debate.title %><% end %>
|
||||
<% cache [locale_and_user_status(@debate), @debate, @debate.author, Flag.flagged?(current_user, @debate), @debate_votes] do %>
|
||||
<section class="debate-show">
|
||||
<div class="debate-show">
|
||||
<div id="<%= dom_id(@debate) %>" class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= render "shared/back_link" %>
|
||||
@@ -59,7 +59,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "comments" %>
|
||||
|
||||
@@ -16,12 +16,7 @@
|
||||
<div class="top-bar-title">
|
||||
<%= link_to root_path, class: "hide-for-small-only", accesskey: "/" do %>
|
||||
<%= image_tag('logo_header.png', class: 'hide-for-small-only float-left', size: '80x80', alt: t("layouts.header.logo")) %>
|
||||
<% if opendata_page? %>
|
||||
<%= t("layouts.header.open_gov", open: "#{t('layouts.header.open')}") %> <span>|</span>
|
||||
<span class="logo-site"><%= t("layouts.header.open_data") %></span>
|
||||
<% else %>
|
||||
<%= setting['org_name'] %>
|
||||
<% end %>
|
||||
<%= setting['org_name'] %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -34,9 +29,6 @@
|
||||
<div class="show-for-small-only">
|
||||
<div class="subnavigation row">
|
||||
<%= render "shared/subnavigation" %>
|
||||
<div class="small-12 medium-3 column">
|
||||
<%= yield :header_addon %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,9 +40,9 @@
|
||||
<div class="row">
|
||||
<div class="hide-for-small-only">
|
||||
<%= render "shared/subnavigation" %>
|
||||
<div class="small-12 medium-3 column">
|
||||
<%= yield :header_addon %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small-12 medium-3 column">
|
||||
<%= yield :header_addon %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<%= csrf_meta_tags %>
|
||||
<%= favicon_link_tag "favicon.ico" %>
|
||||
<%= favicon_link_tag "apple-touch-icon-200.png",
|
||||
rel: "apple-touch-icon",
|
||||
rel: "icon apple-touch-icon",
|
||||
sizes: "200x200",
|
||||
type: "image/png" %>
|
||||
<%= content_for :social_media_meta_tags %>
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count, @comment_flags] do %>
|
||||
<section class="comments">
|
||||
<div class="row">
|
||||
<div id="comments" class="small-12 column">
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
<div class="row comments">
|
||||
<div id="comments" class="small-12 column">
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @proposal, parent_id: nil, toggeable: false} %>
|
||||
<% else %>
|
||||
<br>
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @proposal, parent_id: nil, toggeable: false} %>
|
||||
<% else %>
|
||||
<br>
|
||||
|
||||
<div data-alert class="callout primary">
|
||||
<%= t("proposals.show.login_to_comment",
|
||||
signin: link_to(t("votes.signin"), new_user_session_path),
|
||||
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div data-alert class="callout primary">
|
||||
<%= t("proposals.show.login_to_comment",
|
||||
signin: link_to(t("votes.signin"), new_user_session_path),
|
||||
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% @comment_tree.root_comments.each do |comment| %>
|
||||
<%= render 'comments/comment', comment: comment %>
|
||||
<% end %>
|
||||
<%= paginate @comment_tree.root_comments %>
|
||||
</div>
|
||||
<% @comment_tree.root_comments.each do |comment| %>
|
||||
<%= render 'comments/comment', comment: comment %>
|
||||
<% end %>
|
||||
<%= paginate @comment_tree.root_comments %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
<ul class="tabs" data-tabs id="example-tabs">
|
||||
<li class="tabs-title is-active">
|
||||
<%= link_to "#tab-comments" do %>
|
||||
<h2>
|
||||
<h3>
|
||||
<%= t("proposals.show.comments_tab") %>
|
||||
<span class="js-comments-count">(<%= @proposal.comments_count %>)</span>
|
||||
</h2>
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-notifications" do %>
|
||||
<h2>
|
||||
<h3>
|
||||
<%= t("proposals.show.notifications_tab") %>
|
||||
(<%= @notifications.count %>)
|
||||
</h2>
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
social_description: @proposal.summary %>
|
||||
<% end %>
|
||||
<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %>
|
||||
|
||||
<section class="proposal-show">
|
||||
<div class="proposal-show">
|
||||
<div id="<%= dom_id(@proposal) %>" class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= render "shared/back_link" %>
|
||||
@@ -134,7 +133,7 @@
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="tabs-content" data-tabs-content="example-tabs">
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
</div>
|
||||
|
||||
<div class="small-12 large-3 column">
|
||||
<label><%= t("shared.advanced_search.author_type") %></label>
|
||||
<label for="advanced_search_official_level"><%= t("shared.advanced_search.author_type") %></label>
|
||||
<%= select_tag('advanced_search[official_level]', official_level_search_options,
|
||||
include_blank: t("shared.advanced_search.author_type_blank")) %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 large-9">
|
||||
<div class="small-12 large-4 column">
|
||||
<label><%= t("shared.advanced_search.date") %></label>
|
||||
<label for="js-advanced-search-date-min"><%= t("shared.advanced_search.date") %></label>
|
||||
<%= select_tag('advanced_search[date_min]', date_range_options,
|
||||
include_blank: t("shared.advanced_search.date_range_blank"),
|
||||
id: 'js-advanced-search-date-min') %>
|
||||
@@ -31,14 +31,18 @@
|
||||
<div id='js-custom-date' class='small-12 large-8 column' style="display: none">
|
||||
<div class="row">
|
||||
<div class='small-12 large-6 column'>
|
||||
<label><%= t("shared.advanced_search.from") %> (<%= t("shared.advanced_search.date_placeholder") %>)</label>
|
||||
<label for="advanced_search_date_min">
|
||||
<%= t("shared.advanced_search.from") %> (<%= t("shared.advanced_search.date_placeholder") %>)
|
||||
</label>
|
||||
<%= text_field_tag 'advanced_search[date_min]',
|
||||
params[:advanced_search].try(:[], :date_min),
|
||||
placeholder: t("shared.advanced_search.date_placeholder"),
|
||||
class: 'js-calendar' %>
|
||||
</div>
|
||||
<div class='small-12 large-6 column'>
|
||||
<label><%= t("shared.advanced_search.to") %> (<%= t("shared.advanced_search.date_placeholder") %>)</label>
|
||||
<label for="advanced_search_date_max">
|
||||
<%= t("shared.advanced_search.to") %> (<%= t("shared.advanced_search.date_placeholder") %>)
|
||||
</label>
|
||||
<%= text_field_tag 'advanced_search[date_max]',
|
||||
params[:advanced_search].try(:[], :date_max),
|
||||
placeholder: t("shared.advanced_search.date_placeholder"),
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<div class="submenu">
|
||||
<div class="no-bullet submenu">
|
||||
<% @valid_orders.each do |order| %>
|
||||
<%= link_to current_path_with_query_params(order: order, page: 1), class: order == @current_order ? 'active' : '' do %>
|
||||
<%= content_tag(order == @current_order ? :h2 : :span) do %>
|
||||
<%= t("#{i18n_namespace}.orders.#{order}") %>
|
||||
<li class="inline-block">
|
||||
<%= link_to current_path_with_query_params(order: order, page: 1), class: order == @current_order ? 'active' : '' do %>
|
||||
<%= content_tag(order == @current_order ? :h2 : :span) do %>
|
||||
<%= t("#{i18n_namespace}.orders.#{order}") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
@@ -2,22 +2,36 @@
|
||||
<ul>
|
||||
<% if feature?(:debates) %>
|
||||
<li>
|
||||
<%= link_to t("layouts.header.debates"), debates_path, class: ("active" if controller_name == "debates"), accesskey: "d" %>
|
||||
<%= layout_menu_link_to t("layouts.header.debates"),
|
||||
debates_path,
|
||||
controller_name == 'debates',
|
||||
accesskey: "d" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li>
|
||||
<%= link_to t("layouts.header.proposals"), proposals_path, class: ("active" if controller_name == "proposals"), accesskey: "p" %>
|
||||
<%= layout_menu_link_to t("layouts.header.proposals"),
|
||||
proposals_path,
|
||||
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" %>
|
||||
<%= layout_menu_link_to t("layouts.header.proposal_ballot"),
|
||||
proposal_ballots_path,
|
||||
controller_name == 'proposal_ballots',
|
||||
accesskey: "v" %>
|
||||
</li>
|
||||
<% if feature?(:spending_proposals) %>
|
||||
<li>
|
||||
<%= link_to t("layouts.header.budgets"), budgets_path, class: ("active" if controller_name == "budgets"), accesskey: "s" %>
|
||||
<%= layout_menu_link_to t("layouts.header.spending_proposals"),
|
||||
spending_proposals_path,
|
||||
controller_name == 'spending_proposals',
|
||||
accesskey: "s" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if feature?(:budgets) %>
|
||||
<li>
|
||||
<%= link_to t("layouts.header.budgets"), budgets_path, class: ("active" if controller_name == "budgets"), accesskey: "b" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li>
|
||||
<%= link_to t("layouts.header.more_information"), page_path('more_information'), class: ("active" if current_page?("/more_information")), accesskey: "i" %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%- limit ||= nil %>
|
||||
|
||||
<% if taggable.tags.any? %>
|
||||
<ul id="tags" class="no-bullet tags">
|
||||
<ul id="tags_<%= dom_id(taggable) %>" class="no-bullet tags">
|
||||
<% taggable.tag_list_with_limit(limit).each do |tag| %>
|
||||
<li class="inline-block"><%= link_to sanitize(tag.name), send("#{taggable.class.name.underscore.pluralize}_path", search: tag.name) %></li>
|
||||
<% end %>
|
||||
|
||||
@@ -2,8 +2,26 @@
|
||||
<div class="row">
|
||||
<%= render "shared/locale_switcher" %>
|
||||
<ul class="no-bullet external-links">
|
||||
<li class="inline-block"><%= link_to t("layouts.header.external_link_transparency"), t("layouts.header.external_link_transparency_url") %> |</li>
|
||||
<li class="inline-block"><%= link_to t("layouts.header.external_link_opendata"), "/opendata", class: ("selected" if current_page?("/opendata")) %></li>
|
||||
<li class="inline-block">
|
||||
<%= link_to t("layouts.header.more_information"),
|
||||
page_path('more_information'),
|
||||
class: ("selected" if current_page?("/more_information")),
|
||||
accesskey: "i" %>
|
||||
|
|
||||
</li>
|
||||
<li class="inline-block">
|
||||
<%= link_to t("layouts.header.external_link_transparency"),
|
||||
t("layouts.header.external_link_transparency_url"),
|
||||
target: "_blank",
|
||||
title: t('shared.target_blank_html') %>
|
||||
|
|
||||
</li>
|
||||
<li class="inline-block">
|
||||
<%= link_to t("layouts.header.external_link_opendata"),
|
||||
t("layouts.header.external_link_opendata_url"),
|
||||
target: "_blank",
|
||||
title: t('shared.target_blank_html') %>
|
||||
</li>
|
||||
<% if setting['blog_url'] %>
|
||||
<li class="inline-block">|
|
||||
<%= link_to setting['blog_url'], title: t('shared.target_blank_html'), target: "_blank" do %>
|
||||
|
||||
@@ -97,6 +97,8 @@ ignore_missing:
|
||||
- 'budget.*'
|
||||
- 'budgets.*'
|
||||
- 'unauthorized.*'
|
||||
- 'activerecord.models.proposal'
|
||||
- 'activerecord.models.spending_proposal'
|
||||
- 'activerecord.errors.models.proposal_notification.*'
|
||||
- 'activerecord.errors.models.direct_message.*'
|
||||
- 'errors.messages.blank'
|
||||
|
||||
@@ -12,7 +12,11 @@ Devise.setup do |config|
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class
|
||||
# with default "from" parameter.
|
||||
config.mailer_sender = 'noreply@consul.es'
|
||||
if Rails.env.test?
|
||||
config.mailer_sender = "noreply@example.org"
|
||||
else
|
||||
config.mailer_sender = "#{Setting['mailer_from_name']} <#{Setting['mailer_from_address']}>"
|
||||
end
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
config.mailer = 'DeviseMailer'
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
ActsAsVotable::Vote.class_eval do
|
||||
belongs_to :signature
|
||||
|
||||
def self.for_debates(debates)
|
||||
where(votable_type: 'Debate', votable_id: debates)
|
||||
end
|
||||
@@ -18,4 +20,5 @@ ActsAsVotable::Vote.class_eval do
|
||||
def value
|
||||
vote_flag
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -81,6 +81,10 @@ en:
|
||||
external_url: "Link to additional documentation"
|
||||
geozone_id: "Scope of operation"
|
||||
title: "Title"
|
||||
signature_sheet:
|
||||
signable_type: "Signable type"
|
||||
signable_id: "Signable ID"
|
||||
document_numbers: "Documents numbers"
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
@@ -103,3 +107,8 @@ en:
|
||||
attributes:
|
||||
minimum_interval:
|
||||
invalid: "You have to wait a minium of %{interval} days between notifications"
|
||||
signature:
|
||||
attributes:
|
||||
document_number:
|
||||
not_in_census: 'Not verified by Census'
|
||||
already_voted: 'Already voted this proposal'
|
||||
|
||||
@@ -81,6 +81,10 @@ es:
|
||||
external_url: "Enlace a documentación adicional"
|
||||
geozone_id: "Ámbito de actuación"
|
||||
title: "Título"
|
||||
signature_sheet:
|
||||
signable_type: "Tipo de hoja de firmas"
|
||||
signable_id: "ID Propuesta ciudadana/Propuesta inversión"
|
||||
document_numbers: "Números de documentos"
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
@@ -102,4 +106,9 @@ es:
|
||||
proposal_notification:
|
||||
attributes:
|
||||
minimum_interval:
|
||||
invalid: "Debes esperar un mínimo de %{interval} días entre notificaciones"
|
||||
invalid: "Debes esperar un mínimo de %{interval} días entre notificaciones"
|
||||
signature:
|
||||
attributes:
|
||||
document_number:
|
||||
not_in_census: 'No verificado por Padrón'
|
||||
already_voted: 'Ya ha votado esta propuesta'
|
||||
@@ -175,6 +175,7 @@ en:
|
||||
banner: Manage banners
|
||||
budgets: Participatory budgets
|
||||
debate_topics: Debate topics
|
||||
geozones: Manage geozones
|
||||
hidden_comments: Hidden comments
|
||||
hidden_debates: Hidden debates
|
||||
hidden_proposals: Hidden proposals
|
||||
@@ -188,6 +189,7 @@ en:
|
||||
settings: Configuration settings
|
||||
spending_proposals: Spending proposals
|
||||
stats: Statistics
|
||||
signature_sheets: Signature Sheets
|
||||
moderators:
|
||||
index:
|
||||
title: Moderators
|
||||
@@ -345,6 +347,57 @@ en:
|
||||
in_evaluation_count: In evaluation
|
||||
total_count: Total
|
||||
cost_for_geozone: Cost
|
||||
geozones:
|
||||
index:
|
||||
title: Geozone
|
||||
create: Create geozone
|
||||
edit: Edit
|
||||
delete: Delete
|
||||
geozone:
|
||||
name: Name
|
||||
external_code: External code
|
||||
census_code: Census code
|
||||
coordinates: Coordinates
|
||||
errors:
|
||||
form:
|
||||
error:
|
||||
one: "prevented this geozone from being saved"
|
||||
other: 'prevented this geozone from being saved'
|
||||
edit:
|
||||
form:
|
||||
submit_button: Save changes
|
||||
editing: Editing geozone
|
||||
back: Go back
|
||||
new:
|
||||
back: Go back
|
||||
creating: Create district
|
||||
delete:
|
||||
success: Geozone successfully deleted
|
||||
error: This geozone can't be deleted since there are elements attached to it
|
||||
signature_sheets:
|
||||
author: Author
|
||||
created_at: Creation date
|
||||
name: Name
|
||||
no_signature_sheets: "There are not signature_sheets"
|
||||
index:
|
||||
title: Signature sheets
|
||||
new: New signature sheets
|
||||
new:
|
||||
title: New signature sheets
|
||||
document_numbers_note: "Write the numbers separated by commas (,)"
|
||||
submit: Create signature sheet
|
||||
show:
|
||||
created_at: Created
|
||||
author: Author
|
||||
documents: Documents
|
||||
verified:
|
||||
one: "There is %{count} valid signature"
|
||||
other: "There are %{count} valid signatures"
|
||||
unverified:
|
||||
one: "There is %{count} invalid signature"
|
||||
other: "There are %{count} invalid signatures"
|
||||
unverified_error: (Not verified by Census)
|
||||
loading: "There are still signatures that are being verified by the Census, please refresh the page in a few moments"
|
||||
stats:
|
||||
show:
|
||||
stats_title: Stats
|
||||
|
||||
@@ -175,6 +175,7 @@ es:
|
||||
banner: Gestionar banners
|
||||
budgets: Presupuestos participativos
|
||||
debate_topics: Temas de debate
|
||||
geozones: Gestionar distritos
|
||||
hidden_comments: Comentarios ocultos
|
||||
hidden_debates: Debates ocultos
|
||||
hidden_proposals: Propuestas ocultas
|
||||
@@ -188,6 +189,7 @@ es:
|
||||
settings: Configuración global
|
||||
spending_proposals: Propuestas de inversión
|
||||
stats: Estadísticas
|
||||
signature_sheets: Hojas de firmas
|
||||
moderators:
|
||||
index:
|
||||
title: Moderadores
|
||||
@@ -345,6 +347,57 @@ es:
|
||||
in_evaluation_count: En evaluación
|
||||
total_count: Total
|
||||
cost_for_geozone: Coste total
|
||||
geozones:
|
||||
index:
|
||||
title: Distritos
|
||||
create: Crear un distrito
|
||||
edit: Editar
|
||||
delete: Borrar
|
||||
geozone:
|
||||
name: Nombre
|
||||
external_code: Código externo
|
||||
census_code: Código del censo
|
||||
coordinates: Coordenadas
|
||||
errors:
|
||||
form:
|
||||
error:
|
||||
one: "error impidió guardar el distrito"
|
||||
other: "errores impidieron guardar el distrito."
|
||||
edit:
|
||||
form:
|
||||
submit_button: Guardar cambios
|
||||
editing: Editando distrito
|
||||
back: Volver
|
||||
new:
|
||||
back: Volver
|
||||
creating: Crear distrito
|
||||
delete:
|
||||
success: Distrito borrado correctamente
|
||||
error: No se puede borrar el distrito porque ya tiene elementos asociados
|
||||
signature_sheets:
|
||||
author: Autor
|
||||
created_at: Fecha de creación
|
||||
name: Nombre
|
||||
no_signature_sheets: "No existen hojas de firmas"
|
||||
index:
|
||||
title: Hojas de firmas
|
||||
new: Nueva hoja de firmas
|
||||
new:
|
||||
title: Nueva hoja de firmas
|
||||
document_numbers_note: "Introduce los números separados por comas (,)"
|
||||
submit: Crear hoja de firmas
|
||||
show:
|
||||
created_at: Creado
|
||||
author: Autor
|
||||
documents: Documentos
|
||||
verified:
|
||||
one: "Hay %{count} firma válida"
|
||||
other: "Hay %{count} firmas válidas"
|
||||
unverified:
|
||||
one: "Hay %{count} firma inválida"
|
||||
other: "Hay %{count} firmas inválidas"
|
||||
unverified_error: (No verificadas por el Padrón)
|
||||
loading: "Aún hay firmas que se están verificando por el Padrón, por favor refresca la página en unos instantes"
|
||||
stats:
|
||||
show:
|
||||
stats_title: Estadísticas
|
||||
|
||||
@@ -163,6 +163,7 @@ en:
|
||||
spending_proposal: Spending proposal
|
||||
user: Account
|
||||
verification/sms: phone
|
||||
signature_sheet: Signature sheet
|
||||
geozones:
|
||||
none: All city
|
||||
all: All scopes
|
||||
@@ -198,6 +199,7 @@ en:
|
||||
debates: Debates
|
||||
external_link_blog: Blog
|
||||
external_link_opendata: Open data
|
||||
external_link_opendata_url: "/opendata"
|
||||
external_link_transparency: Transparency
|
||||
external_link_transparency_url: https://transparency.consul
|
||||
locale: 'Language:'
|
||||
@@ -216,7 +218,6 @@ en:
|
||||
open: open
|
||||
open_city_slogan_html: There are cities that are governed directly by their inhabitants, who <b>discuss</b> the topics they are concerned about, <b>propose</b> ideas to improve their lives and <b>decide</b> among themselves which ones will be carried out.
|
||||
open_city_title: Love the city, and it will become a city you love.
|
||||
open_data: Open data
|
||||
open_gov: Open government
|
||||
proposals: Proposals
|
||||
proposal_ballot: Voting
|
||||
@@ -460,6 +461,7 @@ en:
|
||||
districts_list: "Districts list"
|
||||
categories: "Categories"
|
||||
target_blank_html: " (link opens in new window)"
|
||||
you_are_in: "You are in"
|
||||
unflag: Unflag
|
||||
outline:
|
||||
debates: Debates
|
||||
|
||||
@@ -163,6 +163,7 @@ es:
|
||||
spending_proposal: la propuesta de gasto
|
||||
user: la cuenta
|
||||
verification/sms: el teléfono
|
||||
signature_sheet: la hoja de firmas
|
||||
geozones:
|
||||
none: Toda la ciudad
|
||||
all: Todos los ámbitos de actuación
|
||||
@@ -198,6 +199,7 @@ es:
|
||||
debates: Debates
|
||||
external_link_blog: Blog
|
||||
external_link_opendata: Datos abiertos
|
||||
external_link_opendata_url: "/opendata"
|
||||
external_link_transparency: Transparencia
|
||||
external_link_transparency_url: https://transparency.consul
|
||||
locale: 'Idioma:'
|
||||
@@ -216,7 +218,6 @@ es:
|
||||
open: abierto
|
||||
open_city_slogan_html: Existen ciudades gobernadas directamente por sus habitantes, que <strong>debaten</strong> sobre temas que les preocupan, <strong>proponen</strong> ideas para mejorar sus vidas y <strong>deciden</strong> entre todas y todos las que se llevan a cabo.
|
||||
open_city_title: La ciudad que quieres será la ciudad que quieras.
|
||||
open_data: Datos abiertos
|
||||
open_gov: Gobierno %{open}
|
||||
proposals: Propuestas
|
||||
proposal_ballot: Votaciones
|
||||
@@ -460,6 +461,7 @@ es:
|
||||
districts_list: "Listado de distritos"
|
||||
categories: "Categorías"
|
||||
target_blank_html: " (se abre en ventana nueva)"
|
||||
you_are_in: "Estás en"
|
||||
unflag: Deshacer denuncia
|
||||
outline:
|
||||
debates: Debates
|
||||
|
||||
@@ -10,6 +10,7 @@ en:
|
||||
proposal_notification: "Your message has been sent correctly."
|
||||
spending_proposal: "Spending proposal created successfully. You can access it from %{activity}"
|
||||
budget_investment: "Budget Investment created successfully. You can access it from %{activity}"
|
||||
signature_sheet: "Signature sheet created successfully"
|
||||
save_changes:
|
||||
notice: Changes saved
|
||||
update:
|
||||
|
||||
@@ -10,6 +10,7 @@ es:
|
||||
proposal_notification: "Tu message ha sido enviado correctamente."
|
||||
spending_proposal: "Propuesta de inversión creada correctamente. Puedes acceder a ella desde %{activity}"
|
||||
budget_investment: "Inversión creada correctamente. Puedes verla desde %{activity}"
|
||||
signature_sheet: "Hoja de firmas creada correctamente"
|
||||
save_changes:
|
||||
notice: Cambios guardados
|
||||
update:
|
||||
|
||||
@@ -28,6 +28,9 @@ en:
|
||||
facebook_login: Facebook login
|
||||
google_login: Google login
|
||||
debates: Debates
|
||||
signature_sheets: Signature sheets
|
||||
spending_proposals: Investment projects
|
||||
spending_proposal_features:
|
||||
voting_allowed: Voting on investment projects
|
||||
mailer_from_name: Origin email name
|
||||
mailer_from_address: Origin email address
|
||||
|
||||
@@ -28,6 +28,9 @@ es:
|
||||
facebook_login: Registro con Facebook
|
||||
google_login: Registro con Google
|
||||
debates: Debates
|
||||
signature_sheets: Hojas de firmas
|
||||
spending_proposals: Propuestas de inversión
|
||||
spending_proposal_features:
|
||||
voting_allowed: Votaciones sobre propuestas de inversión
|
||||
mailer_from_name: Nombre email remitente
|
||||
mailer_from_address: Dirección email remitente
|
||||
|
||||
@@ -168,6 +168,8 @@ Rails.application.routes.draw do
|
||||
resources :budget_investments, only: [:index, :show, :edit, :update]
|
||||
end
|
||||
|
||||
resources :signature_sheets, only: [:index, :new, :create, :show]
|
||||
|
||||
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||
collection { get :search}
|
||||
end
|
||||
@@ -211,6 +213,8 @@ Rails.application.routes.draw do
|
||||
namespace :api do
|
||||
resource :stats, only: :show
|
||||
end
|
||||
|
||||
resources :geozones, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||
end
|
||||
|
||||
namespace :moderation do
|
||||
|
||||
@@ -31,11 +31,15 @@ Setting.create(key: 'feature.budgets', value: "true")
|
||||
Setting.create(key: 'feature.twitter_login', value: "true")
|
||||
Setting.create(key: 'feature.facebook_login', value: "true")
|
||||
Setting.create(key: 'feature.google_login', value: "true")
|
||||
Setting.create(key: 'feature.signature_sheets', value: "true")
|
||||
Setting.create(key: 'per_page_code', value: "")
|
||||
Setting.create(key: 'comments_body_max_length', value: '1000')
|
||||
Setting.create(key: 'mailer_from_name', value: 'Consul')
|
||||
Setting.create(key: 'mailer_from_address', value: 'noreply@consul.dev')
|
||||
|
||||
|
||||
puts "Creating Geozones"
|
||||
('A'..'Z').each{ |i| Geozone.create(name: "District #{i}") }
|
||||
('A'..'Z').each { |i| Geozone.create(name: "District #{i}", external_code: i.ord, census_code: i.ord) }
|
||||
|
||||
puts "Creating Users"
|
||||
|
||||
|
||||
11
db/migrate/20161214212918_create_signature_sheets.rb
Normal file
11
db/migrate/20161214212918_create_signature_sheets.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateSignatureSheets < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :signature_sheets do |t|
|
||||
t.references :signable, polymorphic: true
|
||||
t.text :document_numbers
|
||||
t.boolean :processed, default: false
|
||||
t.references :author
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/migrate/20161214233817_create_signatures.rb
Normal file
11
db/migrate/20161214233817_create_signatures.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateSignatures < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :signatures do |t|
|
||||
t.references :signature_sheet
|
||||
t.references :user
|
||||
t.string :document_number
|
||||
t.boolean :verified, default: false
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20161221131403_add_signture_id_to_votes.rb
Normal file
5
db/migrate/20161221131403_add_signture_id_to_votes.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddSigntureIdToVotes < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :votes, :signature, index: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddCreatedFromSignatureToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :created_from_signature, :boolean, default: false
|
||||
end
|
||||
end
|
||||
24
db/schema.rb
24
db/schema.rb
@@ -414,6 +414,25 @@ ActiveRecord::Schema.define(version: 20161221172447) do
|
||||
|
||||
add_index "settings", ["key"], name: "index_settings_on_key", using: :btree
|
||||
|
||||
create_table "signature_sheets", force: :cascade do |t|
|
||||
t.integer "signable_id"
|
||||
t.string "signable_type"
|
||||
t.text "document_numbers"
|
||||
t.boolean "processed", default: false
|
||||
t.integer "author_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "signatures", force: :cascade do |t|
|
||||
t.integer "signature_sheet_id"
|
||||
t.integer "user_id"
|
||||
t.string "document_number"
|
||||
t.boolean "verified", default: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "spending_proposals", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
@@ -553,7 +572,8 @@ ActiveRecord::Schema.define(version: 20161221172447) do
|
||||
t.boolean "email_digest", default: true
|
||||
t.boolean "email_on_direct_message", default: true
|
||||
t.boolean "official_position_badge", default: false
|
||||
t.datetime "password_changed_at", default: '2016-11-02 13:51:14', null: false
|
||||
t.datetime "password_changed_at", default: '2016-12-21 17:55:08', null: false
|
||||
t.boolean "created_from_signature", default: false
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||
@@ -634,8 +654,10 @@ ActiveRecord::Schema.define(version: 20161221172447) do
|
||||
t.integer "vote_weight"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "signature_id"
|
||||
end
|
||||
|
||||
add_index "votes", ["signature_id"], name: "index_votes_on_signature_id", using: :btree
|
||||
add_index "votes", ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope", using: :btree
|
||||
add_index "votes", ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope", using: :btree
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ Setting['feature.facebook_login'] = true
|
||||
Setting['feature.google_login'] = true
|
||||
Setting['feature.public_stats'] = true
|
||||
Setting['feature.budgets'] = true
|
||||
Setting['feature.signature_sheets'] = true
|
||||
|
||||
# Spending proposals feature flags
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
@@ -82,3 +83,7 @@ Setting['banner-img.banner-img-three'] = "Banner image 3"
|
||||
# Proposal notifications
|
||||
Setting['proposal_notification_minimum_interval_in_days'] = 3
|
||||
Setting['direct_message_max_per_day'] = 3
|
||||
|
||||
# Email settings
|
||||
Setting['mailer_from_name'] = 'Consul'
|
||||
Setting['mailer_from_address'] = 'noreply@consul.dev'
|
||||
|
||||
@@ -74,7 +74,7 @@ class CensusApi
|
||||
if end_point_available?
|
||||
client.call(:get_habita_datos, message: request(document_type, document_number)).body
|
||||
else
|
||||
stubbed_response_body
|
||||
stubbed_response(document_type, document_number)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -97,8 +97,20 @@ class CensusApi
|
||||
Rails.env.staging? || Rails.env.preproduction? || Rails.env.production?
|
||||
end
|
||||
|
||||
def stubbed_response_body
|
||||
{get_habita_datos_response: {get_habita_datos_return: {hay_errores: false, datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
|
||||
def stubbed_response(document_type, document_number)
|
||||
if document_number == "12345678Z" && document_type == "1"
|
||||
stubbed_valid_response
|
||||
else
|
||||
stubbed_invalid_response
|
||||
end
|
||||
end
|
||||
|
||||
def stubbed_valid_response
|
||||
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón", nombre: "José", apellido1: "García" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
|
||||
end
|
||||
|
||||
def stubbed_invalid_response
|
||||
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {}, datos_vivienda: {}}}}
|
||||
end
|
||||
|
||||
def is_dni?(document_type)
|
||||
|
||||
@@ -394,7 +394,8 @@ FactoryGirl.define do
|
||||
|
||||
factory :geozone do
|
||||
sequence(:name) { |n| "District #{n}" }
|
||||
census_code { '01' }
|
||||
sequence(:external_code) { |n| "#{n}" }
|
||||
sequence(:census_code) { |n| "#{n}" }
|
||||
end
|
||||
|
||||
factory :banner do
|
||||
@@ -420,4 +421,14 @@ FactoryGirl.define do
|
||||
association :receiver, factory: :user
|
||||
end
|
||||
|
||||
factory :signature_sheet do
|
||||
association :signable, factory: :proposal
|
||||
association :author, factory: :user
|
||||
document_numbers "123A, 456B, 789C"
|
||||
end
|
||||
|
||||
factory :signature do
|
||||
signature_sheet
|
||||
sequence(:document_number) { |n| "#{n}A" }
|
||||
end
|
||||
end
|
||||
|
||||
100
spec/features/admin/geozones_spec.rb
Normal file
100
spec/features/admin/geozones_spec.rb
Normal file
@@ -0,0 +1,100 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Admin geozones' do
|
||||
|
||||
background do
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario 'Show list of geozones' do
|
||||
chamberi = create(:geozone, name: 'Chamberí')
|
||||
retiro = create(:geozone, name: 'Retiro')
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
expect(page).to have_content(chamberi.name)
|
||||
expect(page).to have_content(retiro.name)
|
||||
end
|
||||
|
||||
scenario 'Create new geozone' do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') { click_link 'Manage geozones' }
|
||||
|
||||
click_link 'Create geozone'
|
||||
|
||||
fill_in 'geozone_name', with: 'Fancy District'
|
||||
fill_in 'geozone_external_code', with: 123
|
||||
fill_in 'geozone_census_code', with: 44
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content 'Fancy District'
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
expect(page).to have_content 'Fancy District'
|
||||
end
|
||||
|
||||
scenario 'Edit geozone with no associated elements' do
|
||||
geozone = create(:geozone, name: 'Edit me!', census_code: '012')
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Edit' }
|
||||
|
||||
fill_in 'geozone_name', with: 'New geozone name'
|
||||
fill_in 'geozone_census_code', with: '333'
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
within("#geozone_#{geozone.id}") do
|
||||
expect(page).to have_content 'New geozone name'
|
||||
expect(page).to have_content '333'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Edit geozone with associated elements' do
|
||||
geozone = create(:geozone, name: 'Edit me!')
|
||||
create(:proposal, title: 'Proposal with geozone', geozone: geozone)
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Edit' }
|
||||
|
||||
fill_in 'geozone_name', with: 'New geozone name'
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
within("#geozone_#{geozone.id}") do
|
||||
expect(page).to have_content 'New geozone name'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete geozone with no associated elements' do
|
||||
geozone = create(:geozone, name: 'Delete me!')
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||
|
||||
expect(page).to have_content 'Geozone successfully deleted'
|
||||
expect(page).not_to have_content('Delete me!')
|
||||
expect(Geozone.where(id: geozone.id)).to be_empty
|
||||
end
|
||||
|
||||
scenario 'Delete geozone with associated element' do
|
||||
geozone = create(:geozone, name: 'Delete me!')
|
||||
create(:proposal, geozone: geozone)
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||
|
||||
expect(page).to have_content "This geozone can't be deleted since there are elements attached to it"
|
||||
|
||||
within("#geozone_#{geozone.id}") do
|
||||
expect(page).to have_content 'Delete me!'
|
||||
end
|
||||
end
|
||||
end
|
||||
71
spec/features/admin/signature_sheets_spec.rb
Normal file
71
spec/features/admin/signature_sheets_spec.rb
Normal file
@@ -0,0 +1,71 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Signature sheets' do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
3.times { create(:signature_sheet) }
|
||||
|
||||
visit admin_signature_sheets_path
|
||||
|
||||
expect(page).to have_css(".signature_sheet", count: 3)
|
||||
|
||||
SignatureSheet.all.each do |signature_sheet|
|
||||
expect(page).to have_content signature_sheet.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
proposal = create(:proposal)
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
select "Citizen proposal", from: "signature_sheet_signable_type"
|
||||
fill_in "signature_sheet_signable_id", with: proposal.id
|
||||
fill_in "signature_sheet_document_numbers", with: "12345678Z, 99999999Z"
|
||||
click_button "Create signature sheet"
|
||||
|
||||
expect(page).to have_content "Signature sheet created successfully"
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
click_button "Create signature sheet"
|
||||
|
||||
expect(page).to have_content error_message
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
proposal = create(:proposal)
|
||||
user = Administrator.first.user
|
||||
signature_sheet = create(:signature_sheet,
|
||||
signable: proposal,
|
||||
document_numbers: "12345678Z, 123A, 123B",
|
||||
author: user)
|
||||
signature_sheet.verify_signatures
|
||||
|
||||
visit admin_signature_sheet_path(signature_sheet)
|
||||
|
||||
expect(page).to have_content "Citizen proposal #{proposal.id}"
|
||||
expect(page).to have_content "12345678Z, 123A, 123B"
|
||||
expect(page).to have_content signature_sheet.created_at.strftime("%d %b %H:%M")
|
||||
expect(page).to have_content user.name
|
||||
|
||||
within("#verified_signatures") do
|
||||
expect(page).to have_content 1
|
||||
end
|
||||
|
||||
within("#unverified_signatures") do
|
||||
expect(page).to have_content 2
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -232,7 +232,7 @@ feature 'Debates' do
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
|
||||
within "#tags" do
|
||||
within "#tags_debate_#{Debate.last.id}" do
|
||||
expect(page).to have_content 'Education'
|
||||
expect(page).to_not have_content 'Health'
|
||||
end
|
||||
@@ -249,7 +249,8 @@ feature 'Debates' do
|
||||
click_button 'Start a debate'
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
within "#tags" do
|
||||
|
||||
within "#tags_debate_#{Debate.last.id}" do
|
||||
expect(page).to have_content 'Refugees'
|
||||
expect(page).to have_content 'Solidarity'
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ feature 'DocumentVerifications' do
|
||||
scenario 'Verifying a user which does exists in the census but not in the db redirects allows sending an email' do
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '1234'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to have_content "Please introduce the email used on the account"
|
||||
@@ -66,7 +66,7 @@ feature 'DocumentVerifications' do
|
||||
expect_any_instance_of(Verification::Management::Document).to receive(:under_sixteen?).and_return(true)
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '1234'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to have_content "You must be over 16 to verify your account."
|
||||
|
||||
@@ -8,7 +8,7 @@ feature 'EmailVerifications' do
|
||||
user = create(:user)
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '1234'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to have_content "Please introduce the email used on the account"
|
||||
@@ -30,7 +30,7 @@ feature 'EmailVerifications' do
|
||||
expect(page).to_not have_link "Verify my account"
|
||||
expect(page).to have_content "Account verified"
|
||||
|
||||
expect(user.reload.document_number).to eq('1234')
|
||||
expect(user.reload.document_number).to eq('12345678Z')
|
||||
expect(user).to be_level_three_verified
|
||||
end
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ feature 'Managed User' do
|
||||
user = create(:user)
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '1234'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
within(".account-info") do
|
||||
@@ -66,7 +66,7 @@ feature 'Managed User' do
|
||||
expect(page).not_to have_content "Email"
|
||||
expect(page).to have_content "Document type"
|
||||
expect(page).to have_content "Document number"
|
||||
expect(page).to have_content "1234"
|
||||
expect(page).to have_content "12345678Z"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Please introduce the email used on the account"
|
||||
@@ -88,7 +88,7 @@ feature 'Managed User' do
|
||||
login_as_manager
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '1234'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to have_content "Please introduce the email used on the account"
|
||||
|
||||
@@ -9,7 +9,7 @@ feature 'Users' do
|
||||
scenario 'Create a level 3 user from scratch' do
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '1234'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to have_content "Please introduce the email used on the account"
|
||||
@@ -45,10 +45,10 @@ feature 'Users' do
|
||||
end
|
||||
|
||||
scenario 'Delete a level 2 user account from document verification page', :js do
|
||||
level_2_user = create(:user, :level_two, document_number: 13579)
|
||||
level_2_user = create(:user, :level_two, document_number: "12345678Z")
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '13579'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to_not have_content "This user account is already verified."
|
||||
@@ -62,7 +62,7 @@ feature 'Users' do
|
||||
expect(level_2_user.reload.erase_reason).to eq "Deleted by manager: manager_user_#{Manager.last.user_id}"
|
||||
|
||||
visit management_document_verifications_path
|
||||
fill_in 'document_verification_document_number', with: '13579'
|
||||
fill_in 'document_verification_document_number', with: '12345678Z'
|
||||
click_button 'Check'
|
||||
|
||||
expect(page).to have_content "no user account associated to it"
|
||||
|
||||
@@ -333,7 +333,7 @@ feature 'Proposals' do
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
|
||||
within "#tags" do
|
||||
within "#tags_proposal_#{Proposal.last.id}" do
|
||||
expect(page).to have_content 'Education'
|
||||
expect(page).to_not have_content 'Health'
|
||||
end
|
||||
@@ -355,7 +355,7 @@ feature 'Proposals' do
|
||||
click_button 'Create proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal created successfully.'
|
||||
within "#tags" do
|
||||
within "#tags_proposal_#{Proposal.last.id}" do
|
||||
expect(page).to have_content 'Refugees'
|
||||
expect(page).to have_content 'Solidarity'
|
||||
end
|
||||
|
||||
@@ -102,4 +102,24 @@ feature 'Residence' do
|
||||
expect(page).to have_content "You have reached the maximum number of attempts. Please try again later."
|
||||
expect(current_path).to eq(account_path)
|
||||
end
|
||||
|
||||
scenario 'Error when trying to verify a deregistered account' do
|
||||
create(:user, document_number: '12345678Z', document_type: '1', erased_at: Time.now)
|
||||
|
||||
login_as(create(:user))
|
||||
|
||||
visit account_path
|
||||
click_link 'Verify my account'
|
||||
|
||||
fill_in 'residence_document_number', with: "12345678Z"
|
||||
select 'DNI', from: 'residence_document_type'
|
||||
select_date '31-December-1980', from: 'residence_date_of_birth'
|
||||
fill_in 'residence_postal_code', with: '28013'
|
||||
check 'residence_terms_of_service'
|
||||
|
||||
click_button 'Verify residence'
|
||||
|
||||
expect(page).to_not have_content 'Residence verified'
|
||||
expect(page).to have_content 'has already been taken'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,4 +11,30 @@ RSpec.describe Geozone, type: :model do
|
||||
geozone.name = nil
|
||||
expect(geozone).to_not be_valid
|
||||
end
|
||||
|
||||
describe "#safe_to_destroy?" do
|
||||
it "is true when not linked to other models" do
|
||||
expect(geozone.safe_to_destroy?).to be_truthy
|
||||
end
|
||||
|
||||
it "is false when already linked to user" do
|
||||
create(:user, geozone: geozone)
|
||||
expect(geozone.safe_to_destroy?).to be_falsey
|
||||
end
|
||||
|
||||
it "is false when already linked to proposal" do
|
||||
create(:proposal, geozone: geozone)
|
||||
expect(geozone.safe_to_destroy?).to be_falsey
|
||||
end
|
||||
|
||||
it "is false when already linked to spending proposal" do
|
||||
create(:spending_proposal, geozone: geozone)
|
||||
expect(geozone.safe_to_destroy?).to be_falsey
|
||||
end
|
||||
|
||||
it "is false when already linked to debate" do
|
||||
create(:debate, geozone: geozone)
|
||||
expect(geozone.safe_to_destroy?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
81
spec/models/signature_sheet_spec.rb
Normal file
81
spec/models/signature_sheet_spec.rb
Normal file
@@ -0,0 +1,81 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe SignatureSheet do
|
||||
|
||||
let(:signature_sheet) { build(:signature_sheet) }
|
||||
|
||||
describe "validations" do
|
||||
|
||||
it "should be valid" do
|
||||
expect(signature_sheet).to be_valid
|
||||
end
|
||||
|
||||
it "should be valid with a valid signable" do
|
||||
signature_sheet.signable = create(:proposal)
|
||||
expect(signature_sheet).to be_valid
|
||||
|
||||
signature_sheet.signable = create(:spending_proposal)
|
||||
expect(signature_sheet).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without signable" do
|
||||
signature_sheet.signable = nil
|
||||
expect(signature_sheet).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a valid signable" do
|
||||
signature_sheet.signable = create(:comment)
|
||||
expect(signature_sheet).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without document numbers" do
|
||||
signature_sheet.document_numbers = nil
|
||||
expect(signature_sheet).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without an author" do
|
||||
signature_sheet.author = nil
|
||||
expect(signature_sheet).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe "#name" do
|
||||
it "returns name for proposal signature sheets" do
|
||||
proposal = create(:proposal)
|
||||
signature_sheet.signable = proposal
|
||||
|
||||
expect(signature_sheet.name).to eq("Citizen proposal #{proposal.id}")
|
||||
end
|
||||
it "returns name for spending proposal signature sheets" do
|
||||
spending_proposal = create(:spending_proposal)
|
||||
signature_sheet.signable = spending_proposal
|
||||
|
||||
expect(signature_sheet.name).to eq("Spending proposal #{spending_proposal.id}")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#verify_signatures" do
|
||||
it "creates signatures for each document number" do
|
||||
signature_sheet = create(:signature_sheet, document_numbers: "123A, 456B")
|
||||
signature_sheet.verify_signatures
|
||||
|
||||
expect(Signature.count).to eq(2)
|
||||
end
|
||||
|
||||
it "marks signature sheet as processed" do
|
||||
signature_sheet = create(:signature_sheet)
|
||||
signature_sheet.verify_signatures
|
||||
|
||||
expect(signature_sheet.processed).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parsed_document_numbers" do
|
||||
it "returns an array after spliting document numbers by newlines or commas" do
|
||||
signature_sheet.document_numbers = "123A\r\n456B\n789C,123B"
|
||||
|
||||
expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C', '123B'])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
171
spec/models/signature_spec.rb
Normal file
171
spec/models/signature_spec.rb
Normal file
@@ -0,0 +1,171 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Signature do
|
||||
|
||||
let(:signature) { build(:signature) }
|
||||
|
||||
describe "validations" do
|
||||
|
||||
it "should be valid" do
|
||||
expect(signature).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a document number" do
|
||||
signature.document_number = nil
|
||||
expect(signature).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without an associated signature sheet" do
|
||||
signature.signature_sheet = nil
|
||||
expect(signature).to_not be_valid
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#verified?" do
|
||||
|
||||
it "returns true if user exists" do
|
||||
user = create(:user, :level_two, document_number: "123A")
|
||||
signature = create(:signature, document_number: user.document_number)
|
||||
|
||||
expect(signature.verified?).to eq(true)
|
||||
end
|
||||
|
||||
it "returns true if document number in census" do
|
||||
signature = create(:signature, document_number: "12345678Z")
|
||||
|
||||
expect(signature.verified?).to eq(true)
|
||||
end
|
||||
|
||||
it "returns false if user does not exist and not in census" do
|
||||
signature = create(:signature, document_number: "123A")
|
||||
|
||||
expect(signature.verified?).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#assign_vote" do
|
||||
|
||||
describe "existing user" do
|
||||
|
||||
it "assigns vote to user" do
|
||||
user = create(:user, :level_two, document_number: "123A")
|
||||
signature = create(:signature, document_number: user.document_number)
|
||||
proposal = signature.signable
|
||||
|
||||
signature.assign_vote
|
||||
|
||||
expect(user.voted_for?(proposal)).to be
|
||||
end
|
||||
|
||||
it "does not assign vote to user multiple times" do
|
||||
user = create(:user, :level_two, document_number: "123A")
|
||||
signature = create(:signature, document_number: user.document_number)
|
||||
|
||||
signature.assign_vote
|
||||
signature.assign_vote
|
||||
|
||||
expect(Vote.count).to eq(1)
|
||||
end
|
||||
|
||||
it "does not assign vote to user if already voted" do
|
||||
proposal = create(:proposal)
|
||||
user = create(:user, :level_two, document_number: "123A")
|
||||
vote = create(:vote, votable: proposal, voter: user)
|
||||
signature_sheet = create(:signature_sheet, signable: proposal)
|
||||
signature = create(:signature, signature_sheet: signature_sheet, document_number: user.document_number)
|
||||
|
||||
signature.assign_vote
|
||||
|
||||
expect(Vote.count).to eq(1)
|
||||
end
|
||||
|
||||
it "marks the vote as coming from a signature" do
|
||||
signature = create(:signature, document_number: "12345678Z")
|
||||
|
||||
signature.assign_vote
|
||||
|
||||
expect(Vote.last.signature).to eq(signature)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "inexistent user" do
|
||||
|
||||
it "creates a user with that document number" do
|
||||
signature = create(:signature, document_number: "12345678Z")
|
||||
proposal = signature.signable
|
||||
|
||||
signature.assign_vote
|
||||
|
||||
user = User.last
|
||||
expect(user.document_number).to eq("12345678Z")
|
||||
expect(user.created_from_signature).to eq(true)
|
||||
expect(user.verified_at).to be
|
||||
expect(user.erased_at).to be
|
||||
end
|
||||
|
||||
it "assign the vote to newly created user" do
|
||||
signature = create(:signature, document_number: "12345678Z")
|
||||
proposal = signature.signable
|
||||
|
||||
signature.assign_vote
|
||||
|
||||
user = signature.user
|
||||
expect(user.voted_for?(proposal)).to be
|
||||
end
|
||||
|
||||
it "assigns signature to vote" do
|
||||
signature = create(:signature, document_number: "12345678Z")
|
||||
|
||||
signature.assign_vote
|
||||
|
||||
expect(Vote.last.signature).to eq(signature)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#verify" do
|
||||
|
||||
describe "document in census" do
|
||||
|
||||
it "calls assign_vote" do
|
||||
signature = create(:signature, document_number: "12345678Z")
|
||||
|
||||
expect(signature).to receive(:assign_vote)
|
||||
signature.verify
|
||||
end
|
||||
|
||||
it "sets signature as verified" do
|
||||
user = create(:user, :level_two, document_number: "123A")
|
||||
signature = create(:signature, document_number: user.document_number)
|
||||
|
||||
signature.verify
|
||||
|
||||
expect(signature).to be_verified
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "document not in census" do
|
||||
|
||||
it "does not call assign_vote" do
|
||||
signature = create(:signature, document_number: "123A")
|
||||
|
||||
expect(signature).to_not receive(:assign_vote)
|
||||
signature.verify
|
||||
end
|
||||
|
||||
it "maintains signature as not verified" do
|
||||
signature = create(:signature, document_number: "123A")
|
||||
|
||||
signature.verify
|
||||
expect(signature).to_not be_verified
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -336,7 +336,7 @@ describe SpendingProposal do
|
||||
|
||||
it "does not get updated if the user is erased" do
|
||||
user.erase
|
||||
expect(user.document_number).to be_blank
|
||||
expect(user.erased_at).to be
|
||||
spending_proposal.touch
|
||||
expect(spending_proposal.responsible_name).to eq("123456")
|
||||
end
|
||||
|
||||
@@ -415,48 +415,58 @@ describe User do
|
||||
end
|
||||
|
||||
describe "#erase" do
|
||||
it "anonymizes a user and marks him as hidden" do
|
||||
it "erases user information and marks him as erased" do
|
||||
user = create(:user,
|
||||
username: "manolo",
|
||||
email: "a@a.com",
|
||||
unconfirmed_email: "a@a.com",
|
||||
document_number: "1234",
|
||||
phone_number: "5678",
|
||||
confirmed_phone: "5678",
|
||||
unconfirmed_phone: "5678",
|
||||
encrypted_password: "foobar",
|
||||
confirmation_token: "token1",
|
||||
reset_password_token: "token2",
|
||||
email_verification_token: "token3",
|
||||
confirmed_phone:"5678",
|
||||
unconfirmed_phone:"5678")
|
||||
email_verification_token: "token3")
|
||||
|
||||
user.erase('a test')
|
||||
user.reload
|
||||
|
||||
expect(user.erase_reason).to eq('a test')
|
||||
expect(user.erased_at).to be
|
||||
expect(user.erased_at).to be
|
||||
|
||||
expect(user.username).to be_nil
|
||||
|
||||
expect(user.email).to be_nil
|
||||
expect(user.unconfirmed_email).to be_nil
|
||||
expect(user.document_number).to be_nil
|
||||
expect(user.phone_number).to be_nil
|
||||
expect(user.confirmed_phone).to be_nil
|
||||
expect(user.unconfirmed_phone).to be_nil
|
||||
|
||||
expect(user.encrypted_password).to be_empty
|
||||
|
||||
expect(user.confirmation_token).to be_nil
|
||||
expect(user.reset_password_token).to be_nil
|
||||
expect(user.email_verification_token).to be_nil
|
||||
|
||||
end
|
||||
|
||||
it "destroys associated identities" do
|
||||
it "maintains associated identification document" do
|
||||
user = create(:user,
|
||||
document_number: "1234",
|
||||
document_type: "1")
|
||||
user.erase
|
||||
user.reload
|
||||
|
||||
expect(user.erased_at).to be
|
||||
expect(user.document_number).to be
|
||||
expect(user.document_type).to be
|
||||
end
|
||||
|
||||
it "destroys associated social network identities" do
|
||||
user = create(:user)
|
||||
identity = create(:identity, user: user)
|
||||
|
||||
user.erase('an identity test')
|
||||
|
||||
expect(Identity.exists?(identity.id)).to_not be
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user