Merge branch 'proposals' of github.com:AyuntamientoMadrid/participacion into proposals

This commit is contained in:
rgarcia
2015-09-12 13:18:44 +02:00
6 changed files with 18 additions and 2 deletions

View File

@@ -74,6 +74,10 @@ class Proposal < ActiveRecord::Base
user.level_two_verified? || !user.voted_for?(self)
end
def code
"#{Setting.value_for("proposal_code_prefix")}-#{created_at.strftime('%Y-%M')}-#{id}"
end
protected
def sanitize_description

View File

@@ -6,4 +6,5 @@ en:
official_level_4_name: "Level 4 official positions"
official_level_5_name: "Level 5 official positions"
max_ratio_anon_votes_on_debates: "Max allowed percentage of anonymous votes per Debate"
max_votes_for_proposal_edit: "Number of votes where a Proposal is not editable anymore"
max_votes_for_proposal_edit: "Number of votes where a Proposal is not editable anymore"
proposal_code_prefix: "Prefix for Proposals codes"

View File

@@ -6,4 +6,5 @@ es:
official_level_4_name: "Cargos públicos de nivel 4"
official_level_5_name: "Cargos públicos de nivel 5"
max_ratio_anon_votes_on_debates: "Porcentaje máximo de votos anónimos por Debate"
max_votes_for_proposal_edit: "Número de votos en que una Propuesta deja de poderse editar"
max_votes_for_proposal_edit: "Número de votos en que una Propuesta deja de poderse editar"
proposal_code_prefix: "Prefijo para los códigos de Propuestas"

View File

@@ -10,6 +10,7 @@ Setting.create(key: 'official_level_4_name', value: 'Concejales')
Setting.create(key: 'official_level_5_name', value: 'Alcaldesa')
Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50')
Setting.create(key: 'max_votes_for_proposal_edit', value: '1000')
Setting.create(key: 'proposal_code_prefix', value: 'MAD')
puts "Creating Users"

View File

@@ -17,3 +17,6 @@ Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50')
# Max votes where a proposal is still editable
Setting.create(key: 'max_votes_for_proposal_edit', value: '1000')
# Prefix for the Proposal codes
Setting.create(key: 'proposal_code_prefix', value: 'MAD')

View File

@@ -46,6 +46,12 @@ describe Proposal do
expect(proposal).to_not be_valid
end
it "should have a code" do
Setting.find_by(key: "proposal_code_prefix").update(value: "TEST")
proposal = create(:proposal)
expect(proposal.code).to eq "TEST-#{proposal.created_at.strftime('%Y-%M')}-#{proposal.id}"
end
describe "#editable?" do
let(:proposal) { create(:proposal) }
before(:each) {Setting.find_by(key: "max_votes_for_proposal_edit").update(value: 100)}