merge with master
This commit is contained in:
@@ -14,6 +14,9 @@ Setting.create(key: 'max_votes_for_proposal_edit', value: '1000')
|
||||
Setting.create(key: 'proposal_code_prefix', value: 'MAD')
|
||||
Setting.create(key: 'votes_for_proposal_success', value: '100')
|
||||
|
||||
puts "Creating Geozones"
|
||||
('A'..'Z').each{ |i| Geozone.create(name: "District #{i}") }
|
||||
|
||||
puts "Creating Users"
|
||||
|
||||
def create_user(email, username = Faker::Name.name)
|
||||
@@ -180,6 +183,25 @@ end
|
||||
Flag.flag(flagger, proposal)
|
||||
end
|
||||
|
||||
puts "Creating Spending Proposals"
|
||||
|
||||
resolutions = ["accepted", "rejected", nil]
|
||||
|
||||
(1..30).each do |i|
|
||||
geozone = Geozone.reorder("RANDOM()").first
|
||||
author = User.reorder("RANDOM()").first
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
spending_proposal = SpendingProposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(3).truncate(60),
|
||||
external_url: Faker::Internet.url,
|
||||
description: description,
|
||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||
resolution: resolutions.sample,
|
||||
geozone: [geozone, nil].sample,
|
||||
terms_of_service: "1")
|
||||
puts " #{spending_proposal.title}"
|
||||
end
|
||||
|
||||
puts "Creating Legislation"
|
||||
|
||||
Legislation.create!(title: 'Participatory Democracy', body: 'In order to achieve...')
|
||||
|
||||
9
db/migrate/20150928115005_create_notifications.rb
Normal file
9
db/migrate/20150928115005_create_notifications.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class CreateNotifications < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :notifications do |t|
|
||||
t.belongs_to :user, index: true, foreign_key: true
|
||||
t.belongs_to :activity, index: true, foreign_key: true
|
||||
t.boolean :read, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
12
db/migrate/20151218114205_create_spending_proposals.rb
Normal file
12
db/migrate/20151218114205_create_spending_proposals.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateSpendingProposals < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :spending_proposals do |t|
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.integer :author_id
|
||||
t.string :external_url
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddSpendingProposalsCounterToTags < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tags, :spending_proposals_count, :integer, default: 0
|
||||
add_index :tags, :spending_proposals_count
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddSpendingProposalsIndexes < ActiveRecord::Migration
|
||||
def change
|
||||
add_index :spending_proposals, :author_id
|
||||
end
|
||||
end
|
||||
11
db/migrate/20160105121132_create_geozones.rb
Normal file
11
db/migrate/20160105121132_create_geozones.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateGeozones < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :geozones do |t|
|
||||
t.string :name
|
||||
t.string :html_map_coordinates
|
||||
t.string :external_code
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
class MergeActivitiesAndNotifications < ActiveRecord::Migration
|
||||
def change
|
||||
change_table :notifications do |t|
|
||||
t.remove :read
|
||||
t.remove :activity_id
|
||||
t.references :notifiable, polymorphic: true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddGeozoneToSpendingProposal < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spending_proposals, :geozone_id, :integer, default: nil
|
||||
add_index :spending_proposals, :geozone_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddResolutionToSpendingProposals < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spending_proposals, :resolution, :string, default: nil
|
||||
add_index :spending_proposals, :resolution
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddCounterToNotifications < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :notifications, :counter, :integer, default: 1
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddNotificationsCounterCacheToUser < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :notifications_count, :integer, default: 0
|
||||
end
|
||||
end
|
||||
41
db/schema.rb
41
db/schema.rb
@@ -11,7 +11,8 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160108133501) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -171,6 +172,14 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
add_index "flags", ["user_id", "flaggable_type", "flaggable_id"], name: "access_inappropiate_flags", using: :btree
|
||||
add_index "flags", ["user_id"], name: "index_flags_on_user_id", using: :btree
|
||||
|
||||
create_table "geozones", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "html_map_coordinates"
|
||||
t.string "external_code"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "identities", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.string "provider"
|
||||
@@ -191,7 +200,7 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
create_table "locks", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "tries", default: 0
|
||||
t.datetime "locked_until", default: '2000-01-01 07:01:01', null: false
|
||||
t.datetime "locked_until", default: '2000-01-01 00:01:01', null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
@@ -204,6 +213,15 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
|
||||
add_index "moderators", ["user_id"], name: "index_moderators_on_user_id", using: :btree
|
||||
|
||||
create_table "notifications", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "notifiable_id"
|
||||
t.string "notifiable_type"
|
||||
t.integer "counter", default: 1
|
||||
end
|
||||
|
||||
add_index "notifications", ["user_id"], name: "index_notifications_on_user_id", using: :btree
|
||||
|
||||
create_table "organizations", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.string "name", limit: 60
|
||||
@@ -264,6 +282,21 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
|
||||
add_index "simple_captcha_data", ["key"], name: "idx_key", using: :btree
|
||||
|
||||
create_table "spending_proposals", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
t.integer "author_id"
|
||||
t.string "external_url"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "geozone_id"
|
||||
t.string "resolution"
|
||||
end
|
||||
|
||||
add_index "spending_proposals", ["author_id"], name: "index_spending_proposals_on_author_id", using: :btree
|
||||
add_index "spending_proposals", ["geozone_id"], name: "index_spending_proposals_on_geozone_id", using: :btree
|
||||
add_index "spending_proposals", ["resolution"], name: "index_spending_proposals_on_resolution", using: :btree
|
||||
|
||||
create_table "taggings", force: :cascade do |t|
|
||||
t.integer "tag_id"
|
||||
t.integer "taggable_id"
|
||||
@@ -284,11 +317,13 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
t.integer "debates_count", default: 0
|
||||
t.integer "proposals_count", default: 0
|
||||
t.string "kind", limit: 40
|
||||
t.integer "spending_proposals_count", default: 0
|
||||
end
|
||||
|
||||
add_index "tags", ["debates_count"], name: "index_tags_on_debates_count", using: :btree
|
||||
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
|
||||
add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
|
||||
add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: ""
|
||||
@@ -331,6 +366,7 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
t.datetime "erased_at"
|
||||
t.boolean "public_activity", default: true
|
||||
t.boolean "newsletter", default: false
|
||||
t.integer "notifications_count", default: 0
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||
@@ -405,5 +441,6 @@ ActiveRecord::Schema.define(version: 20160108101736) do
|
||||
add_foreign_key "identities", "users"
|
||||
add_foreign_key "locks", "users"
|
||||
add_foreign_key "moderators", "users"
|
||||
add_foreign_key "notifications", "users"
|
||||
add_foreign_key "organizations", "users"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user