Added Proposal model to Legislation
This new Legislation::Proposal model inherits from the original Proposal, as it will behave in a very similar way.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class Admin::Legislation::ProposalsController < Admin::Legislation::BaseController
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
load_and_authorize_resource :proposal, class: "Legislation::Proposal", through: :process
|
||||
|
||||
def index
|
||||
end
|
||||
end
|
||||
@@ -9,6 +9,7 @@ class Legislation::Process < ActiveRecord::Base
|
||||
has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion',
|
||||
foreign_key: 'legislation_process_id'
|
||||
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
has_many :proposals, -> { order(:id) }, class_name: 'Legislation::Proposal', foreign_key: 'legislation_process_id', dependent: :destroy
|
||||
|
||||
validates :title, presence: true
|
||||
validates :start_date, presence: true
|
||||
|
||||
8
app/models/legislation/proposal.rb
Normal file
8
app/models/legislation/proposal.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Legislation::Proposal < Proposal
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id'
|
||||
|
||||
scope :sorted, -> { order('id ASC') }
|
||||
end
|
||||
@@ -287,11 +287,11 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
resources :booths do
|
||||
get :available, on: :collection
|
||||
get :available, on: :collection
|
||||
|
||||
resources :shifts do
|
||||
get :search_officers, on: :collection
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resources :questions
|
||||
@@ -313,6 +313,7 @@ Rails.application.routes.draw do
|
||||
namespace :legislation do
|
||||
resources :processes do
|
||||
resources :questions
|
||||
resources :proposals
|
||||
resources :draft_versions
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user