Merge branch 'master' into iss-1192-test

This commit is contained in:
Raimond Garcia
2017-04-12 11:51:48 +02:00
committed by GitHub
406 changed files with 11980 additions and 1214 deletions

View File

@@ -2,7 +2,7 @@ require 'database_cleaner'
DatabaseCleaner.clean_with :truncation
puts "Creating Settings"
print "Creating Settings"
Setting.create(key: 'official_level_1_name', value: 'Empleados públicos')
Setting.create(key: 'official_level_2_name', value: 'Organización Municipal')
Setting.create(key: 'official_level_3_name', value: 'Directores generales')
@@ -20,11 +20,13 @@ Setting.create(key: 'twitter_handle', value: '@consul_dev')
Setting.create(key: 'twitter_hashtag', value: '#consul_dev')
Setting.create(key: 'facebook_handle', value: 'consul')
Setting.create(key: 'youtube_handle', value: 'consul')
Setting.create(key: 'telegram_handle', value: 'consul')
Setting.create(key: 'blog_url', value: '/blog')
Setting.create(key: 'url', value: 'http://localhost:3000')
Setting.create(key: 'org_name', value: 'Consul')
Setting.create(key: 'place_name', value: 'City')
Setting.create(key: 'feature.debates', value: "true")
Setting.create(key: 'feature.polls', value: "true")
Setting.create(key: 'feature.spending_proposals', value: nil)
Setting.create(key: 'feature.spending_proposal_features.voting_allowed', value: nil)
Setting.create(key: 'feature.budgets', value: "true")
@@ -32,7 +34,8 @@ 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: 'per_page_code_head', value: "")
Setting.create(key: 'per_page_code_body', 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')
@@ -41,14 +44,18 @@ Setting.create(key: 'meta_keywords', value: 'citizen participation, open governm
Setting.create(key: 'verification_offices_url', value: 'http://oficinas-atencion-ciudadano.url/')
Setting.create(key: 'min_age_to_participate', value: '16')
puts "Creating Geozones"
puts ""
print "Creating Geozones"
Geozone.create(name: "city")
Geozone.create(name: "Existent District", census_code: "01")
('A'..'Z').each { |i| Geozone.create(name: "District #{i}", external_code: i.ord, census_code: i.ord) }
puts "Creating Users"
puts ""
print "Creating Users"
def create_user(email, username = Faker::Name.name)
pwd = '12345678'
puts " #{username}"
User.create!(username: username, email: email, password: pwd, password_confirmation: pwd, confirmed_at: Time.current, terms_of_service: "1")
end
@@ -65,6 +72,9 @@ manager.create_manager
valuator = create_user('valuator@consul.dev', 'valuator')
valuator.create_valuator
poll_officer = create_user('poll_officer@consul.dev', 'Paul O. Fisher')
poll_officer.create_poll_officer
level_2 = create_user('leveltwo@consul.dev', 'level 2')
level_2.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_number: "2222222222", document_type: "1" )
@@ -104,7 +114,8 @@ end
org_user_ids = User.organizations.pluck(:id)
not_org_users = User.where(['users.id NOT IN(?)', org_user_ids])
puts "Creating Tags Categories"
puts ""
print "Creating Tags Categories"
ActsAsTaggableOn::Tag.create!(name: "Asociaciones", featured: true, kind: "category")
ActsAsTaggableOn::Tag.create!(name: "Cultura", featured: true, kind: "category")
@@ -122,7 +133,8 @@ ActsAsTaggableOn::Tag.create!(name: "Transparencia", featured: true, kind: "cat
ActsAsTaggableOn::Tag.create!(name: "Seguridad y Emergencias", featured: true, kind: "category")
ActsAsTaggableOn::Tag.create!(name: "Medio Ambiente", featured: true, kind: "category")
puts "Creating Debates"
puts ""
print "Creating Debates"
tags = Faker::Lorem.words(25)
(1..30).each do
@@ -135,7 +147,6 @@ tags = Faker::Lorem.words(25)
tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1")
puts " #{debate.title}"
end
@@ -150,11 +161,11 @@ tags = ActsAsTaggableOn::Tag.where(kind: 'category')
tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1")
puts " #{debate.title}"
end
puts "Creating Proposals"
puts ""
print "Creating Proposals"
tags = Faker::Lorem.words(25)
(1..30).each do |i|
@@ -171,13 +182,33 @@ tags = Faker::Lorem.words(25)
tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1")
puts " #{proposal.title}"
end
puts "Creating Archived Proposals"
puts ""
print "Creating Archived Proposals"
tags = Faker::Lorem.words(25)
(1..5).each do
author = User.reorder("RANDOM()").first
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
question: Faker::Lorem.sentence(3) + "?",
summary: Faker::Lorem.sentence(3),
responsible_name: Faker::Name.name,
external_url: Faker::Internet.url,
description: description,
tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1",
created_at: Setting["months_to_archive_proposals"].to_i.months.ago)
end
puts ""
print "Creating Successful Proposals"
tags = Faker::Lorem.words(25)
(1..10).each do |i|
author = User.reorder("RANDOM()").first
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
proposal = Proposal.create!(author: author,
@@ -191,8 +222,7 @@ tags = Faker::Lorem.words(25)
tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1",
created_at: Setting["months_to_archive_proposals"].to_i.months.ago)
puts " #{proposal.title}"
cached_votes_up: Setting["votes_for_proposal_success"])
end
@@ -211,11 +241,11 @@ tags = ActsAsTaggableOn::Tag.where(kind: 'category')
tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1")
puts " #{proposal.title}"
end
puts "Commenting Debates"
puts ""
print "Commenting Debates"
(1..100).each do
author = User.reorder("RANDOM()").first
@@ -227,7 +257,8 @@ puts "Commenting Debates"
end
puts "Commenting Proposals"
puts ""
print "Commenting Proposals"
(1..100).each do |i|
author = User.reorder("RANDOM()").first
@@ -239,7 +270,8 @@ puts "Commenting Proposals"
end
puts "Commenting Comments"
puts ""
print "Commenting Comments"
(1..200).each do
author = User.reorder("RANDOM()").first
@@ -253,7 +285,8 @@ puts "Commenting Comments"
end
puts "Voting Debates, Proposals & Comments"
puts ""
print "Voting Debates, Proposals & Comments"
(1..100).each do
voter = not_org_users.reorder("RANDOM()").first
@@ -276,7 +309,8 @@ end
end
puts "Flagging Debates & Comments"
puts ""
print "Flagging Debates & Comments"
(1..40).each do
debate = Debate.reorder("RANDOM()").first
@@ -296,7 +330,8 @@ end
Flag.flag(flagger, proposal)
end
puts "Creating Spending Proposals"
puts ""
print "Creating Spending Proposals"
tags = Faker::Lorem.words(10)
@@ -319,17 +354,18 @@ tags = Faker::Lorem.words(10)
tag_list: tags.sample(3).join(','),
price: rand(1000000),
terms_of_service: "1")
puts " #{spending_proposal.title}"
end
puts "Creating Valuation Assignments"
puts ""
print "Creating Valuation Assignments"
(1..17).to_a.sample.times do
SpendingProposal.reorder("RANDOM()").first.valuators << valuator.valuator
end
puts "Creating Budgets"
puts ""
print "Creating Budgets"
Budget::PHASES.each_with_index do |phase, i|
descriptions = Hash[Budget::PHASES.map{ |p| ["description_#{p}",
@@ -342,8 +378,6 @@ Budget::PHASES.each_with_index do |phase, i|
)
)
puts budget.name
(1..([1, 2, 3].sample)).each do
group = budget.groups.create!(name: Faker::StarWars.planet)
@@ -354,13 +388,12 @@ Budget::PHASES.each_with_index do |phase, i|
price: rand(1 .. 100) * 100000)
end
print "#{group.name} "
end
puts ""
end
puts "Creating Investments"
puts ""
print "Creating Investments"
tags = Faker::Lorem.words(10)
(1..100).each do |i|
heading = Budget::Heading.reorder("RANDOM()").first
@@ -380,47 +413,53 @@ tags = Faker::Lorem.words(10)
tag_list: tags.sample(3).join(','),
price: rand(1 .. 100) * 100000,
terms_of_service: "1")
puts " #{investment.title}"
end
puts "Selecting Investments"
puts ""
print "Selecting Investments"
Budget.balloting.reorder("RANDOM()").limit(3).each do |budget|
budget.investments.feasible.reorder("RANDOM()").limit(10).update_all(selected: true)
end
puts "Creating Valuation Assignments"
puts ""
print "Creating Valuation Assignments"
(1..17).to_a.sample.times do
(1..50).to_a.sample.times do
Budget::Investment.reorder("RANDOM()").first.valuators << valuator.valuator
end
puts "Creating Legislation"
puts ""
print "Creating Legislation"
Legislation.create!(title: 'Participatory Democracy', body: 'In order to achieve...')
puts "Ignoring flags in Debates, comments & proposals"
puts ""
print "Ignoring flags in Debates, comments & proposals"
Debate.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
Comment.flagged.reorder("RANDOM()").limit(30).each(&:ignore_flag)
Proposal.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag)
puts "Hiding debates, comments & proposals"
puts ""
print "Hiding debates, comments & proposals"
Comment.with_hidden.flagged.reorder("RANDOM()").limit(30).each(&:hide)
Debate.with_hidden.flagged.reorder("RANDOM()").limit(5).each(&:hide)
Proposal.with_hidden.flagged.reorder("RANDOM()").limit(10).each(&:hide)
puts "Confirming hiding in debates, comments & proposals"
puts ""
print "Confirming hiding in debates, comments & proposals"
Comment.only_hidden.flagged.reorder("RANDOM()").limit(10).each(&:confirm_hide)
Debate.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
Proposal.only_hidden.flagged.reorder("RANDOM()").limit(5).each(&:confirm_hide)
puts "Creating banners"
puts ""
print "Creating banners"
Proposal.last(3).each do |proposal|
title = Faker::Lorem.sentence(word_count = 3)
@@ -435,5 +474,136 @@ Proposal.last(3).each do |proposal|
post_started_at: rand((Time.current - 1.week) .. (Time.current - 1.day)),
post_ended_at: rand((Time.current - 1.day) .. (Time.current + 1.week)),
created_at: rand((Time.current - 1.week) .. Time.current))
puts " #{banner.title}"
end
puts ""
print "Creating polls"
puts ""
print "Active Polls"
(1..3).each do |i|
poll = Poll.create(name: "Active Poll #{i}",
starts_at: 1.month.ago,
ends_at: 1.month.from_now,
geozone_restricted: false)
end
(4..5).each do |i|
poll = Poll.create(name: "Active Poll #{i}",
starts_at: 1.month.ago,
ends_at: 1.month.from_now,
geozone_restricted: true,
geozones: Geozone.reorder("RANDOM()").limit(3)
)
end
puts ""
print "Upcoming Poll"
poll = Poll.create(name: "Upcoming Poll",
starts_at: 1.month.from_now,
ends_at: 2.months.from_now)
puts ""
print "Expired Poll"
poll = Poll.create(name: "Expired Poll",
starts_at: 2.months.ago,
ends_at: 1.months.ago)
puts ""
print "Creating Poll Questions"
(1..50).each do |i|
poll = Poll.reorder("RANDOM()").first
author = User.reorder("RANDOM()").first
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
open_at = rand(2.months.ago .. 2.months.from_now)
question = Poll::Question.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
description: description,
valid_answers: Faker::Lorem.words((2..7).to_a.sample).join(', '),
poll: poll)
end
puts ""
print "Creating Poll Booths"
30.times.each_with_index do |i|
Poll::Booth.create(name: "Booth #{i}", polls: [Poll.all.sample])
end
puts ""
print "Creating Booth Assignments"
Poll::Booth.all.each do |booth|
Poll::BoothAssignment.create(booth: booth, poll: Poll.all.sample)
end
puts ""
print "Creating Poll Officer Assignments"
(1..15).to_a.sample.times do |i|
Poll::BoothAssignment.all.sample(i).each do |booth_assignment|
Poll::OfficerAssignment.create(officer: poll_officer.poll_officer,
booth_assignment: booth_assignment,
date: booth_assignment.poll.starts_at)
end
end
puts ""
print "Creating Poll Recounts" do
(1..15).to_a.sample.times do |i|
poll_officer.poll_officer.officer_assignments.all.sample(i).each do |officer_assignment|
Poll::Recount.create(officer_assignment: officer_assignment,
booth_assignment: officer_assignment.booth_assignment,
date: officer_assignment.date,
count: (1..5000).to_a.sample)
end
end
end
puts ""
print "Creating Poll Questions from Proposals"
(1..3).each do
proposal = Proposal.reorder("RANDOM()").first
poll = Poll.current.first
question = Poll::Question.create(valid_answers: "Yes, No")
question.copy_attributes_from_proposal(proposal)
question.save!
end
puts ""
print "Creating Successful Proposals"
(1..10).each do
proposal = Proposal.reorder("RANDOM()").first
poll = Poll.current.first
question = Poll::Question.create(valid_answers: "Yes, No")
question.copy_attributes_from_proposal(proposal)
question.save!
end
puts ""
print "Commenting Poll Questions"
(1..30).each do
author = User.reorder("RANDOM()").first
question = Poll::Question.reorder("RANDOM()").first
Comment.create!(user: author,
created_at: rand(question.created_at .. Time.current),
commentable: question,
body: Faker::Lorem.sentence)
end
puts ""
print "Creating Poll Voters"
(1..10).each do
poll = Poll.all.sample
user = User.level_two_verified.sample
Poll::Voter.create(poll: poll, user: user)
end
puts ""
puts "All dev seeds created successfuly 👍"

