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