Merge pull request #763 from AjuntamentdeBarcelona/make_consul_location_agnostic
Parameterize brand and social links
This commit is contained in:
@@ -53,7 +53,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def set_official_position
|
def set_official_position
|
||||||
resource.add_official_position! (Setting.value_for 'official_level_1_name'), 1
|
resource.add_official_position! (Setting['official_level_1_name']), 1
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module AdminHelper
|
|||||||
def official_level_options
|
def official_level_options
|
||||||
options = [["",0]]
|
options = [["",0]]
|
||||||
(1..5).each do |i|
|
(1..5).each do |i|
|
||||||
options << [[t("admin.officials.level_#{i}"), Setting.value_for("official_level_#{i}_name")].compact.join(': '), i]
|
options << [[t("admin.officials.level_#{i}"), Setting["official_level_#{i}_name"]].compact.join(': '), i]
|
||||||
end
|
end
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class Debate < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def editable?
|
def editable?
|
||||||
total_votes <= Setting.value_for('max_votes_for_debate_edit').to_i
|
total_votes <= Setting['max_votes_for_debate_edit'].to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def editable_by?(user)
|
def editable_by?(user)
|
||||||
@@ -93,8 +93,8 @@ class Debate < ActiveRecord::Base
|
|||||||
return false unless user
|
return false unless user
|
||||||
total_votes <= 100 ||
|
total_votes <= 100 ||
|
||||||
!user.unverified? ||
|
!user.unverified? ||
|
||||||
Setting.value_for('max_ratio_anon_votes_on_debates').to_i == 100 ||
|
Setting['max_ratio_anon_votes_on_debates'].to_i == 100 ||
|
||||||
anonymous_votes_ratio < Setting.value_for('max_ratio_anon_votes_on_debates').to_i ||
|
anonymous_votes_ratio < Setting['max_ratio_anon_votes_on_debates'].to_i ||
|
||||||
user.voted_for?(self)
|
user.voted_for?(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class Proposal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def editable?
|
def editable?
|
||||||
total_votes <= Setting.value_for("max_votes_for_proposal_edit").to_i
|
total_votes <= Setting["max_votes_for_proposal_edit"].to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def editable_by?(user)
|
def editable_by?(user)
|
||||||
@@ -98,7 +98,7 @@ class Proposal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def code
|
def code
|
||||||
"#{Setting.value_for("proposal_code_prefix")}-#{created_at.strftime('%Y-%m')}-#{id}"
|
"#{Setting["proposal_code_prefix"]}-#{created_at.strftime('%Y-%m')}-#{id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_commented
|
def after_commented
|
||||||
@@ -129,7 +129,7 @@ class Proposal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.votes_needed_for_success
|
def self.votes_needed_for_success
|
||||||
Setting.value_for('votes_for_proposal_success').to_i
|
Setting['votes_for_proposal_success'].to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|||||||
@@ -3,7 +3,16 @@ class Setting < ActiveRecord::Base
|
|||||||
|
|
||||||
default_scope { order(id: :asc) }
|
default_scope { order(id: :asc) }
|
||||||
|
|
||||||
def self.value_for(key)
|
class << self
|
||||||
where(key: key).pluck(:value).first
|
def [](key)
|
||||||
|
where(key: key).pluck(:value).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def []=(key, value)
|
||||||
|
setting = where(key: key).first || new(key: key)
|
||||||
|
setting.value = value
|
||||||
|
setting.save!
|
||||||
|
value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_official_email?
|
def has_official_email?
|
||||||
domain = Setting.value_for 'email_domain_for_officials'
|
domain = Setting['email_domain_for_officials']
|
||||||
!email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") )
|
!email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<li class="name">
|
<li class="name">
|
||||||
<%= link_to root_path do %>
|
<%= link_to root_path do %>
|
||||||
<%= image_tag('header_logo_madrid.png', class: 'left', size: '96x96', alt: t("layouts.header.logo")) %>
|
<%= image_tag('header_logo_madrid.png', class: 'left', size: '96x96', alt: t("layouts.header.logo")) %>
|
||||||
<%= t("layouts.header.participation_html") %> <span>|</span> <span class="logo-site"><%= t("admin.dashboard.index.title") %></span>
|
<%= Setting['org_name'] %> <span>|</span> <span class="logo-site"><%= t("admin.dashboard.index.title") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
|
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
|
||||||
|
|||||||
@@ -53,21 +53,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-3 column social">
|
<div class="small-12 medium-3 column social">
|
||||||
<%= link_to "https://twitter.com/abriendomadrid", target: "_blank", title: t("social.twitter") do %>
|
<% if Setting['twitter_handle'] %>
|
||||||
<span class="sr-only"><%= t("social.twitter") %></span>
|
<%= link_to "https://twitter.com/#{Setting['twitter_handle']}", target: "_blank", title: t("social.twitter") do %>
|
||||||
<i class="icon-twitter"></i>
|
<span class="sr-only"><%= t("social.twitter") %></span>
|
||||||
|
<i class="icon-twitter"></i>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to "https://www.facebook.com/Abriendo-Madrid-1475577616080350/", target: "_blank", title: t("social.facebook") do %>
|
<% if Setting['facebook_handle'] %>
|
||||||
<span class="sr-only"><%= t("social.facebook") %></span>
|
<%= link_to "https://www.facebook.com/#{Setting['facebook_handle']}/", target: "_blank", title: t("social.facebook") do %>
|
||||||
<i class="icon-facebook"></i>
|
<span class="sr-only"><%= t("social.facebook") %></span>
|
||||||
|
<i class="icon-facebook"></i>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to "/blog", target: "_blank", title: t("social.blog") do %>
|
<% if Setting['blog_url'] %>
|
||||||
<span class="sr-only"><%= t("social.blog") %></span>
|
<%= link_to Setting['blog_url'], target: "_blank", title: t("social.blog") do %>
|
||||||
<i class="icon-blog"></i>
|
<span class="sr-only"><%= t("social.blog") %></span>
|
||||||
|
<i class="icon-blog"></i>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to "https://www.youtube.com/channel/UCFmaChI9quIY7lwHplnacfg", target: "_blank", title: t("social.youtube") do %>
|
<% if Setting['youtube_handle'] %>
|
||||||
<span class="sr-only"><%= t("social.youtube") %></span>
|
<%= link_to "https://www.youtube.com/#{Setting['youtube_handle']}", target: "_blank", title: t("social.youtube") do %>
|
||||||
<i class="icon-youtube"></i>
|
<span class="sr-only"><%= t("social.youtube") %></span>
|
||||||
|
<i class="icon-youtube"></i>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<%= render "shared/locale_switcher" %>
|
<%= render "shared/locale_switcher" %>
|
||||||
<div class="external-links">
|
<div class="external-links">
|
||||||
<%= link_to t("layouts.header.participation_html"), root_path, class: ("selected" unless current_page?("/opendata")) %> |
|
<%= link_to Setting['org_name'], root_path, class: ("selected" unless current_page?("/opendata")) %> |
|
||||||
<%= link_to t("layouts.header.external_link_transparency"), t("layouts.header.external_link_transparency_url") %> |
|
<%= link_to t("layouts.header.external_link_transparency"), t("layouts.header.external_link_transparency_url") %> |
|
||||||
<%= link_to t("layouts.header.external_link_opendata"), "/opendata", class: ("selected" if current_page?("/opendata")) %>
|
<%= link_to t("layouts.header.external_link_opendata"), "/opendata", class: ("selected" if current_page?("/opendata")) %>
|
||||||
</div>
|
</div>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<%= t("layouts.header.open_gov", open: "#{t('layouts.header.open')}") %> <span>|</span>
|
<%= t("layouts.header.open_gov", open: "#{t('layouts.header.open')}") %> <span>|</span>
|
||||||
<span class="logo-site"><%= t("layouts.header.open_data") %></span>
|
<span class="logo-site"><%= t("layouts.header.open_data") %></span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= t("layouts.header.participation_html") %>
|
<%= Setting['org_name'] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
@@ -39,9 +39,11 @@
|
|||||||
<%= link_to t("layouts.header.proposals"), proposals_path, class: ("active" if controller_name == "proposals") %>
|
<%= link_to t("layouts.header.proposals"), proposals_path, class: ("active" if controller_name == "proposals") %>
|
||||||
<%= link_to t("layouts.header.spending_proposals"), spending_proposals_path, class: ("active" if controller_name == "spending_proposals") %>
|
<%= link_to t("layouts.header.spending_proposals"), spending_proposals_path, class: ("active" if controller_name == "spending_proposals") %>
|
||||||
<%= link_to t("layouts.header.more_information"), page_path('more_information'), class: ("active" if current_page?("/more_information")) %>
|
<%= link_to t("layouts.header.more_information"), page_path('more_information'), class: ("active" if current_page?("/more_information")) %>
|
||||||
<%= link_to t("layouts.header.external_link_blog_url"), target: "_blank" do %>
|
<% if Setting['blog_url'] %>
|
||||||
<%= t("layouts.header.external_link_blog") %>
|
<%= link_to Setting['blog_url'], target: "_blank" do %>
|
||||||
<small><i class="icon-external"></i></small>
|
<%= t("layouts.header.external_link_blog") %>
|
||||||
|
<i class="icon-external"></i>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<title><%= content_for?(:title) ? yield(:title) : "Gobierno abierto" %></title>
|
<title><%= content_for?(:title) ? yield(:title) : Setting['org_name'] %></title>
|
||||||
<%= stylesheet_link_tag "application" %>
|
<%= stylesheet_link_tag "application" %>
|
||||||
<%= javascript_include_tag "vendor/modernizr" %>
|
<%= javascript_include_tag "vendor/modernizr" %>
|
||||||
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
|
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
type: "image/png" %>
|
type: "image/png" %>
|
||||||
<%= content_for :social_media_meta_tags %>
|
<%= content_for :social_media_meta_tags %>
|
||||||
|
|
||||||
<%= Setting.value_for(:per_page_code).try(:html_safe) %>
|
<%= Setting['per_page_code'].try(:html_safe) %>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="border-bottom: 1px solid #dadfe1; padding: 20px 0;">
|
<td style="border-bottom: 1px solid #dadfe1; padding: 20px 0;">
|
||||||
<a href="#" target="_blank">
|
<a href="#" target="_blank">
|
||||||
<%= image_tag('logo_email_gobierno_abierto.png', style: "border: 0; display: block; width: 100%;max-width: 370px", alt: "Ayuntamiento de Madrid - Participación ciudadana, transparencia y gobierno abierto") %>
|
<%= image_tag('logo_email_gobierno_abierto.png', style: "border: 0; display: block; width: 100%;max-width: 370px", alt: Setting['org_name']) %>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: center; border-top: 1px solid #dadfe1; padding-top: 20px;">
|
<td style="text-align: center; border-top: 1px solid #dadfe1; padding-top: 20px;">
|
||||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; margin: 0;padding: 0;line-height: 1.5em;color: #797f7f; font-size: 12px;">
|
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; margin: 0;padding: 0;line-height: 1.5em;color: #797f7f; font-size: 12px;">
|
||||||
Ayuntamiento de Madrid</p>
|
<%= Setting['org_name'] %></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<li class="name">
|
<li class="name">
|
||||||
<%= link_to management_root_path do %>
|
<%= link_to management_root_path do %>
|
||||||
<%= image_tag('header_logo_madrid.png', class: 'left', size: '96x96') %>
|
<%= image_tag('header_logo_madrid.png', class: 'left', size: '96x96') %>
|
||||||
<%= t("layouts.header.participation_html") %> <span>|</span> <span class="logo-site"><%= t("management.dashboard.index.title") %></span>
|
<%= Setting['org_name'] %> <span>|</span> <span class="logo-site"><%= t("management.dashboard.index.title") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
|
<li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
|
||||||
|
|||||||
@@ -35,8 +35,10 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if voted_for?(@featured_proposals_votes, proposal) %>
|
<% if voted_for?(@featured_proposals_votes, proposal) %>
|
||||||
<div class="share-supported">
|
<% if Setting['twitter_handle'] %>
|
||||||
<%= social_share_button_tag(proposal.title, url: proposal_url(proposal), via: "AbriendoMadrid") %>
|
<div class="share-supported">
|
||||||
</div>
|
<%= social_share_button_tag(proposal.title, url: proposal_url(proposal), via: Setting['twitter_handle']) %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -51,9 +51,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if voted_for?(@proposal_votes, proposal) %>
|
<% if voted_for?(@proposal_votes, proposal) && Setting['twitter_handle'] %>
|
||||||
<div class="share-supported">
|
<div class="share-supported">
|
||||||
<%= social_share_button_tag(proposal.title, url: proposal_url(proposal), via: "AbriendoMadrid") %>
|
<%= social_share_button_tag(proposal.title, url: proposal_url(proposal), via: Setting['twitter_handle']) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,11 +6,15 @@
|
|||||||
<meta name="twitter:image" content="<%= image_url '/social-media-icon.png' %>" />
|
<meta name="twitter:image" content="<%= image_url '/social-media-icon.png' %>" />
|
||||||
<!-- Facebook OG -->
|
<!-- Facebook OG -->
|
||||||
<meta id="ogtitle" property="og:title" content="<%= social_title %>"/>
|
<meta id="ogtitle" property="og:title" content="<%= social_title %>"/>
|
||||||
<meta property="article:publisher" content="http://decide.madrid.es"/>
|
<% if Setting['url'] %>
|
||||||
<meta property="article:author" content="https://www.facebook.com/Ayuntamiento-de-Madrid-770904446353931"/>
|
<meta property="article:publisher" content=Setting['url']/>
|
||||||
|
<% end %>
|
||||||
|
<% if Setting['facebook_handle'] %>
|
||||||
|
<meta property="article:author" content="https://www.facebook.com/#{Setting['facebook_handle']}"/>
|
||||||
|
<% end %>
|
||||||
<meta property="og:type" content="article"/>
|
<meta property="og:type" content="article"/>
|
||||||
<meta id="ogurl" property="og:url" content="<%= social_url %>"/>
|
<meta id="ogurl" property="og:url" content="<%= social_url %>"/>
|
||||||
<meta id="ogimage" property="og:image" content="<%= image_url '/social-media-icon.png' %>"/>
|
<meta id="ogimage" property="og:image" content="<%= image_url '/social-media-icon.png' %>"/>
|
||||||
<meta property="og:site_name" content="Madrid Participación"/>
|
<meta property="og:site_name" content="<%= Setting['org_name'] %>"/>
|
||||||
<meta id="ogdescription" property="og:description" content="<%= social_description %>"/>
|
<meta id="ogdescription" property="og:description" content="<%= social_description %>"/>
|
||||||
<meta property="fb:app_id" content="1662598980652932"/>
|
<meta property="fb:app_id" content="1662598980652932"/>
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ en:
|
|||||||
administration: Administration
|
administration: Administration
|
||||||
debates: Debates
|
debates: Debates
|
||||||
external_link_blog: Blog
|
external_link_blog: Blog
|
||||||
external_link_blog_url: "/blog"
|
|
||||||
external_link_opendata: Open data
|
external_link_opendata: Open data
|
||||||
external_link_opendata_url: http://datos.madrid.es
|
external_link_opendata_url: http://datos.madrid.es
|
||||||
external_link_transparency: Transparency
|
external_link_transparency: Transparency
|
||||||
@@ -204,7 +203,6 @@ en:
|
|||||||
open_city_title: Love the city, and it will become a city you love.
|
open_city_title: Love the city, and it will become a city you love.
|
||||||
open_data: Open data
|
open_data: Open data
|
||||||
open_gov: Open government
|
open_gov: Open government
|
||||||
participation_html: Madrid Decide
|
|
||||||
proposals: Proposals
|
proposals: Proposals
|
||||||
see_all: See proposals
|
see_all: See proposals
|
||||||
spending_proposals: Spending proposals
|
spending_proposals: Spending proposals
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ es:
|
|||||||
administration: Administrar
|
administration: Administrar
|
||||||
debates: Debates
|
debates: Debates
|
||||||
external_link_blog: Blog
|
external_link_blog: Blog
|
||||||
external_link_blog_url: "/blog"
|
|
||||||
external_link_opendata: Datos abiertos
|
external_link_opendata: Datos abiertos
|
||||||
external_link_opendata_url: http://datos.madrid.es
|
external_link_opendata_url: http://datos.madrid.es
|
||||||
external_link_transparency: Transparencia
|
external_link_transparency: Transparencia
|
||||||
@@ -204,7 +203,6 @@ es:
|
|||||||
open_city_title: La ciudad que quieres será la ciudad que quieras.
|
open_city_title: La ciudad que quieres será la ciudad que quieras.
|
||||||
open_data: Datos abiertos
|
open_data: Datos abiertos
|
||||||
open_gov: Gobierno %{open}
|
open_gov: Gobierno %{open}
|
||||||
participation_html: Madrid Decide
|
|
||||||
proposals: Propuestas
|
proposals: Propuestas
|
||||||
see_all: Ver propuestas
|
see_all: Ver propuestas
|
||||||
spending_proposals: Presupuestos ciudadanos
|
spending_proposals: Presupuestos ciudadanos
|
||||||
|
|||||||
40
db/seeds.rb
40
db/seeds.rb
@@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
# Default admin user (change password after first deploy to a server!)
|
# Default admin user (change password after first deploy to a server!)
|
||||||
if Administrator.count == 0 && !Rails.env.test?
|
if Administrator.count == 0 && !Rails.env.test?
|
||||||
admin = User.create!(username: 'admin', email: 'admin@madrid.es', password: '12345678', password_confirmation: '12345678', confirmed_at: Time.now, terms_of_service: "1")
|
admin = User.create!(username: 'admin', email: 'admin@madrid.es', password: '12345678', password_confirmation: '12345678', confirmed_at: Time.now, terms_of_service: "1")
|
||||||
@@ -6,30 +7,45 @@ end
|
|||||||
|
|
||||||
# Names for the moderation console, as a hint for moderators
|
# Names for the moderation console, as a hint for moderators
|
||||||
# to know better how to assign users with official positions
|
# to know better how to assign users with official positions
|
||||||
Setting.create(key: 'official_level_1_name', value: 'Empleados públicos')
|
Setting["official_level_1_name"] = "Empleados públicos"
|
||||||
Setting.create(key: 'official_level_2_name', value: 'Organización Municipal')
|
Setting["official_level_2_name"] = "Organización Municipal"
|
||||||
Setting.create(key: 'official_level_3_name', value: 'Directores generales')
|
Setting["official_level_3_name"] = "Directores generales"
|
||||||
Setting.create(key: 'official_level_4_name', value: 'Concejales')
|
Setting["official_level_4_name"] = "Concejales"
|
||||||
Setting.create(key: 'official_level_5_name', value: 'Alcaldesa')
|
Setting["official_level_5_name"] = "Alcaldesa"
|
||||||
|
|
||||||
# Max percentage of allowed anonymous votes on a debate
|
# Max percentage of allowed anonymous votes on a debate
|
||||||
Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50')
|
Setting["max_ratio_anon_votes_on_debates"] = 50
|
||||||
|
|
||||||
# Max votes where a debate is still editable
|
# Max votes where a debate is still editable
|
||||||
Setting.create(key: 'max_votes_for_debate_edit', value: '1000')
|
Setting["max_votes_for_debate_edit"] = 1000
|
||||||
|
|
||||||
# Max votes where a proposal is still editable
|
# Max votes where a proposal is still editable
|
||||||
Setting.create(key: 'max_votes_for_proposal_edit', value: '1000')
|
Setting["max_votes_for_proposal_edit"] = 1000
|
||||||
|
|
||||||
# Prefix for the Proposal codes
|
# Prefix for the Proposal codes
|
||||||
Setting.create(key: 'proposal_code_prefix', value: 'MAD')
|
Setting["proposal_code_prefix"] = 'MAD'
|
||||||
|
|
||||||
# Number of votes needed for proposal success
|
# Number of votes needed for proposal success
|
||||||
Setting.create(key: 'votes_for_proposal_success', value: '53726')
|
Setting["votes_for_proposal_success"] = 53726
|
||||||
|
|
||||||
# Users with this email domain will automatically be marked as level 1 officials
|
# Users with this email domain will automatically be marked as level 1 officials
|
||||||
# Emails under the domain's subdomains will also be included
|
# Emails under the domain's subdomains will also be included
|
||||||
Setting.create(key: 'email_domain_for_officials', value: '')
|
Setting["email_domain_for_officials"] = ''
|
||||||
|
|
||||||
# Code to be included at the top (header) of every page (useful for tracking)
|
# Code to be included at the top (header) of every page (useful for tracking)
|
||||||
Setting.create(key: 'per_page_code', value: '')
|
Setting['per_page_code'] = ''
|
||||||
|
|
||||||
|
# Social settings
|
||||||
|
Setting["twitter_handle"] = nil
|
||||||
|
Setting["facebook_handle"] = nil
|
||||||
|
Setting["youtube_handle"] = nil
|
||||||
|
Setting["blog_url"] = nil
|
||||||
|
|
||||||
|
# Public-facing URL of the app.
|
||||||
|
Setting["url"] = "http://example.com"
|
||||||
|
|
||||||
|
# Consul installation's organization name
|
||||||
|
Setting["org_name"] = "Consul"
|
||||||
|
|
||||||
|
# Consul installation place name (City, Country...)
|
||||||
|
Setting["place_name"] = "Consul-land"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace :users do
|
|||||||
|
|
||||||
desc "Assigns official level to users with the officials' email domain"
|
desc "Assigns official level to users with the officials' email domain"
|
||||||
task check_for_official_emails: :environment do
|
task check_for_official_emails: :environment do
|
||||||
domain = Setting.value_for 'email_domain_for_officials'
|
domain = Setting['email_domain_for_officials']
|
||||||
|
|
||||||
# We end the task if there is no email domain configured
|
# We end the task if there is no email domain configured
|
||||||
if !domain.blank?
|
if !domain.blank?
|
||||||
@@ -15,7 +15,7 @@ namespace :users do
|
|||||||
# The real check will be done by check_if_official_email, however.
|
# The real check will be done by check_if_official_email, however.
|
||||||
User.where('official_level = 0 and email like ?', "%#{domain}").find_each do |user|
|
User.where('official_level = 0 and email like ?', "%#{domain}").find_each do |user|
|
||||||
if user.has_official_email?
|
if user.has_official_email?
|
||||||
user.add_official_position! (Setting.value_for 'official_level_1_name'), 1
|
user.add_official_position! (Setting['official_level_1_name']), 1
|
||||||
puts "#{user.username} (#{user.email}) is now a level-1 official."
|
puts "#{user.username} (#{user.email}) is now a level-1 official."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ describe DebatesController do
|
|||||||
|
|
||||||
describe "Vote with too many anonymous votes" do
|
describe "Vote with too many anonymous votes" do
|
||||||
it 'should allow vote if user is allowed' do
|
it 'should allow vote if user is allowed' do
|
||||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 100)
|
Setting["max_ratio_anon_votes_on_debates"] = 100
|
||||||
debate = create(:debate)
|
debate = create(:debate)
|
||||||
sign_in create(:user)
|
sign_in create(:user)
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ describe DebatesController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should not allow vote if user is not allowed' do
|
it 'should not allow vote if user is not allowed' do
|
||||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 0)
|
Setting["max_ratio_anon_votes_on_debates"] = 0
|
||||||
debate = create(:debate, cached_votes_total: 1000)
|
debate = create(:debate, cached_votes_total: 1000)
|
||||||
sign_in create(:user)
|
sign_in create(:user)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Debates' do
|
feature 'Debates' do
|
||||||
@@ -255,7 +256,7 @@ feature 'Debates' do
|
|||||||
|
|
||||||
scenario 'Update should not be posible if debate is not editable' do
|
scenario 'Update should not be posible if debate is not editable' do
|
||||||
debate = create(:debate)
|
debate = create(:debate)
|
||||||
Setting.find_by(key: "max_votes_for_debate_edit").update(value: 2)
|
Setting["max_votes_for_debate_edit"] = 2
|
||||||
3.times { create(:vote, votable: debate) }
|
3.times { create(:vote, votable: debate) }
|
||||||
|
|
||||||
expect(debate).to_not be_editable
|
expect(debate).to_not be_editable
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Proposals' do
|
feature 'Proposals' do
|
||||||
@@ -342,7 +343,7 @@ feature 'Proposals' do
|
|||||||
|
|
||||||
scenario 'Update should not be posible if proposal is not editable' do
|
scenario 'Update should not be posible if proposal is not editable' do
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
Setting.find_by(key: "max_votes_for_proposal_edit").update(value: 10)
|
Setting["max_votes_for_proposal_edit"] = 10
|
||||||
11.times { create(:vote, votable: proposal) }
|
11.times { create(:vote, votable: proposal) }
|
||||||
|
|
||||||
expect(proposal).to_not be_editable
|
expect(proposal).to_not be_editable
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ feature 'Votes' do
|
|||||||
user = create(:user)
|
user = create(:user)
|
||||||
debate = create(:debate)
|
debate = create(:debate)
|
||||||
|
|
||||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 50)
|
Setting["max_ratio_anon_votes_on_debates"] = 50
|
||||||
debate.update(cached_anonymous_votes_total: 520, cached_votes_total: 1000)
|
debate.update(cached_anonymous_votes_total: 520, cached_votes_total: 1000)
|
||||||
|
|
||||||
login_as(user)
|
login_as(user)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Debate do
|
describe Debate do
|
||||||
@@ -82,7 +83,7 @@ describe Debate do
|
|||||||
|
|
||||||
describe "#editable?" do
|
describe "#editable?" do
|
||||||
let(:debate) { create(:debate) }
|
let(:debate) { create(:debate) }
|
||||||
before(:each) { Setting.find_by(key: "max_votes_for_debate_edit").update(value: 3) }
|
before(:each) { Setting["max_votes_for_debate_edit"] = 3 }
|
||||||
|
|
||||||
it "should be true if debate has no votes yet" do
|
it "should be true if debate has no votes yet" do
|
||||||
expect(debate.total_votes).to eq(0)
|
expect(debate.total_votes).to eq(0)
|
||||||
@@ -104,7 +105,7 @@ describe Debate do
|
|||||||
|
|
||||||
describe "#editable_by?" do
|
describe "#editable_by?" do
|
||||||
let(:debate) { create(:debate) }
|
let(:debate) { create(:debate) }
|
||||||
before(:each) { Setting.find_by(key: "max_votes_for_debate_edit").update(value: 1) }
|
before(:each) { Setting["max_votes_for_debate_edit"] = 1 }
|
||||||
|
|
||||||
it "should be true if user is the author and debate is editable" do
|
it "should be true if user is the author and debate is editable" do
|
||||||
expect(debate.editable_by?(debate.author)).to be true
|
expect(debate.editable_by?(debate.author)).to be true
|
||||||
@@ -124,7 +125,7 @@ describe Debate do
|
|||||||
let(:debate) { create(:debate) }
|
let(:debate) { create(:debate) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 50)
|
Setting["max_ratio_anon_votes_on_debates"] = 50
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be true for level two verified users" do
|
it "should be true for level two verified users" do
|
||||||
@@ -160,7 +161,7 @@ describe Debate do
|
|||||||
let(:debate) { create(:debate) }
|
let(:debate) { create(:debate) }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 50)
|
Setting["max_ratio_anon_votes_on_debates"] = 50
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "from level two verified users" do
|
describe "from level two verified users" do
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Proposal do
|
describe Proposal do
|
||||||
@@ -134,14 +135,14 @@ describe Proposal do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "should have a code" do
|
it "should have a code" do
|
||||||
Setting.find_by(key: "proposal_code_prefix").update(value: "TEST")
|
Setting["proposal_code_prefix"] = "TEST"
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
expect(proposal.code).to eq "TEST-#{proposal.created_at.strftime('%Y-%m')}-#{proposal.id}"
|
expect(proposal.code).to eq "TEST-#{proposal.created_at.strftime('%Y-%m')}-#{proposal.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#editable?" do
|
describe "#editable?" do
|
||||||
let(:proposal) { create(:proposal) }
|
let(:proposal) { create(:proposal) }
|
||||||
before(:each) {Setting.find_by(key: "max_votes_for_proposal_edit").update(value: 5)}
|
before(:each) {Setting["max_votes_for_proposal_edit"] = 5}
|
||||||
|
|
||||||
it "should be true if proposal has no votes yet" do
|
it "should be true if proposal has no votes yet" do
|
||||||
expect(proposal.total_votes).to eq(0)
|
expect(proposal.total_votes).to eq(0)
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Setting do
|
describe Setting do
|
||||||
|
before do
|
||||||
it "should be accesible by key" do
|
Setting["official_level_1_name"] = 'Stormtrooper'
|
||||||
create(:setting, key: "Important Setting", value: "42")
|
|
||||||
|
|
||||||
expect(Setting.value_for("Important Setting")).to eq("42")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be nil if key does not exist" do
|
it "should return the overriden setting" do
|
||||||
expect(Setting.value_for("Undefined key")).to be_nil
|
expect(Setting['official_level_1_name']).to eq('Stormtrooper')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
it "should should return nil" do
|
||||||
|
expect(Setting['undefined_key']).to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should persist a setting on the db" do
|
||||||
|
expect(Setting.where(key: 'official_level_1_name', value: 'Stormtrooper')).to exist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ describe User do
|
|||||||
it "checks if the mail address has the officials domain" do
|
it "checks if the mail address has the officials domain" do
|
||||||
# We will use empleados.madrid.es as the officials' domain
|
# We will use empleados.madrid.es as the officials' domain
|
||||||
# Subdomains are also accepted
|
# Subdomains are also accepted
|
||||||
Setting.find_by(key: 'email_domain_for_officials').update(value: 'officials.madrid.es')
|
Setting['email_domain_for_officials'] = 'officials.madrid.es'
|
||||||
|
|
||||||
user1 = create(:user, email: "john@officials.madrid.es", confirmed_at: Time.now)
|
user1 = create(:user, email: "john@officials.madrid.es", confirmed_at: Time.now)
|
||||||
user2 = create(:user, email: "john@yes.officials.madrid.es", confirmed_at: Time.now)
|
user2 = create(:user, email: "john@yes.officials.madrid.es", confirmed_at: Time.now)
|
||||||
|
|||||||
Reference in New Issue
Block a user