View File

@@ -0,0 +1,7 @@
class CreatePolls < ActiveRecord::Migration
def change
create_table :polls do |t|
t.string :name
end
end
end

View File

@@ -0,0 +1,7 @@
class CreatePollOfficers < ActiveRecord::Migration
def change
create_table :poll_officers do |t|
t.integer :user_id
end
end
end

View File

@@ -0,0 +1,9 @@
class CreatePollVoters < ActiveRecord::Migration
def change
create_table :poll_voters do |t|
t.integer :booth_id
t.string :document_number
t.string :document_type
end
end
end

View File

@@ -0,0 +1,8 @@
class CreatePollBooths < ActiveRecord::Migration
def change
create_table :poll_booths do |t|
t.string :name
t.integer :poll_id
end
end
end

View File

@@ -0,0 +1,5 @@
class AddLocationToBooths < ActiveRecord::Migration
def change
add_column :poll_booths, :location, :string
end
end

View File

@@ -0,0 +1,9 @@
class CreateOfficingBooths < ActiveRecord::Migration
def change
create_table :poll_officing_booths do |t|
t.belongs_to :officer
t.belongs_to :booth
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,6 @@
class AddDatesToPolls < ActiveRecord::Migration
def change
add_column :polls, :starts_at, :datetime
add_column :polls, :ends_at, :datetime
end
end

