Merge branch 'legislation-module-stable' into sandbox-html
This commit is contained in:
@@ -2,7 +2,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
|
||||
has_filters %w{all with_active with_inactive}, only: :index
|
||||
|
||||
before_action :find_banner, only: [:edit, :update, :destroy]
|
||||
before_action :banner_styles, only: [:edit, :new, :create, :update]
|
||||
before_action :banner_imgs, only: [:edit, :new, :create, :update]
|
||||
|
||||
@@ -24,7 +23,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def update
|
||||
@banner.assign_attributes(banner_params)
|
||||
if @banner.update(banner_params)
|
||||
redirect_to admin_banners_path
|
||||
else
|
||||
@@ -43,10 +41,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at)
|
||||
end
|
||||
|
||||
def find_banner
|
||||
@banner = Banner.find(params[:id])
|
||||
end
|
||||
|
||||
def banner_styles
|
||||
@banner_styles = Setting.all.banner_style.map { |banner_style| [banner_style.value, banner_style.key.split('.')[1]] }
|
||||
end
|
||||
|
||||
@@ -31,7 +31,6 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
|
||||
|
||||
def draft_version_params
|
||||
params.require(:legislation_draft_version).permit(
|
||||
:legislation_process_id,
|
||||
:title,
|
||||
:changelog,
|
||||
:status,
|
||||
|
||||
39
app/controllers/admin/legislation/questions_controller.rb
Normal file
39
app/controllers/admin/legislation/questions_controller.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
class Admin::Legislation::QuestionsController < Admin::Legislation::BaseController
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
load_and_authorize_resource :question, class: "Legislation::Question", through: :process
|
||||
|
||||
def index
|
||||
@questions = @process.questions
|
||||
end
|
||||
|
||||
def create
|
||||
@question.author = current_user
|
||||
if @question.save
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @question.update(question_params)
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@question.destroy
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def question_params
|
||||
params.require(:legislation_question).permit(
|
||||
:title,
|
||||
question_options_attributes: [:id, :value, :_destroy]
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,32 @@
|
||||
class Legislation::ProcessesController < Legislation::BaseController
|
||||
has_filters %w{open next past}, only: :index
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@current_filter ||= 'open'
|
||||
@processes = ::Legislation::Process.send(@current_filter).page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def draft_publication
|
||||
phase :draft_publication
|
||||
end
|
||||
|
||||
def allegations
|
||||
phase :allegations
|
||||
end
|
||||
|
||||
def final_version_publication
|
||||
phase :final_version_publication
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def phase(phase)
|
||||
@process = ::Legislation::Process.find(params[:process_id])
|
||||
@phase = phase
|
||||
render :phase
|
||||
end
|
||||
end
|
||||
|
||||
12
app/controllers/legislation/questions_controller.rb
Normal file
12
app/controllers/legislation/questions_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Legislation::QuestionsController < Legislation::BaseController
|
||||
load_and_authorize_resource :process
|
||||
load_and_authorize_resource :question, through: :process
|
||||
|
||||
has_orders %w{most_voted newest oldest}, only: :show
|
||||
|
||||
def show
|
||||
@commentable = @question
|
||||
@comment_tree = CommentTree.new(@commentable, params[:page], @current_order)
|
||||
set_comment_flags(@comment_tree.comments)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user