Skip to content

Commit

Permalink
Merge pull request #2178 from ekylibre/cultivable-zone-traceability-r…
Browse files Browse the repository at this point in the history
…egistry

Cultivable zone traceability registry
  • Loading branch information
Aquaj committed Mar 29, 2019
2 parents 8c6f836 + 643f9ee commit cc43dee
Show file tree
Hide file tree
Showing 8 changed files with 459 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/controllers/backend/cultivable_zones_controller.rb
Expand Up @@ -20,6 +20,8 @@ module Backend
class CultivableZonesController < Backend::BaseController
manage_restfully(t3e: { name: :name })

respond_to :pdf, :odt, :docx, :xml, :json, :html, :csv

unroll

list do |t|
Expand All @@ -45,5 +47,23 @@ class CultivableZonesController < Backend::BaseController
t.column :started_on
t.column :stopped_on
end

# Show one cultivable zone with params_id
def show
return unless @cultivable_zone = find_and_check
t3e @cultivable_zone
respond_with(@cultivable_zone, methods: %i[shape_svg cap_number human_shape_area],
include: [
{ activity_productions: {
methods: %i[name implanted_at harvested_at],
include: {
interventions: {
methods: %i[started_at stopped_at status name human_working_duration human_working_zone_area human_actions_names human_input_quantity_names],
include: {}
}
}
} }
], procs: proc { |options| options[:builder].tag!(:url, backend_cultivable_zone_url(@cultivable_zone)) })
end
end
end
4 changes: 4 additions & 0 deletions app/models/cultivable_zone.rb
Expand Up @@ -76,6 +76,10 @@ class CultivableZone < Ekylibre::Record::Base

alias net_surface_area shape_area

def shape_svg
shape.to_svg(srid: 2154)
end

# get the first object with variety 'plant', availables
def current_cultivations(at = Time.zone.now)
Plant.contained_by(current_supports, at)
Expand Down
9 changes: 9 additions & 0 deletions app/models/intervention.rb
Expand Up @@ -428,6 +428,15 @@ def human_tool_names
tools.map(&:product).compact.map(&:work_name).sort.to_sentence
end

# Returns human inputs names and quantity
def human_input_quantity_names
names = []
inputs.each do |input|
names << "#{input.name} : #{input.human_quantity}"
end
names.sort.to_sentence
end

# Returns human actions names
def human_actions_names
actions.map { |action| Nomen::ProcedureAction.find(action).human_name }
Expand Down
3 changes: 3 additions & 0 deletions app/views/backend/cultivable_zones/show.html.haml
@@ -1,7 +1,10 @@
- main_toolbar do |t|
= t.edit resource
= t.export :cultivable_zone_sheet, key: :work_number
= t.destroy

- main_period_selector(:year)

= main_informations attachment: true do
= mini_map(resource)
= infos do
Expand Down
1 change: 1 addition & 0 deletions config/locales/eng/nomenclatures.yml
Expand Up @@ -1906,6 +1906,7 @@ eng:
animal_list: "Animal list"
animal_sheet: "Animal sheet"
balance_sheet: "Balance sheet"
# cultivable_zone_sheet: "Cultivable zone sheet"
deposit_list: "Deposit list"
entity_sheet: "Entity sheet"
equipment_certification: "Equipment certification"
Expand Down
417 changes: 417 additions & 0 deletions config/locales/fra/reporting/cultivable_zone_sheet.jrxml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions db/nomenclatures/db.xml
Expand Up @@ -1923,6 +1923,7 @@
<item name="animal_list" category="animal_farming"/>
<item name="animal_sheet" category="animal_farming"/>
<item name="balance_sheet" category="accountancy"/>
<item name="cultivable_zone_sheet" category="land_parcel_management"/>
<item name="deposit_list" category="exploitation"/>
<item name="entity_sheet" category="exploitation"/>
<item name="equipment_certification" category="land_parcel_management"/>
Expand Down
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<migration name="Add loan registry">
<item-creation item="document_natures#cultivable_zone_sheet" category="land_parcel_management"/>
</migration>

0 comments on commit cc43dee

Please sign in to comment.