View File

@@ -0,0 +1,21 @@
class CreatePollQuestions < ActiveRecord::Migration
def change
create_table :poll_questions do |t|
t.references :proposal, index: true, foreign_key: true
t.references :poll, index: true, foreign_key: true
t.references :author, index: true # foreign key added later due to rails 4
t.string :author_visible_name
t.string :title
t.string :question
t.string :summary
t.string :valid_answers
t.text :description
t.integer :comments_count
t.datetime :hidden_at
t.timestamps
end
add_foreign_key :poll_questions, :users, column: :author_id
end
end

View File

@@ -0,0 +1,10 @@
class CreateGeozonesPollQuestions < ActiveRecord::Migration
def change
create_table :geozones_poll_questions do |t|
t.references :geozone, index: true, foreign_key: true
t.integer :question_id, index: true
end
add_foreign_key :geozones_poll_questions, :poll_questions, column: :question_id
end
end

View File

@@ -0,0 +1,5 @@
class AddAllGeozonesToPollQuestions < ActiveRecord::Migration
def change
add_column :poll_questions, :all_geozones, :boolean, default: false
end
end

View File

@@ -0,0 +1,14 @@
class CreatePollPartialResult < ActiveRecord::Migration
def change
create_table :poll_partial_results do |t|
t.integer :question_id, index: true
t.integer :author_id, index: true
t.string :answer, index: true
t.integer :amount
t.string :origin, index: true
end
add_foreign_key(:poll_partial_results, :users, column: :author_id)
add_foreign_key(:poll_partial_results, :poll_questions, column: :question_id)
end
end

