diff --git a/app/controllers/annotations_controller.rb b/app/controllers/annotations_controller.rb
index d70a2e9be..8b004076c 100644
--- a/app/controllers/annotations_controller.rb
+++ b/app/controllers/annotations_controller.rb
@@ -24,7 +24,7 @@ class AnnotationsController < ApplicationController
end
def search
- @annotations = Annotation.where(legislation_id: params[:legislation_id])
+ @annotations = Annotation.where(legacy_legislation_id: params[:legacy_legislation_id])
annotations_hash = { total: @annotations.size, rows: @annotations }
render json: annotations_hash.to_json(methods: :permissions)
end
@@ -35,6 +35,6 @@ class AnnotationsController < ApplicationController
params
.require(:annotation)
.permit(:quote, :text, ranges: [:start, :startOffset, :end, :endOffset])
- .merge(legislation_id: params[:legislation_id])
+ .merge(legacy_legislation_id: params[:legacy_legislation_id])
end
end
diff --git a/app/controllers/legacy_legislations_controller.rb b/app/controllers/legacy_legislations_controller.rb
new file mode 100644
index 000000000..103c81cea
--- /dev/null
+++ b/app/controllers/legacy_legislations_controller.rb
@@ -0,0 +1,8 @@
+class LegacyLegislationsController < ApplicationController
+ load_and_authorize_resource
+
+ def show
+ @legacy_legislation = LegacyLegislation.find(params[:id])
+ end
+
+end
diff --git a/app/controllers/legislations_controller.rb b/app/controllers/legislations_controller.rb
deleted file mode 100644
index a95f95ef2..000000000
--- a/app/controllers/legislations_controller.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class LegislationsController < ApplicationController
- load_and_authorize_resource
-
- def show
- @legislation = Legislation.find(params[:id])
- end
-
-end
\ No newline at end of file
diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb
index 39a7f69f5..867bc3df6 100644
--- a/app/models/abilities/everyone.rb
+++ b/app/models/abilities/everyone.rb
@@ -7,7 +7,7 @@ module Abilities
can [:read, :map, :summary], Proposal
can :read, Comment
can :read, SpendingProposal
- can :read, Legislation
+ can :read, LegacyLegislation
can :read, User
can [:search, :read], Annotation
can :new, DirectMessage
diff --git a/app/models/annotation.rb b/app/models/annotation.rb
index 66abb2db2..295badd92 100644
--- a/app/models/annotation.rb
+++ b/app/models/annotation.rb
@@ -1,7 +1,7 @@
class Annotation < ActiveRecord::Base
serialize :ranges, Array
- belongs_to :legislation
+ belongs_to :legacy_legislation
belongs_to :user
def permissions
diff --git a/app/models/legacy_legislation.rb b/app/models/legacy_legislation.rb
new file mode 100644
index 000000000..ddc267e3a
--- /dev/null
+++ b/app/models/legacy_legislation.rb
@@ -0,0 +1,3 @@
+class LegacyLegislation < ActiveRecord::Base
+ has_many :annotations
+end
diff --git a/app/models/legislation.rb b/app/models/legislation.rb
deleted file mode 100644
index d918c0255..000000000
--- a/app/models/legislation.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Legislation < ActiveRecord::Base
- has_many :annotations
-end
diff --git a/app/views/legacy_legislations/show.html.erb b/app/views/legacy_legislations/show.html.erb
new file mode 100644
index 000000000..ab65649bb
--- /dev/null
+++ b/app/views/legacy_legislations/show.html.erb
@@ -0,0 +1,29 @@
+
+
+
+
+
+ <%= t("legacy_legislation.help.title") %>
+
+
+
+
+ <%= t("legacy_legislation.help.text",
+ sign_in: link_to(t("legacy_legislation.help.text_sign_in"), new_user_session_path),
+ sign_up: link_to(t("legacy_legislation.help.text_sign_up"), new_user_registration_path)).html_safe %>
+ <%= image_tag ("annotator_help.gif"), alt: t("legacy_legislation.help.alt") %>
+
+
+
+
+
+
+
+
+
+ <%= @legacy_legislation.title %>
+ <%= @legacy_legislation.body %>
+
+
+
diff --git a/app/views/legislations/show.html.erb b/app/views/legislations/show.html.erb
deleted file mode 100644
index 006d91bb2..000000000
--- a/app/views/legislations/show.html.erb
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
- <%= t("legislation.help.title") %>
-
-
-
-
- <%= t("legislation.help.text",
- sign_in: link_to(t("legislation.help.text_sign_in"), new_user_session_path),
- sign_up: link_to(t("legislation.help.text_sign_up"), new_user_registration_path)).html_safe %>
- <%= image_tag ("annotator_help.gif"), alt: t("legislation.help.alt") %>
-
-
-
-
-
-
-
-
-
- <%= @legislation.title %>
- <%= @legislation.body %>
-
-
-
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 27d8bac7f..008a1efa4 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -212,7 +212,7 @@ en:
proposal_ballot: Voting
see_all: See proposals
spending_proposals: Spending proposals
- legislation:
+ legacy_legislation:
help:
alt: Select the text you want to comment and press the button with the pencil.
text: To comment this document you must %{sign_in} or %{sign_up}. Then select the text you want to comment and press the button with the pencil.
diff --git a/config/locales/es.yml b/config/locales/es.yml
index a243b759d..d906018ee 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -212,7 +212,7 @@ es:
proposal_ballot: Votaciones
see_all: Ver propuestas
spending_proposals: Presupuestos ciudadanos
- legislation:
+ legacy_legislation:
help:
alt: Selecciona el texto que quieres comentar y pulsa en el botón con el lápiz.
text: Para comentar este documento debes %{sign_in} o %{sign_up}. Después selecciona el texto que quieres comentar y pulsa en el botón con el lápiz.
diff --git a/config/routes.rb b/config/routes.rb
index df1a7c6fb..037b107ae 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -79,7 +79,7 @@ Rails.application.routes.draw do
resources :stats, only: [:index]
- resources :legislations, only: [:show]
+ resources :legacy_legislations, only: [:show], path: 'legislations'
resources :annotations do
get :search, on: :collection
diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb
index 87dc94a2e..9f47873ce 100644
--- a/db/dev_seeds.rb
+++ b/db/dev_seeds.rb
@@ -316,10 +316,6 @@ puts "Creating Valuation Assignments"
SpendingProposal.reorder("RANDOM()").first.valuators << valuator.valuator
end
-puts "Creating Legislation"
-
-Legislation.create!(title: 'Participatory Democracy', body: 'In order to achieve...')
-
puts "Ignoring flags in Debates, comments & proposals"
diff --git a/db/migrate/20161117115841_rename_legislations_to_legacy_legislations.rb b/db/migrate/20161117115841_rename_legislations_to_legacy_legislations.rb
new file mode 100644
index 000000000..d8eaa76c0
--- /dev/null
+++ b/db/migrate/20161117115841_rename_legislations_to_legacy_legislations.rb
@@ -0,0 +1,6 @@
+class RenameLegislationsToLegacyLegislations < ActiveRecord::Migration
+ def change
+ rename_table :legislations, :legacy_legislations
+ rename_column :annotations, :legislation_id, :legacy_legislation_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a93942873..149851a2b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161102133838) do
+ActiveRecord::Schema.define(version: 20161117115841) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -57,10 +57,10 @@ ActiveRecord::Schema.define(version: 20161102133838) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
- t.integer "legislation_id"
+ t.integer "legacy_legislation_id"
end
- add_index "annotations", ["legislation_id"], name: "index_annotations_on_legislation_id", using: :btree
+ add_index "annotations", ["legacy_legislation_id"], name: "index_annotations_on_legacy_legislation_id", using: :btree
add_index "annotations", ["user_id"], name: "index_annotations_on_user_id", using: :btree
create_table "banners", force: :cascade do |t|
@@ -221,7 +221,7 @@ ActiveRecord::Schema.define(version: 20161102133838) do
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
- create_table "legislations", force: :cascade do |t|
+ create_table "legacy_legislations", force: :cascade do |t|
t.string "title"
t.text "body"
t.datetime "created_at", null: false
@@ -550,7 +550,7 @@ ActiveRecord::Schema.define(version: 20161102133838) do
add_index "votes", ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope", using: :btree
add_foreign_key "administrators", "users"
- add_foreign_key "annotations", "legislations"
+ add_foreign_key "annotations", "legacy_legislations"
add_foreign_key "annotations", "users"
add_foreign_key "failed_census_calls", "users"
add_foreign_key "flags", "users"
diff --git a/spec/factories.rb b/spec/factories.rb
index 7b446f3a0..1445ac3c1 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -234,8 +234,8 @@ FactoryGirl.define do
end
end
- factory :legislation do
- sequence(:title) { |n| "Legislation #{n}" }
+ factory :legacy_legislation do
+ sequence(:title) { |n| "Legacy Legislation #{n}" }
body "In order to achieve this..."
end
@@ -243,7 +243,7 @@ FactoryGirl.define do
quote "ipsum"
text "Loremp ipsum dolor"
ranges [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}]
- legislation
+ legacy_legislation
user
end
diff --git a/spec/features/legislation_spec.rb b/spec/features/legacy_legislation_spec.rb
similarity index 57%
rename from spec/features/legislation_spec.rb
rename to spec/features/legacy_legislation_spec.rb
index 93a82e1e9..e2f1ba915 100644
--- a/spec/features/legislation_spec.rb
+++ b/spec/features/legacy_legislation_spec.rb
@@ -1,11 +1,11 @@
require 'rails_helper'
-feature 'Legislation' do
+feature 'Legacy Legislation' do
scenario 'Show' do
- legislation = create(:legislation, title: 'Change the world', body: 'To achieve this...')
+ legacy_legislation = create(:legacy_legislation, title: 'Change the world', body: 'To achieve this...')
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
expect(page).to have_content 'Change the world'
expect(page).to have_content 'To achieve this...'
@@ -17,11 +17,11 @@ feature 'Legislation' do
background { login_as user }
scenario 'Create' do
- legislation = create(:legislation)
+ legacy_legislation = create(:legacy_legislation)
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
- page.find(:css, "#legislation_body").double_click
+ page.find(:css, "#legacy_legislation_body").double_click
page.find(:css, ".annotator-adder button").click
fill_in 'annotator-field-0', with: 'this is my annotation'
page.find(:css, ".annotator-controls a[href='#save']").click
@@ -30,7 +30,7 @@ feature 'Legislation' do
first(:css, ".annotator-hl").click
expect(page).to have_content "this is my annotation"
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
expect(page).to have_css ".annotator-hl"
first(:css, ".annotator-hl").click
@@ -38,10 +38,10 @@ feature 'Legislation' do
end
scenario 'Update' do
- legislation = create(:legislation)
- annotation = create(:annotation, legislation: legislation, user: user, text: "my annotation")
+ legacy_legislation = create(:legacy_legislation)
+ annotation = create(:annotation, legacy_legislation: legacy_legislation, user: user, text: "my annotation")
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
expect(page).to have_css ".annotator-hl"
page.find(:css, ".annotator-hl").click
@@ -55,17 +55,17 @@ feature 'Legislation' do
page.find(:css, ".annotator-hl").click
expect(page).to have_content "edited annotation"
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
page.find(:css, ".annotator-hl").click
expect(page).to have_content "edited annotation"
end
scenario 'Destroy' do
- legislation = create(:legislation)
- annotation = create(:annotation, legislation: legislation, user: user)
+ legacy_legislation = create(:legacy_legislation)
+ annotation = create(:annotation, legacy_legislation: legacy_legislation, user: user)
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
expect(page).to have_css ".annotator-hl"
@@ -76,11 +76,11 @@ feature 'Legislation' do
end
scenario 'Search' do
- legislation = create(:legislation)
- annotation1 = create(:annotation, legislation: legislation, text: "my annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}])
- annotation2 = create(:annotation, legislation: legislation, text: "my other annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>12, "end"=>"/div[1]", "endOffset"=>19}])
+ legacy_legislation = create(:legacy_legislation)
+ annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}])
+ annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>12, "end"=>"/div[1]", "endOffset"=>19}])
- visit legislation_path(legislation)
+ visit legacy_legislation_path(legacy_legislation)
expect(page).to have_css ".annotator-hl"
first(:css, ".annotator-hl").click