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.
This commit is contained in:
Javi Martín
2019-11-01 20:08:46 +01:00
parent 71d9ac20e3
commit ac6d50e06b
76 changed files with 221 additions and 1433 deletions

View File

@@ -0,0 +1,7 @@
class Admin::BudgetInvestmentMilestonesController < Admin::MilestonesController
private
def milestoneable
Budget::Investment.find(params[:budget_investment_id])
end
end

View File

@@ -0,0 +1,7 @@
class Admin::BudgetInvestmentProgressBarsController < Admin::ProgressBarsController
private
def progressable
Budget::Investment.find(params[:budget_investment_id])
end
end

View File

@@ -87,7 +87,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
def budget_investment_params
attributes = [:external_url, :heading_id, :administrator_id, :tag_list,
:valuation_tag_list, :incompatible, :visible_to_valuators, :selected,
:milestone_tag_list, tracker_ids: [], valuator_ids: [], valuator_group_ids: []]
:milestone_tag_list, valuator_ids: [], valuator_group_ids: []]
params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment))
end
@@ -101,7 +101,6 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
def load_staff
@admins = @budget.administrators.includes(:user)
@trackers = @budget.trackers.includes(:user).order(description: :asc).order("users.email ASC")
@valuators = @budget.valuators.includes(:user).order(description: :asc).order("users.email ASC")
end

View File

@@ -71,8 +71,7 @@ class Admin::BudgetsController < Admin::BaseController
valid_attributes = [:phase,
:currency_symbol,
administrator_ids: [],
valuator_ids: [],
tracker_ids: []
valuator_ids: []
] + descriptions
params.require(:budget).permit(*valid_attributes, *report_attributes, translation_params(Budget))
end
@@ -83,7 +82,6 @@ class Admin::BudgetsController < Admin::BaseController
def load_staff
@admins = Administrator.includes(:user)
@trackers = Tracker.includes(:user).order(description: :asc).order("users.email ASC")
@valuators = Valuator.includes(:user).order(description: :asc).order("users.email ASC")
end
end

View File

@@ -1,4 +1,4 @@
class Admin::Legislation::MilestonesController < Tracking::MilestonesController
class Admin::Legislation::MilestonesController < Admin::MilestonesController
include FeatureFlags
feature_flag :legislation
@@ -11,4 +11,8 @@ class Admin::Legislation::MilestonesController < Tracking::MilestonesController
def milestoneable
::Legislation::Process.find(params[:process_id])
end
def milestoneable_path
admin_legislation_process_milestones_path(milestoneable)
end
end

View File

@@ -0,0 +1,14 @@
class Admin::Legislation::ProgressBarsController < Admin::ProgressBarsController
include FeatureFlags
feature_flag :legislation
def index
@process = progressable
end
private
def progressable
::Legislation::Process.find(params[:process_id])
end
end

View File

@@ -0,0 +1,72 @@
class Admin::MilestonesController < Admin::BaseController
include Translatable
include ImageAttributes
before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy]
before_action :load_milestone, only: [:edit, :update, :destroy]
before_action :load_statuses, only: [:index, :new, :create, :edit, :update]
helper_method :milestoneable_path
def index
end
def new
@milestone = @milestoneable.milestones.new
end
def create
@milestone = @milestoneable.milestones.new(milestone_params)
if @milestone.save
redirect_to milestoneable_path, notice: t("admin.milestones.create.notice")
else
render :new
end
end
def edit
end
def update
if @milestone.update(milestone_params)
redirect_to milestoneable_path, notice: t("admin.milestones.update.notice")
else
render :edit
end
end
def destroy
@milestone.destroy!
redirect_to milestoneable_path, notice: t("admin.milestones.delete.notice")
end
private
def milestone_params
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
attributes = [:publication_date, :status_id,
translation_params(Milestone),
image_attributes: image_attributes, documents_attributes: documents_attributes]
params.require(:milestone).permit(*attributes)
end
def load_milestoneable
@milestoneable = milestoneable
end
def milestoneable
raise "Implement in subclass"
end
def load_milestone
@milestone = @milestoneable.milestones.find(params[:id])
end
def load_statuses
@statuses = Milestone::Status.all
end
def milestoneable_path
polymorphic_path([:admin, *resource_hierarchy_for(@milestone.milestoneable)])
end
end

View File

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

View File

@@ -0,0 +1,7 @@
class Admin::ProposalMilestonesController < Admin::MilestonesController
private
def milestoneable
Proposal.find(params[:proposal_id])
end
end

View File

@@ -0,0 +1,7 @@
class Admin::ProposalProgressBarsController < Admin::ProgressBarsController
private
def progressable
Proposal.find(params[:proposal_id])
end
end

View File

@@ -1,57 +0,0 @@
class Admin::TrackersController < Admin::BaseController
load_and_authorize_resource
before_action :set_tracker, only: [:show, :edit, :update, :destroy]
def show
@tracker = Tracker.find(params[:id])
end
def index
@trackers = @trackers.page(params[:page])
end
def search
@users = User.search(params[:name_or_email])
.includes(:tracker)
.page(params[:page])
.for_render
end
def create
@tracker = Tracker.new(tracker_params)
@tracker.save!
redirect_to admin_trackers_path
end
def edit
@tracker = Tracker.find(params[:id])
end
def update
@tracker = Tracker.find(params[:id])
if @tracker.update(tracker_params)
notice = t("admin.trackers.form.updated")
redirect_to [:admin, @tracker], notice: notice
else
render :edit
end
end
def destroy
@tracker.destroy!
redirect_to admin_trackers_path
end
private
def set_tracker
@tracker = Tracker.find(params[:id])
end
def tracker_params
params[:tracker][:description] = nil if params[:tracker][:description].blank?
params.require(:tracker).permit(:user_id, :description, :budget_investment_count)
end
end