View File

@@ -0,0 +1,5 @@
class RemoveQuestionFromPollQuestions < ActiveRecord::Migration
def change
remove_column :poll_questions, :question
end
end

View File

@@ -0,0 +1,11 @@
class AddTsvToPollQuestions < ActiveRecord::Migration
def up
add_column :poll_questions, :tsv, :tsvector
add_index :poll_questions, :tsv, using: "gin"
end
def down
remove_index :poll_questions, :tsv
remove_column :poll_questions, :tsv
end
end

View File

@@ -0,0 +1,5 @@
class RemovePollIdFromBooth < ActiveRecord::Migration
def change
remove_column :poll_booths, :poll_id, :integer
end
end

View File

@@ -0,0 +1,9 @@
class CreatePollBoothAssignments < ActiveRecord::Migration
def change
create_table :poll_booth_assignments do |t|
t.integer :booth_id
t.integer :poll_id
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,8 @@
class DeleteOfficingBooths < ActiveRecord::Migration
def self.up
drop_table :poll_officing_booths
end
def self.down
end
end

View File

@@ -0,0 +1,9 @@
class CreatePollOfficerAssignments < ActiveRecord::Migration
def change
create_table :poll_officer_assignments do |t|
t.integer :booth_assignment_id
t.integer :officer_id
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,10 @@
class RenameBoothIdToBoothAssignmentId < ActiveRecord::Migration
def change
remove_column :poll_voters, :booth_id, :integer
add_column :poll_voters, :booth_assignment_id, :integer, null: false
add_column :poll_voters, :poll_id, :integer, null: false
add_column :poll_voters, :created_at, :datetime, null: false
add_column :poll_voters, :updated_at, :datetime, null: false
end
end

View File

@@ -0,0 +1,5 @@
class RemovePollIdFromVoter < ActiveRecord::Migration
def change
remove_column :poll_voters, :poll_id, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddDateToOfficerAssignment < ActiveRecord::Migration
def change
add_column :poll_officer_assignments, :date, :datetime
end
end

View File

@@ -0,0 +1,15 @@
class CreatePollRecounts < ActiveRecord::Migration
def change
create_table :poll_recounts do |t|
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.integer :count
t.text :count_log, default: ""
t.timestamps null: false
end
add_index :poll_recounts, :booth_assignment_id
add_index :poll_recounts, :officer_assignment_id
end
end

View File

@@ -0,0 +1,5 @@
class AddPublishedToPolls < ActiveRecord::Migration
def change
add_column :polls, :published, :boolean, default: false
end
end

View File

@@ -0,0 +1,6 @@
class AddDateAndOfficerAssignmentLogToPollRecounts < ActiveRecord::Migration
def change
add_column :poll_recounts, :date, :datetime
add_column :poll_recounts, :officer_assignment_id_log, :text, default: ""
end
end

View File

@@ -0,0 +1,10 @@
class MoveGeozonesFromPollQuestionsToPolls < ActiveRecord::Migration
def change
drop_table :geozones_poll_questions
create_table :geozones_polls do |t|
t.references :geozone, index: true, foreign_key: true
t.references :poll, index: true, foreign_key: true
end
end
end

View File

@@ -0,0 +1,5 @@
class AddGeozoneRestrictedToPolls < ActiveRecord::Migration
def change
add_column :polls, :geozone_restricted, :boolean, default: false, index: true
end
end

View File

@@ -0,0 +1,5 @@
class RemoveAllGeozonesFromPollQuestions < ActiveRecord::Migration
def change
remove_column :poll_questions, :all_geozones, :boolean
end
end

