Files
nairobi/app/controllers/admin/progress_bars_controller.rb
Javi Martín ac6d50e06b Remove tracker role
The current tracking section had a few issues:

* When browsing as an admin, this section becomes useless since no
investments are shown
* Browsing investments in the admin section, you're suddenly redirected
to the tracking section, making navigation confusing
* One test related to the officing dashboard failed due to these changes
and had been commented
* Several views and controller methods were copied from other sections,
leading to duplication and making the code harder to maintain
* Tracking routes were defined for proposals and legislation processes,
but in the tracking section only investments were shown
* Probably many more things, since these issues were detected after only
an hour reviewing and testing the code

So we're removing this untested section before releasing version 1.1. We
might add it back afterwards.
2019-11-01 20:08:46 +01:00

70 lines
1.5 KiB
Ruby

class Admin::ProgressBarsController < Admin::BaseController
include Translatable
before_action :load_progressable
before_action :load_progress_bar, only: [:edit, :update, :destroy]
helper_method :progress_bars_index
def index
end
def new
@progress_bar = @progressable.progress_bars.new
end
def create
@progress_bar = @progressable.progress_bars.new(progress_bar_params)
if @progress_bar.save
redirect_to progress_bars_index, notice: t("admin.progress_bars.create.notice")
else
render :new
end
end
def edit
end
def update
if @progress_bar.update(progress_bar_params)
redirect_to progress_bars_index, notice: t("admin.progress_bars.update.notice")
else
render :edit
end
end
def destroy
@progress_bar.destroy!
redirect_to progress_bars_index, notice: t("admin.progress_bars.delete.notice")
end
private
def progress_bar_params
params.require(:progress_bar).permit(allowed_params)
end
def allowed_params
[
:kind,
:percentage,
translation_params(ProgressBar)
]
end
def load_progressable
@progressable = progressable
end
def progressable
raise "This method must be implemented in subclass #{self.class.name}"
end
def load_progress_bar
@progress_bar = progressable.progress_bars.find(params[:id])
end
def progress_bars_index
polymorphic_path([:admin, *resource_hierarchy_for(@progressable), ProgressBar.new])
end
end