Renames Legislation model to LegacyLegislation

Renames the model and related stuff from Legislation 
to LegacyLegislation to avoid name clashes with 
the future Legislation module.
This commit is contained in:
Amaia Castro
2016-11-17 15:03:58 +01:00
parent 9e5a55be68
commit 9a9f1da5a0
17 changed files with 79 additions and 77 deletions

View File

@@ -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

View File

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

View File

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

View File

@@ -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

View File

@@ -1,7 +1,7 @@
class Annotation < ActiveRecord::Base
serialize :ranges, Array
belongs_to :legislation
belongs_to :legacy_legislation
belongs_to :user
def permissions

View File

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

View File

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

View File

@@ -0,0 +1,29 @@
<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

@@ -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-legislation">
<sub><span class="icon-edit"></span></sub>&nbsp;
<%= t("legislation.help.title") %>
</a>
<div class="dropdown-pane" id="help-legislation" data-dropdown data-auto-focus="true">
<p>
<%= 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") %>
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 medium-9 small-centered column">
<section data-annotatable-type="legislation"
data-annotatable-id="<%= @legislation.id %>">
<h1 class="text-center"><%= @legislation.title %></h1>
<div id="legislation_body"><%= @legislation.body %></div>
</section>
</div>
</div>