View File

@@ -0,0 +1,12 @@
class AddPollIdAndStatsFieldsToPollVoter < ActiveRecord::Migration
def change
add_column :poll_voters, :poll_id, :integer, null: false
remove_column :poll_voters, :booth_assignment_id, :integer, null: false
add_column :poll_voters, :booth_assignment_id, :integer
add_column :poll_voters, :age, :integer
add_column :poll_voters, :gender, :string
add_column :poll_voters, :geozone_id, :integer
end
end

View File

@@ -0,0 +1,15 @@
class CreatePollAnswers < ActiveRecord::Migration
def change
create_table :poll_answers do |t|
t.integer :question_id
t.integer :author_id
t.string :answer
t.timestamps
end
add_index :poll_answers, :question_id
add_index :poll_answers, :author_id
add_index :poll_answers, [:question_id, :answer]
end
end

View File

@@ -0,0 +1,9 @@
class AddAnswerIdToPollVoters < ActiveRecord::Migration
def change
add_column :poll_voters, :answer_id, :integer, default: nil
add_index :poll_voters, :document_number
add_index :poll_voters, :poll_id
add_index :poll_voters, [:poll_id, :document_number, :document_type], name: 'doc_by_poll'
end
end

View File

@@ -0,0 +1,5 @@
class AddOfficerAssignmentToVotes < ActiveRecord::Migration
def change
add_column :poll_voters, :officer_assignment_id, :integer, default: nil
end
end

View File

@@ -0,0 +1,5 @@
class AddsUserIdToPollVoters < ActiveRecord::Migration
def change
add_reference :poll_voters, :user, index: true
end
end

View File

@@ -0,0 +1,15 @@
class CreatePollFinalRecount < ActiveRecord::Migration
def change
create_table :poll_final_recounts do |t|
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.integer :count
t.text :count_log, default: ""
t.datetime :created_at, null: false
t.datetime :updated_at, null: false
t.text :officer_assignment_id_log, default: ""
end
add_index :poll_final_recounts, :booth_assignment_id
end
end

View File

@@ -0,0 +1,5 @@
class AddFinalToPollOfficerAssignments < ActiveRecord::Migration
def change
add_column :poll_officer_assignments, :final, :boolean, default: false
end
end

View File

@@ -0,0 +1,5 @@
class AddDateToFinalRecount < ActiveRecord::Migration
def change
add_column :poll_final_recounts, :date, :datetime, null: false
end
end

View File

@@ -0,0 +1,13 @@
class ChangeDatetimesToDateInRecountsAndAssignments < ActiveRecord::Migration
def up
change_column :poll_recounts, :date, :date, null: false
change_column :poll_final_recounts, :date, :date, null: false
change_column :poll_officer_assignments, :date, :date, null: false
end
def down
change_column :poll_recounts, :date, :datetime, null: false
change_column :poll_final_recounts, :date, :datetime, null: false
change_column :poll_officer_assignments, :date, :datetime, null: false
end
end

View File

@@ -0,0 +1,5 @@
class RemoveSummaryFromPollQuestion < ActiveRecord::Migration
def change
remove_column :poll_questions, :summary
end
end

View File

@@ -0,0 +1,9 @@
class AddsFieldsToPollPartialResults < ActiveRecord::Migration
def change
add_column :poll_partial_results, :date, :date
add_column :poll_partial_results, :booth_assignment_id, :integer
add_column :poll_partial_results, :officer_assignment_id, :integer
add_index :poll_partial_results, [:booth_assignment_id, :date]
end
end

View File

@@ -0,0 +1,7 @@
class AddLogFieldsToPollPartialResults < ActiveRecord::Migration
def change
add_column :poll_partial_results, :amount_log, :text, default: ""
add_column :poll_partial_results, :officer_assignment_id_log, :text, default: ""
add_column :poll_partial_results, :author_id_log, :text, default: ""
end
end

View File

@@ -0,0 +1,18 @@
class CreatePollWhiteResults < ActiveRecord::Migration
def change
create_table :poll_white_results do |t|
t.integer :author_id
t.integer :amount
t.string :origin
t.date :date
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.text :amount_log, default: ""
t.text :officer_assignment_id_log, default: ""
t.text :author_id_log, default: ""
end
add_index :poll_white_results, :officer_assignment_id
add_index :poll_white_results, :booth_assignment_id
end
end

View File

@@ -0,0 +1,18 @@
class CreatePollNullResults < ActiveRecord::Migration
def change
create_table :poll_null_results do |t|
t.integer :author_id
t.integer :amount
t.string :origin
t.date :date
t.integer :booth_assignment_id
t.integer :officer_assignment_id
t.text :amount_log, default: ""
t.text :officer_assignment_id_log, default: ""
t.text :author_id_log, default: ""
end
add_index :poll_null_results, :officer_assignment_id
add_index :poll_null_results, :booth_assignment_id
end
end

View File

@@ -0,0 +1,6 @@
class AddOfficerIdToFailedCensusCalls < ActiveRecord::Migration
def change
add_column :failed_census_calls, :poll_officer_id, :integer, index: true
add_foreign_key :failed_census_calls, :poll_officers
end
end

