Update to Redmine 5/Rails 6
This commit is contained in:
parent
71bfc5a33a
commit
a784ca6514
@ -1,4 +1,4 @@
|
||||
module Concerns::Finders
|
||||
module Finders
|
||||
private
|
||||
|
||||
def find_goal(id = params[:id])
|
||||
|
@ -5,7 +5,7 @@ class FoodsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id,
|
||||
|
@ -3,7 +3,7 @@ class GoalsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create]
|
||||
before_action :find_goal, only: [:edit, :update, :destroy]
|
||||
|
@ -1,5 +1,5 @@
|
||||
class IngredientsController < ApplicationController
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :authorize
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ class MealsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create]
|
||||
before_action :find_quantity_by_quantity_id, only: [:toggle_exposure]
|
||||
|
@ -1,5 +1,5 @@
|
||||
class MeasurementRoutinesController < ApplicationController
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :find_measurement_routine, only: [:show, :edit]
|
||||
before_action :authorize
|
||||
|
@ -3,7 +3,7 @@ class MeasurementsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create, :filter]
|
||||
|
@ -3,7 +3,7 @@ class QuantitiesController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create, :filter, :parents]
|
||||
@ -123,7 +123,7 @@ class QuantitiesController < ApplicationController
|
||||
end
|
||||
|
||||
def prepare_quantities
|
||||
@quantities = @project.quantities.filter(@project, session[:q_filters])
|
||||
@quantities = @project.quantities.apply_filter(@project, session[:q_filters])
|
||||
.includes(:exposures, :formula, :parent)
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ class ReadoutsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :find_measurement_routine_by_measurement_routine_id,
|
||||
only: [:index, :toggle_exposure]
|
||||
|
@ -3,7 +3,7 @@ class TargetsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
helper :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :find_goal_by_goal_id, only: [:index, :new, :create, :show, :edit, :update,
|
||||
:destroy, :reapply, :toggle_exposure]
|
||||
|
@ -2,7 +2,7 @@ class UnitsController < ApplicationController
|
||||
layout 'body_tracking'
|
||||
menu_item :body_trackers
|
||||
|
||||
include Concerns::Finders
|
||||
include Finders
|
||||
|
||||
before_action :find_project_by_project_id, only: [:index, :create]
|
||||
before_action :find_unit, only: [:destroy]
|
||||
|
@ -74,7 +74,7 @@ class Quantity < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# TODO: move as an association extension module
|
||||
def self.filter(project, filters)
|
||||
def self.apply_filter(project, filters)
|
||||
quantities = all
|
||||
|
||||
if filters[:domain].present?
|
||||
|
@ -6,4 +6,4 @@
|
||||
<%= render partial: 'layouts/sidebar' %>
|
||||
<% end %>
|
||||
|
||||
<%= render :file => "layouts/base" %>
|
||||
<%= render template: "layouts/base" %>
|
||||
|
8
init.rb
8
init.rb
@ -1,8 +1,6 @@
|
||||
(Rails::VERSION::MAJOR < 5 ? ActionDispatch : ActiveSupport)::Reloader.to_prepare do
|
||||
Project.include BodyTracking::ProjectPatch
|
||||
CollectiveIdea.include BodyTracking::AwesomeNestedSetPatch
|
||||
ActiveSupport::TestCase.include BodyTracking::PluginFixturesLoader if Rails.env == 'test'
|
||||
end
|
||||
Project.include BodyTracking::ProjectPatch
|
||||
CollectiveIdea.include BodyTracking::AwesomeNestedSetPatch
|
||||
ActiveSupport::TestCase.include BodyTracking::PluginFixturesLoader if Rails.env == 'test'
|
||||
|
||||
Redmine::Plugin.register :body_tracking do
|
||||
name 'Body tracking plugin'
|
||||
|
@ -9,7 +9,7 @@ module BodyTracking::ProjectPatch
|
||||
has_many :foods, -> { order "foods.name" }, dependent: :destroy,
|
||||
extend: BodyTracking::ItemsWithQuantities
|
||||
has_many :nutrient_exposures, -> { where view_type: "Nutrient" }, dependent: :destroy,
|
||||
foreign_key: :view_id, foreign_type: :view_type,
|
||||
foreign_key: :view_id,
|
||||
class_name: 'Exposure', extend: BodyTracking::TogglableExposures
|
||||
has_many :nutrient_quantities, -> { order "lft" }, through: :nutrient_exposures,
|
||||
source: 'quantity'
|
||||
@ -24,7 +24,7 @@ module BodyTracking::ProjectPatch
|
||||
has_many :meal_foods, through: :meal_ingredients, source: 'food',
|
||||
extend: BodyTracking::ItemsWithQuantities
|
||||
has_many :meal_exposures, -> { where view_type: "Meal" }, dependent: :destroy,
|
||||
foreign_key: :view_id, foreign_type: :view_type,
|
||||
foreign_key: :view_id,
|
||||
class_name: 'Exposure', extend: BodyTracking::TogglableExposures
|
||||
has_many :meal_quantities, -> { order "lft" }, through: :meal_exposures,
|
||||
source: 'quantity'
|
||||
|
Reference in New Issue
Block a user