Added Source perms and routing
Added Quantity displayed defaults
This commit is contained in:
parent
e58952b0e7
commit
ce9f011694
@ -13,4 +13,10 @@ class Quantity < ActiveRecord::Base
|
|||||||
validate if: -> { parent.present? } do
|
validate if: -> { parent.present? } do
|
||||||
errors.add(:parent, :parent_domain_mismatch) unless domain == parent.domain
|
errors.add(:parent, :parent_domain_mismatch) unless domain == parent.domain
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after_initialize do
|
||||||
|
if new_record?
|
||||||
|
self.displayed = false if self.displayed.nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,7 @@ resources :projects do
|
|||||||
resources :ingredients, :only => [:index, :create, :destroy] do
|
resources :ingredients, :only => [:index, :create, :destroy] do
|
||||||
post 'import', on: :collection
|
post 'import', on: :collection
|
||||||
end
|
end
|
||||||
|
resources :sources, :only => [:index, :create, :destroy]
|
||||||
resources :quantities, :only => [:index, :create, :destroy]
|
resources :quantities, :only => [:index, :create, :destroy]
|
||||||
resources :units, :only => [:index, :create, :destroy]
|
resources :units, :only => [:index, :create, :destroy]
|
||||||
end
|
end
|
||||||
|
@ -54,13 +54,13 @@ class CreateUnits < ActiveRecord::Migration
|
|||||||
# https://www.fsai.ie/uploadedFiles/Consol_Reg1169_2011.pdf
|
# https://www.fsai.ie/uploadedFiles/Consol_Reg1169_2011.pdf
|
||||||
# https://www.fsai.ie/legislation/food_legislation/food_information_fic/nutrition_labelling.html
|
# https://www.fsai.ie/legislation/food_legislation/food_information_fic/nutrition_labelling.html
|
||||||
e = Quantity.create project: nil, domain: :diet, parent: nil, name: "Energy",
|
e = Quantity.create project: nil, domain: :diet, parent: nil, name: "Energy",
|
||||||
description: "Total energy"
|
description: "Total energy", displayed: true
|
||||||
|
|
||||||
Quantity.create project: nil, domain: :diet, parent: nil, name: "Proteins",
|
Quantity.create project: nil, domain: :diet, parent: nil, name: "Proteins",
|
||||||
description: "Total amount of proteins"
|
description: "Total amount of proteins", displayed: true
|
||||||
|
|
||||||
f = Quantity.create project: nil, domain: :diet, parent: nil, name: "Fats",
|
f = Quantity.create project: nil, domain: :diet, parent: nil, name: "Fats",
|
||||||
description: "Total lipids, including phospholipids"
|
description: "Total lipids, including phospholipids", displayed: true
|
||||||
f1 = Quantity.create project: nil, domain: :diet, parent: f, name: "Fatty acids",
|
f1 = Quantity.create project: nil, domain: :diet, parent: f, name: "Fatty acids",
|
||||||
description: ""
|
description: ""
|
||||||
f2 = Quantity.create project: nil, domain: :diet, parent: f1, name: "Saturated",
|
f2 = Quantity.create project: nil, domain: :diet, parent: f1, name: "Saturated",
|
||||||
@ -87,7 +87,7 @@ class CreateUnits < ActiveRecord::Migration
|
|||||||
description: "Docosahexaenoic acid"
|
description: "Docosahexaenoic acid"
|
||||||
|
|
||||||
c1 = Quantity.create project: nil, domain: :diet, parent: nil, name: "Carbohydrates",
|
c1 = Quantity.create project: nil, domain: :diet, parent: nil, name: "Carbohydrates",
|
||||||
description: "Total amount of carbohydrates"
|
description: "Total amount of carbohydrates", displayed: true
|
||||||
c2 = Quantity.create project: nil, domain: :diet, parent: c1, name: "Digestible",
|
c2 = Quantity.create project: nil, domain: :diet, parent: c1, name: "Digestible",
|
||||||
description: ""
|
description: ""
|
||||||
c3 = Quantity.create project: nil, domain: :diet, parent: c2, name: "Sugars",
|
c3 = Quantity.create project: nil, domain: :diet, parent: c2, name: "Sugars",
|
||||||
|
2
init.rb
2
init.rb
@ -14,12 +14,14 @@ Redmine::Plugin.register :body_tracking do
|
|||||||
permission :view_body_trackers, {
|
permission :view_body_trackers, {
|
||||||
:body_trackers => [:index],
|
:body_trackers => [:index],
|
||||||
:ingredients => [:index],
|
:ingredients => [:index],
|
||||||
|
:sources => [:index],
|
||||||
:quantities => [:index],
|
:quantities => [:index],
|
||||||
:units => [:index],
|
:units => [:index],
|
||||||
}, read: true
|
}, read: true
|
||||||
permission :manage_common, {
|
permission :manage_common, {
|
||||||
:body_trackers => [:defaults],
|
:body_trackers => [:defaults],
|
||||||
:ingredients => [:create, :destroy, :import],
|
:ingredients => [:create, :destroy, :import],
|
||||||
|
:sources => [:create, :destroy],
|
||||||
:quantities => [:create, :destroy],
|
:quantities => [:create, :destroy],
|
||||||
:units => [:create, :destroy],
|
:units => [:create, :destroy],
|
||||||
}, require: :loggedin
|
}, require: :loggedin
|
||||||
|
Reference in New Issue
Block a user