View File

@@ -0,0 +1,5 @@
class AddFailedCensusCallsCountToPollOfficers < ActiveRecord::Migration
def change
add_column :poll_officers, :failed_census_calls_count, :integer, default: 0
end
end

View File

@@ -0,0 +1,5 @@
class AddYearOfBirthToFailedCensusCalls < ActiveRecord::Migration
def change
add_column :failed_census_calls, :year_of_birth, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddUserDataLogToPollOfficerAssignments < ActiveRecord::Migration
def change
add_column :poll_officer_assignments, :user_data_log, :string, default: ""
end
end

View File

@@ -0,0 +1,5 @@
class AddFormerUsersDataLogToUsers < ActiveRecord::Migration
def change
add_column :users, :former_users_data_log, :text, default: ""
end
end

View File

@@ -0,0 +1,36 @@
class AddPollsRelatedIndexes < ActiveRecord::Migration
def change
add_index :poll_booth_assignments, :booth_id
add_index :poll_booth_assignments, :poll_id
add_index :poll_final_recounts, :officer_assignment_id
add_index :poll_officer_assignments, :booth_assignment_id
add_index :poll_officer_assignments, :officer_id
add_index :poll_officer_assignments, [:officer_id, :date]
add_index :poll_officers, :user_id
add_index :poll_voters, :booth_assignment_id
add_index :poll_voters, :officer_assignment_id
add_index :polls, [:starts_at, :ends_at]
add_foreign_key :poll_answers, :poll_questions, column: :question_id
add_foreign_key :poll_booth_assignments, :polls
add_foreign_key :poll_final_recounts, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_final_recounts, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_null_results, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_null_results, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_white_results, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_white_results, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_officer_assignments, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_partial_results, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_partial_results, :poll_officer_assignments, column: :officer_assignment_id
add_foreign_key :poll_voters, :polls
add_foreign_key :poll_recounts, :poll_booth_assignments, column: :booth_assignment_id
add_foreign_key :poll_recounts, :poll_officer_assignments, column: :officer_assignment_id
end
end

View File

@@ -0,0 +1,15 @@
class CreateSiteCustomizationPages < ActiveRecord::Migration
def change
create_table :site_customization_pages do |t|
t.string :slug, null: false
t.string :title, null: false
t.string :subtitle
t.text :content
t.boolean :more_info_flag
t.boolean :print_content_flag
t.string :status, default: 'draft'
t.timestamps null: false
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateSiteCustomizationImages < ActiveRecord::Migration
def change
create_table :site_customization_images do |t|
t.string :name, null: false
t.attachment :image
t.timestamps null: false
end
add_index :site_customization_images, :name, unique: true
end
end

View File

