LegacyLegislation migration cleanup

These legacy models are not used anymore.
This commit is contained in:
Julian Herrero
2019-01-24 19:36:57 +01:00
parent c6f2aacb51
commit 54e59a8a58
15 changed files with 10 additions and 148 deletions

View File

@@ -1,40 +0,0 @@
class AnnotationsController < ApplicationController
skip_before_action :verify_authenticity_token
load_and_authorize_resource
def create
@annotation = Annotation.new(annotation_params)
@annotation.user = current_user
if @annotation.save
render json: @annotation.to_json(methods: :permissions)
end
end
def update
@annotation = Annotation.find(params[:id])
if @annotation.update_attributes(annotation_params)
render json: @annotation.to_json(methods: :permissions)
end
end
def destroy
@annotation = Annotation.find(params[:id])
@annotation.destroy
render json: { status: :ok }
end
def search
@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
private
def annotation_params
params
.require(:annotation)
.permit(:quote, :text, ranges: [:start, :startOffset, :end, :endOffset])
.merge(legacy_legislation_id: params[:legacy_legislation_id])
end
end

View File

@@ -1,8 +0,0 @@
class LegacyLegislationsController < ApplicationController
load_and_authorize_resource
def show
@legacy_legislation = LegacyLegislation.find(params[:id])
end
end

View File

@@ -57,8 +57,6 @@ module Abilities
can [:search, :create, :index, :destroy], ::Manager can [:search, :create, :index, :destroy], ::Manager
can [:search, :index], ::User can [:search, :index], ::User
can :manage, Annotation
can [:read, :update, :valuate, :destroy, :summary], SpendingProposal can [:read, :update, :valuate, :destroy, :summary], SpendingProposal
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget
can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Group

View File

@@ -92,9 +92,6 @@ module Abilities
can [:create, :show], ProposalNotification, proposal: { author_id: user.id } can [:create, :show], ProposalNotification, proposal: { author_id: user.id }
can :create, Annotation
can [:update, :destroy], Annotation, user_id: user.id
can [:create], Topic can [:create], Topic
can [:update, :destroy], Topic, author_id: user.id can [:update, :destroy], Topic, author_id: user.id

View File

@@ -16,9 +16,7 @@ module Abilities
can :read, Poll::Question can :read, Poll::Question
can [:read, :welcome], Budget can [:read, :welcome], Budget
can :read, SpendingProposal can :read, SpendingProposal
can :read, LegacyLegislation
can :read, User can :read, User
can [:search, :read], Annotation
can [:read], Budget can [:read], Budget
can [:read], Budget::Group can [:read], Budget::Group
can [:read, :print, :json_data], Budget::Investment can [:read, :print, :json_data], Budget::Investment

View File

@@ -1,10 +0,0 @@
class Annotation < ActiveRecord::Base
serialize :ranges, Array
belongs_to :legacy_legislation
belongs_to :user
def permissions
{ update: [user_id], delete: [user_id], admin: [] }
end
end

View File

@@ -1,3 +0,0 @@
class LegacyLegislation < ActiveRecord::Base
has_many :annotations
end

View File

@@ -1,29 +0,0 @@
<div class="row margin-top">
<div class="small-12 column">
<div class="float-right">
<a class="button warning" type="button" data-toggle="help-legacy-legislation">
<sub><span class="icon-edit"></span></sub>&nbsp;
<%= t("legacy_legislation.help.title") %>
</a>
<div class="dropdown-pane" id="help-legacy-legislation" data-dropdown data-auto-focus="true">
<p>
<%= 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") %>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 medium-9 small-centered column">
<section data-annotatable-type="legacy_legislation"
data-annotatable-id="<%= @legacy_legislation.id %>">
<h1 class="text-center"><%= @legacy_legislation.title %></h1>
<div id="legacy_legislation_body"><%= @legacy_legislation.body %></div>
</section>
</div>
</div>

View File

@@ -242,13 +242,6 @@ en:
no_notifications: "You don't have new notifications" no_notifications: "You don't have new notifications"
admin: admin:
watch_form_message: 'You have unsaved changes. Do you confirm to leave the page?' watch_form_message: 'You have unsaved changes. Do you confirm to leave the page?'
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.
text_sign_in: login
text_sign_up: sign up
title: How I can comment this document?
notifications: notifications:
index: index:
empty_notifications: You don't have new notifications. empty_notifications: You don't have new notifications.