@@ -0,0 +1,13 @@
class CreateSiteCustomizationContentBlocks < ActiveRecord::Migration
def change
create_table :site_customization_content_blocks do |t|
t.string :name
t.string :locale
t.text :body
t.timestamps null: false
end
add_index :site_customization_content_blocks, [:name, :locale], unique: true
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170114154421) do
ActiveRecord::Schema.define(version: 20170324101716) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -283,6 +283,8 @@ ActiveRecord::Schema.define(version: 20170114154421) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "district_code"
t.integer "poll_officer_id"
t.integer "year_of_birth"
end
add_index "failed_census_calls", ["user_id"], name: "index_failed_census_calls_on_user_id", using: :btree
@@ -308,6 +310,14 @@ ActiveRecord::Schema.define(version: 20170114154421) do
t.string "census_code"
end
create_table "geozones_polls", force: :cascade do |t|
t.integer "geozone_id"
t.integer "poll_id"
end
add_index "geozones_polls", ["geozone_id"], name: "index_geozones_polls_on_geozone_id", using: :btree
add_index "geozones_polls", ["poll_id"], name: "index_geozones_polls_on_poll_id", using: :btree
create_table "identities", force: :cascade do |t|
t.integer "user_id"
t.string "provider"
@@ -367,6 +377,184 @@ ActiveRecord::Schema.define(version: 20170114154421) do
add_index "organizations", ["user_id"], name: "index_organizations_on_user_id", using: :btree
create_table "poll_answers", force: :cascade do |t|
t.integer "question_id"
t.integer "author_id"
t.string "answer"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "poll_answers", ["author_id"], name: "index_poll_answers_on_author_id", using: :btree
add_index "poll_answers", ["question_id", "answer"], name: "index_poll_answers_on_question_id_and_answer", using: :btree
add_index "poll_answers", ["question_id"], name: "index_poll_answers_on_question_id", using: :btree
create_table "poll_booth_assignments", force: :cascade do |t|
t.integer "booth_id"
t.integer "poll_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "poll_booth_assignments", ["booth_id"], name: "index_poll_booth_assignments_on_booth_id", using: :btree
add_index "poll_booth_assignments", ["poll_id"], name: "index_poll_booth_assignments_on_poll_id", using: :btree
create_table "poll_booths", force: :cascade do |t|
t.string "name"
t.string "location"
end
create_table "poll_final_recounts", force: :cascade do |t|
t.integer "booth_assignment_id"
t.integer "officer_assignment_id"
t.integer "count"
t.text "count_log", default: ""
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "officer_assignment_id_log", default: ""
t.date "date", null: false
end
add_index "poll_final_recounts", ["booth_assignment_id"], name: "index_poll_final_recounts_on_booth_assignment_id", using: :btree
add_index "poll_final_recounts", ["officer_assignment_id"], name: "index_poll_final_recounts_on_officer_assignment_id", using: :btree
create_table "poll_null_results", force: :cascade do |t|
t.integer "author_id"
t.integer "amount"
t.string "origin"
t.date "date"
t.integer "booth_assignment_id"
t.integer "officer_assignment_id"
t.text "amount_log", default: ""
t.text "officer_assignment_id_log", default: ""
t.text "author_id_log", default: ""
end
add_index "poll_null_results", ["booth_assignment_id"], name: "index_poll_null_results_on_booth_assignment_id", using: :btree
add_index "poll_null_results", ["officer_assignment_id"], name: "index_poll_null_results_on_officer_assignment_id", using: :btree
create_table "poll_officer_assignments", force: :cascade do |t|
t.integer "booth_assignment_id"
t.integer "officer_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.date "date", null: false
t.boolean "final", default: false
t.string "user_data_log", default: ""
end
add_index "poll_officer_assignments", ["booth_assignment_id"], name: "index_poll_officer_assignments_on_booth_assignment_id", using: :btree
add_index "poll_officer_assignments", ["officer_id", "date"], name: "index_poll_officer_assignments_on_officer_id_and_date", using: :btree
add_index "poll_officer_assignments", ["officer_id"], name: "index_poll_officer_assignments_on_officer_id", using: :btree
create_table "poll_officers", force: :cascade do |t|
t.integer "user_id"
t.integer "failed_census_calls_count", default: 0
end
add_index "poll_officers", ["user_id"], name: "index_poll_officers_on_user_id", using: :btree
create_table "poll_partial_results", force: :cascade do |t|
t.integer "question_id"
t.integer "author_id"
t.string "answer"
t.integer "amount"
t.string "origin"
t.date "date"
t.integer "booth_assignment_id"
t.integer "officer_assignment_id"
t.text "amount_log", default: ""
t.text "officer_assignment_id_log", default: ""
t.text "author_id_log", default: ""
end
add_index "poll_partial_results", ["answer"], name: "index_poll_partial_results_on_answer", using: :btree
add_index "poll_partial_results", ["author_id"], name: "index_poll_partial_results_on_author_id", using: :btree
add_index "poll_partial_results", ["booth_assignment_id", "date"], name: "index_poll_partial_results_on_booth_assignment_id_and_date", using: :btree
add_index "poll_partial_results", ["origin"], name: "index_poll_partial_results_on_origin", using: :btree
add_index "poll_partial_results", ["question_id"], name: "index_poll_partial_results_on_question_id", using: :btree
create_table "poll_questions", force: :cascade do |t|
t.integer "proposal_id"
t.integer "poll_id"
t.integer "author_id"
t.string "author_visible_name"
t.string "title"
t.string "valid_answers"
t.text "description"
t.integer "comments_count"
t.datetime "hidden_at"
t.datetime "created_at"
t.datetime "updated_at"
t.tsvector "tsv"
end
add_index "poll_questions", ["author_id"], name: "index_poll_questions_on_author_id", using: :btree
add_index "poll_questions", ["poll_id"], name: "index_poll_questions_on_poll_id", using: :btree
add_index "poll_questions", ["proposal_id"], name: "index_poll_questions_on_proposal_id", using: :btree
add_index "poll_questions", ["tsv"], name: "index_poll_questions_on_tsv", using: :gin
create_table "poll_recounts", force: :cascade do |t|
t.integer "booth_assignment_id"
t.integer "officer_assignment_id"
t.integer "count"
t.text "count_log", default: ""
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.date "date", null: false
t.text "officer_assignment_id_log", default: ""
end
add_index "poll_recounts", ["booth_assignment_id"], name: "index_poll_recounts_on_booth_assignment_id", using: :btree
add_index "poll_recounts", ["officer_assignment_id"], name: "index_poll_recounts_on_officer_assignment_id", using: :btree
create_table "poll_voters", force: :cascade do |t|
t.string "document_number"
t.string "document_type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "poll_id", null: false
t.integer "booth_assignment_id"
t.integer "age"
t.string "gender"
t.integer "geozone_id"
t.integer "answer_id"
t.integer "officer_assignment_id"
t.integer "user_id"
end
add_index "poll_voters", ["booth_assignment_id"], name: "index_poll_voters_on_booth_assignment_id", using: :btree
add_index "poll_voters", ["document_number"], name: "index_poll_voters_on_document_number", using: :btree
add_index "poll_voters", ["officer_assignment_id"], name: "index_poll_voters_on_officer_assignment_id", using: :btree
add_index "poll_voters", ["poll_id", "document_number", "document_type"], name: "doc_by_poll", using: :btree
add_index "poll_voters", ["poll_id"], name: "index_poll_voters_on_poll_id", using: :btree
add_index "poll_voters", ["user_id"], name: "index_poll_voters_on_user_id", using: :btree
create_table "poll_white_results", force: :cascade do |t|
t.integer "author_id"
t.integer "amount"
t.string "origin"
t.date "date"
t.integer "booth_assignment_id"
t.integer "officer_assignment_id"
t.text "amount_log", default: ""
t.text "officer_assignment_id_log", default: ""
t.text "author_id_log", default: ""
end
add_index "poll_white_results", ["booth_assignment_id"], name: "index_poll_white_results_on_booth_assignment_id", using: :btree
add_index "poll_white_results", ["officer_assignment_id"], name: "index_poll_white_results_on_officer_assignment_id", using: :btree
create_table "polls", force: :cascade do |t|
t.string "name"
t.datetime "starts_at"
t.datetime "ends_at"
t.boolean "published", default: false
t.boolean "geozone_restricted", default: false
end
add_index "polls", ["starts_at", "ends_at"], name: "index_polls_on_starts_at_and_ends_at", using: :btree
create_table "proposal_notifications", force: :cascade do |t|
t.string "title"
t.text "body"
@@ -441,6 +629,40 @@ ActiveRecord::Schema.define(version: 20170114154421) do
t.datetime "updated_at"
end
create_table "site_customization_content_blocks", force: :cascade do |t|
t.string "name"
t.string "locale"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "site_customization_content_blocks", ["name", "locale"], name: "index_site_customization_content_blocks_on_name_and_locale", unique: true, using: :btree
create_table "site_customization_images", force: :cascade do |t|
t.string "name", null: false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "site_customization_images", ["name"], name: "index_site_customization_images_on_name", unique: true, using: :btree
create_table "site_customization_pages", force: :cascade do |t|
t.string "slug", null: false
t.string "title", null: false
t.string "subtitle"
t.text "content"
t.boolean "more_info_flag"
t.boolean "print_content_flag"
t.string "status", default: "draft"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spending_proposals", force: :cascade do |t|
t.string "title"
t.text "description"
@@ -580,9 +802,10 @@ ActiveRecord::Schema.define(version: 20170114154421) 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-11-23 10:59:20', null: false
t.boolean "created_from_signature", default: false
t.integer "failed_email_digests_count", default: 0
t.text "former_users_data_log", default: ""
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
@@ -673,14 +896,36 @@ ActiveRecord::Schema.define(version: 20170114154421) do
add_foreign_key "administrators", "users"
add_foreign_key "annotations", "legislations"
add_foreign_key "annotations", "users"
add_foreign_key "failed_census_calls", "poll_officers"
add_foreign_key "failed_census_calls", "users"
add_foreign_key "flags", "users"
add_foreign_key "geozones_polls", "geozones"
add_foreign_key "geozones_polls", "polls"
add_foreign_key "identities", "users"
add_foreign_key "locks", "users"
add_foreign_key "managers", "users"
add_foreign_key "moderators", "users"
add_foreign_key "notifications", "users"
add_foreign_key "organizations", "users"
add_foreign_key "poll_answers", "poll_questions", column: "question_id"
add_foreign_key "poll_booth_assignments", "polls"
add_foreign_key "poll_final_recounts", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_final_recounts", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_null_results", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_null_results", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_officer_assignments", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_partial_results", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_partial_results", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_partial_results", "poll_questions", column: "question_id"
add_foreign_key "poll_partial_results", "users", column: "author_id"
add_foreign_key "poll_questions", "polls"
add_foreign_key "poll_questions", "proposals"
add_foreign_key "poll_questions", "users", column: "author_id"
add_foreign_key "poll_recounts", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_recounts", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_voters", "polls"
add_foreign_key "poll_white_results", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_white_results", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "users", "geozones"
add_foreign_key "valuators", "users"
end

View File

@@ -38,15 +38,21 @@ Setting["months_to_archive_proposals"] = 12
# Emails under the domain's subdomains will also be included
Setting["email_domain_for_officials"] = ''
# Code to be included at the top (header) of every page (useful for tracking)
Setting['per_page_code'] = ''
# Code to be included at the top (inside <head>) of every page (useful for tracking)
Setting['per_page_code_head'] = ''
# Code to be included at the top (inside <body>) of every page
Setting['per_page_code_body'] = ''
# Social settings
Setting["twitter_handle"] = nil
Setting["twitter_hashtag"] = nil
Setting["facebook_handle"] = nil
Setting["youtube_handle"] = nil
Setting["telegram_handle"] = nil
Setting["blog_url"] = nil
Setting["transparency_url"] = nil
Setting["opendata_url"] = "/opendata"
# Public-facing URL of the app.
Setting["url"] = "http://example.com"
@@ -64,6 +70,7 @@ Setting["meta_keywords"] = nil
# Feature flags
Setting['feature.debates'] = true
Setting['feature.spending_proposals'] = nil
Setting['feature.polls'] = true
Setting['feature.twitter_login'] = true
Setting['feature.facebook_login'] = true
Setting['feature.google_login'] = true