View File

@@ -242,13 +242,6 @@ es:
no_notifications: "No tienes notificaciones nuevas" no_notifications: "No tienes notificaciones nuevas"
admin: admin:
watch_form_message: 'Has realizado cambios que no han sido guardados. ¿Seguro que quieres abandonar la página?' watch_form_message: 'Has realizado cambios que no han sido guardados. ¿Seguro que quieres abandonar la página?'
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.
text_sign_in: iniciar sesión
text_sign_up: registrarte
title: '¿Cómo puedo comentar este documento?'
notifications: notifications:
index: index:
empty_notifications: No tienes notificaciones nuevas. empty_notifications: No tienes notificaciones nuevas.

View File

@@ -0,0 +1,5 @@
class DropAnnotationsTable < ActiveRecord::Migration
def change
drop_table :annotations
end
end

View File

@@ -0,0 +1,5 @@
class DropLegacyLegislationsTable < ActiveRecord::Migration
def change
drop_table :legacy_legislations
end
end

View File

@@ -73,19 +73,6 @@ ActiveRecord::Schema.define(version: 20190205131722) do
add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id", using: :btree add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id", using: :btree
add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id", using: :btree add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id", using: :btree
create_table "annotations", force: :cascade do |t|
t.string "quote"
t.text "ranges"
t.text "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.integer "legacy_legislation_id"
end
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 "banner_sections", force: :cascade do |t| create_table "banner_sections", force: :cascade do |t|
t.integer "banner_id" t.integer "banner_id"
t.integer "web_section_id" t.integer "web_section_id"
@@ -545,13 +532,6 @@ ActiveRecord::Schema.define(version: 20190205131722) do
add_index "images", ["imageable_type", "imageable_id"], name: "index_images_on_imageable_type_and_imageable_id", using: :btree add_index "images", ["imageable_type", "imageable_id"], name: "index_images_on_imageable_type_and_imageable_id", using: :btree
add_index "images", ["user_id"], name: "index_images_on_user_id", using: :btree add_index "images", ["user_id"], name: "index_images_on_user_id", using: :btree
create_table "legacy_legislations", force: :cascade do |t|
t.string "title"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "legislation_annotations", force: :cascade do |t| create_table "legislation_annotations", force: :cascade do |t|
t.string "quote" t.string "quote"
t.text "ranges" t.text "ranges"
@@ -1539,8 +1519,6 @@ ActiveRecord::Schema.define(version: 20190205131722) do
end end
add_foreign_key "administrators", "users" add_foreign_key "administrators", "users"
add_foreign_key "annotations", "legacy_legislations"
add_foreign_key "annotations", "users"
add_foreign_key "budget_investments", "communities" add_foreign_key "budget_investments", "communities"
add_foreign_key "documents", "users" add_foreign_key "documents", "users"
add_foreign_key "failed_census_calls", "poll_officers" add_foreign_key "failed_census_calls", "poll_officers"

View File

@@ -1,17 +1,4 @@
FactoryBot.define do FactoryBot.define do
factory :legacy_legislation do
sequence(:title) { |n| "Legacy Legislation #{n}" }
body "In order to achieve this..."
end
factory :annotation do
quote "ipsum"
text "Loremp ipsum dolor"
ranges [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}]
legacy_legislation
user
end
factory :legislation_process, class: 'Legislation::Process' do factory :legislation_process, class: 'Legislation::Process' do
title "A collaborative legislation process" title "A collaborative legislation process"
description "Description of the process" description "Description of the process"

View File

@@ -64,8 +64,6 @@ describe Abilities::Administrator do
it { should be_able_to(:comment_as_administrator, legislation_question) } it { should be_able_to(:comment_as_administrator, legislation_question) }
it { should_not be_able_to(:comment_as_moderator, legislation_question) } it { should_not be_able_to(:comment_as_moderator, legislation_question) }
it { should be_able_to(:manage, Annotation) }
it { should be_able_to(:read, SpendingProposal) } it { should be_able_to(:read, SpendingProposal) }
it { should be_able_to(:update, SpendingProposal) } it { should be_able_to(:update, SpendingProposal) }
it { should be_able_to(:valuate, SpendingProposal) } it { should be_able_to(:valuate, SpendingProposal) }