Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ekylibre/ekylibre
Browse files Browse the repository at this point in the history
  • Loading branch information
burisu committed Apr 1, 2014
2 parents db0725e + 31cd1e1 commit dd28076
Show file tree
Hide file tree
Showing 30 changed files with 585 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ GEM
json (~> 1.8)
rdoc (~> 4.0, < 5.0)
sexp_processor (4.4.3)
shoulda-context (1.1.6)
shoulda-context (1.2.0)
simple_calendar (0.1.10)
rails (>= 3.0)
simple_form (3.0.1)
Expand Down
2 changes: 1 addition & 1 deletion app/models/intervention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Intervention < Ekylibre::Record::Base
# where("id IN (SELECT intervention_id FROM #{InterventionCast.table_name} WHERE target_id = ? AND role = ?)", object.id, role.to_s)
# }
scope :with_cast, lambda { |role, object|
where("id IN (SELECT intervention_id FROM #{InterventionCast.table_name} WHERE actor_id = ? AND roles ~ E?)", object.id, "\\\\m#{role}\\\\M")
where(id: InterventionCast.with_cast(role, object).pluck(:intervention_id))
}

before_validation do
Expand Down
4 changes: 4 additions & 0 deletions app/models/intervention_cast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class InterventionCast < Ekylibre::Record::Base
where("roles ~ E?", "\\\\m#{role}\\\\M")
}

scope :with_cast, lambda { |role, object|
self.of_role(role).where(actor_id: object.id)
}

before_validation do
if self.reference
self.roles = self.reference.roles.join(', ')
Expand Down
5 changes: 5 additions & 0 deletions app/models/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Product < Ekylibre::Record::Base
has_many :current_memberships, -> { current }, class_name: "ProductMembership", foreign_key: :product_id
has_one :container, through: :current_localization
has_many :groups, through: :current_memberships
has_one :incoming_delivery_item, class_name: "IncomingDeliveryItem", foreign_key: :product_id

has_attached_file :picture, {
:url => '/backend/:class/:id/picture/:style',
Expand All @@ -134,6 +135,10 @@ class Product < Ekylibre::Record::Base
where(nature_id: ProductNature.can_each(*abilities))
}

scope :of_working_set, lambda { |working_set|
where(nature_id: ProductNature.of_working_set(working_set))
}

scope :of_nature, lambda { |nature|
where(nature_id: nature.id)
}
Expand Down
8 changes: 8 additions & 0 deletions app/models/product_nature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ class ProductNature < Ekylibre::Record::Base
able_to(:and, *abilities)
}

scope :of_working_set, lambda { |working_set|
if working_set == :oenological_regulateds
where("id IN (?) OR id IN (?)", of_variety(:saccharose, :concentrated_rectified_must, :potassium_ferrocyanide).pluck(:id), can('acidify(fermented_juice)', 'alkalinize(fermented_juice)').pluck(:id))
else
raise StandardError, "Invalid working set: #{working_set.inspect}"
end
}

protect(on: :destroy) do
self.variants.any? or self.products.any?
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/product_nature_variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class ProductNatureVariant < Ekylibre::Record::Base
scope :can_each, Proc.new { |*abilities|
where(nature_id: ProductNature.can_each(*abilities))
}
scope :of_working_set, lambda { |working_set|
where(nature_id: ProductNature.of_working_set(working_set))
}

scope :of_natures, lambda { |*natures|
natures.flatten!
for nature in natures
Expand Down
37 changes: 37 additions & 0 deletions config/aggregators/wine_detention_registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<aggregators xmlns="http://www.ekylibre.org/XML/2013/aggregators">
<aggregator name="wine_detention_registry" version="0.0" category="land_parcel_management">
<parameters>
<parameter name="campaigns" type="record-list" of="campaign" default="currents"/>
</parameters>
<section name="campaigns">
<variable name="company" value="Entity.of_company"/>
<property name="entity_name" value="company.full_name"/>
<property name="address" value="company.default_mail_address.coordinate"/>
<sections for="campaign" in="campaigns">
<property name="id" of="campaign" level="api"/>
<title name="name" of="campaign"/>
<property name="harvest_year" of="campaign"/>
<!-- looking for all Product in current campaign with oenological_regulateds -->
<sections for="product" in="Product.of_working_set(:oenological_regulateds)" of-type="record">
<title name="name" of="product"/>
<property name="work_number" of="product"/>
<property name="nature_name" of="product"/>
<property name="variant_name" of="product"/>
<property name="born_at" of="product" type="datetime"/>
<property name="received_at" if="product.incoming_delivery_item" value="product.incoming_delivery_item.delivery.received_at" type="datetime"/>
<property name="sender" if="product.incoming_delivery_item" value="product.incoming_delivery_item.delivery.sender.name"/>
<property name="sender_adress" if="product.incoming_delivery_item" value="product.incoming_delivery_item.delivery.sender.default_mail_address.coordinate"/>
<property name="incoming_quantity" if="product.incoming_delivery_item" value="product.incoming_delivery_item.population"/>
<matrix name="interventions" for="intervention" in="Intervention.with_cast('addition-input', product).of_campaign(campaign).order(:started_at)">
<cell name="name" of="intervention"/>
<cell name="started_at" of="intervention" type="datetime"/>
<cell name="stopped_at" of="intervention" type="datetime"/>
<cell name="input_quantity" value="intervention.casts.of_role('addition-input').first.population"/>
<cell name="input_unit_name" value="product.unit_name"/>
</matrix>
</sections>
</sections>
</section>
</aggregator>
</aggregators>
1 change: 1 addition & 0 deletions config/locales/arb/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ arb:
in_name: "الاختصارات تشمل اسم الملف" #?
included: "تضمنت"
# incoming_deliveries: "Approvisionnements"
# incoming_delivery_item: "Incoming delivery item"
# incoming_delivery_items: "Éléments d’approvisionnement"
incoming_payment_modes: "طرق تسديد الدفعات"
incoming_payment_uses: "اجزاء الدفعات" #?
Expand Down
42 changes: 41 additions & 1 deletion config/locales/arb/nomenclatures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ arb:
nomenclatures:
abilities:
items:
# acidify: "Acidifier"
# alkalinize: "Alcaliniser"
# blow: "Souffler"
# bunch: "Boteller"
# care: "Soigner"
# catalyze: "Catalyser"
# catch: "Atteler"
# chaptelise: "Chaptaliser"
# clarify: "Clarifier"
# clean: "Nettoyer"
# consume: "Consommer"
# cut: "Couper"
Expand Down Expand Up @@ -1584,13 +1587,21 @@ arb:
# name: "États de la reproduction mammifère"
molecules:
items:
# calcium_carbonate: "Carbonate de calcium "
# copper_sulfate: "Sulfate de cuivre (Ⅰ)"
# dicopper_sulfate: "Sulfate de cuivre (Ⅱ)"
# dinitrogen: "Diazote"
# diphosphorus_pentoxide: "Diphosphorus pentoxide"
# glucose: "Glucose"
# lactic_acid: "Acide lactique "
# malic_acid: "Acide malique"
# phosphate: "Phosphate"
# potash: "Potasse"
# potassium_bicarbonate: "Bicarbonate de potassium"
# potassium_ferrocyanide: "Ferrocyanide de potassium"
# sodium_chloride: "Chlorure de sodium"
# sucrose: "Sucrose"
# tetraphosphorus_decoxide: "Tetraphosphorus decoxide"
# name: "Molécules"
property_natures:
# formula: "Formule"
Expand Down Expand Up @@ -1902,6 +1913,7 @@ arb:
# bulk_kg_animal_food: "Aliment en vrac (kg)"
# bulk_urea_46: "Engrais Urée 46% VRAC"
# bulk_wheat_straw: "Paille de blé en vrac"
# calcium_carbonate_25kg: "Carbonate de calcium - 25kg"
# calf: "Veau"
# caphorn_wheat_crop: "Culture de blé tendre Caphorn"
# caphorn_wheat_seed_25: "Semence de blé tendre Caphorn"
Expand All @@ -1915,6 +1927,7 @@ arb:
# cereals_feed_bag_25: "Aliments céréales - sac de 25 kg"
# chemical_fertilizer_division: "Emplacement de stockage des engrais"
# complete_herbicide: "Herbicide total"
# concrete_tank: "Cuve béton"
# coop:ammonitre_33,5%_vr: "ammonitre COOP 33,5% vrac"
# coop:aviator_xpro_5l: "Aviator xpro 5l"
# coop:avoine_d'hiver_une_de_mai_red_25kg: "Semence d'avoine d'hiver une de mai - sac de 25kg"
Expand Down Expand Up @@ -1971,6 +1984,7 @@ arb:
# female_adult_cow: "Vache"
# female_hen_band: "Bande de poule"
# female_young_cow: "Génisse"
# fiberglass_tank: "Cuve en fibre de verre"
# fig_crop: "Culture de figuier"
# fig_seedling: "Plant de figuier"
# food_equipment_division: "Zone de stockage des aliments et du matériels"
Expand Down Expand Up @@ -2017,6 +2031,7 @@ arb:
# implanter: "Planteuse"
# insecticide: "Insecticide"
# irrigation_water: "Eau (irrigation)"
# lactic_acid_25kg: "Acide lactique - 25kg"
# land_parcel: "Parcelle"
# land_parcel_cluster: "Îlot"
# lavender_crop: "Culture de lavande"
Expand All @@ -2028,6 +2043,7 @@ arb:
# male_adult_cow: "Taureau"
# male_hen_band: "Bande de poulet"
# male_young_cow: "Taurillon"
# malic_acid_25kg: "Acide malique - 25kg"
# manager: "Responsable"
# manual_implanter: "Plantoir"
# manure_division: "Fumière"
Expand Down Expand Up @@ -2072,6 +2088,9 @@ arb:
# plum_seedling: "Plant de prunier"
# poaceae_fungicide: "Fongicide céréales/graminées"
# poaceae_herbicide: "Herbicide céréales/graminées"
# polyester_tank: "Cuve en polyester"
# potassium_bicarbonate_25kg: "Bicarbonate de potassium - 25kg"
# potassium_ferrocyanide_25kg: "Ferrocyanide de potassium - 25kg"
# potato_crop: "Culture de pomme de terre"
# pruning_platform: "plate-forme de taille"
# rabbit_manure: "Fumier de lapin"
Expand Down Expand Up @@ -2113,6 +2132,7 @@ arb:
# spring_barley_crop: "Culture d’orge de printemps"
# spring_barley_seed_25: "Semence d’orge de printemps - sac de 25kg"
# spring_oat_crop: "Culture d’avoine de printemps"
# stainless_steel_tank: "Cuve en acier inox"
# strawberry_crop: "Culture de fraisier"
# strawberry_seedling: "Plant de fraisier"
# subsoil_plow: "Sous soleuse"
Expand All @@ -2131,7 +2151,8 @@ arb:
# urban_compost: "Compost urbain"
# vine_grape_berry: "Grappe de raisin"
# vine_grape_crop: "Culture de vigne"
# vine_grape_must: "Mout de raisin"
# vine_grape_juice: "Jus de raisin"
# vine_grape_must: "Moût de raisin"
# vine_residu: "Co-produit du raisin"
# walnut_crop: "Culture de noyer"
# wheat_crop: "Culture de blé"
Expand All @@ -2140,6 +2161,7 @@ arb:
# wheat_straw_big_rectangular_bales: "Botte de paille de blé - botte grand format"
# wheat_straw_round_bales: "Botte de paille de blé - balle ronde"
# wheat_straw_small_rectangular_bales: "Botte de paille de blé - botte petit format"
# white_sugar_25kg: "Sucre blanc - 25kg"
# wine: "Vin"
# wine_press: "Pressoir"
# wine_vinasse: "Vinasse de distillerie"
Expand Down Expand Up @@ -2177,6 +2199,7 @@ arb:
# cattle_herd: "Troupeau de bovins"
# cereal_crop: "Culture de céréales"
# chemical_fertilizer: "Engrais minéral"
# clarification_solution: "Solution clarifiante"
# complete_sower: "Semoir équipé"
# crop: "Culture"
# cultivable_zone: "Zone cultivable"
Expand All @@ -2188,6 +2211,7 @@ arb:
# female_adult_cattle_herd: "Troupeau de vaches"
# female_adult_cow: "Vache"
# female_young_cow: "Génisse"
# fermented_grape_juice: "Jus fermenté de raisin"
# fertilizer_division: "Zone de stockage des engrais"
# flower_crop: "Culture florale"
# food_distributor: "Matériel de distribution d’aliments"
Expand All @@ -2205,6 +2229,7 @@ arb:
# grain: "Céréale"
# grain_crop: "Culture à graines"
# grape: "Raisin"
# grape_juice: "Jus de raisin"
# grape_reaper: "Machine à vendanger"
# grass: "Herbe"
# hay_rake: "Andaineur"
Expand Down Expand Up @@ -2260,13 +2285,16 @@ arb:
# spreader: "Épandeur à engrais"
# spreader_trailer: "Épandeur à fumier"
# straw: "Paille"
# sugar: "Sucre"
# superficial_plow: "Déchaumeuse"
# technician: "Technicien"
# tractor: "Tracteur"
# trailer: "Remorque"
# usual_vine_seedling: "Plant de vigne traditionnel"
# walnut_crop: "Culture d’arbre à coques"
# wine: "Vin"
# wine_acidifying: "Acidifiant (vin)"
# wine_alkalinizing: "Alcalinisant (vin)"
# wine_crop: "Vigne"
# wine_press: "Pressoir (vin)"
# wine_tank: "Cuve à vin"
Expand Down Expand Up @@ -2572,6 +2600,7 @@ arb:
# cichorium: "Chicoré"
# cleaner: "Rabot"
# compost: "Compost"
# concentrated_rectified_must: "Moût concentré rectifié"
# corabel: "Corabel"
# corylus: "Corylus"
# corylus_avellana: "Corylus avellana"
Expand All @@ -2593,6 +2622,7 @@ arb:
# fabaceae: "Fabaceae"
# fercoril_corabel: "Fercoril corabel"
# feriale: "Feriale"
# fermented_juice: "Jus fermenté"
# fertile_coutard: "Fertile coutard"
# ficus: "Ficus"
# ficus_carica: "Ficus carica"
Expand Down Expand Up @@ -2679,6 +2709,8 @@ arb:
# poa: "Prairie"
# poaceae: "Graminée"
# pollen: "Pollen"
# pomace: "Résidu (Tourteau, Marc)"
# potassium_ferrocyanide: "Ferrocyanure de potassium"
# preparation: "Préparation"
# press: "Pressoir"
# product: "Produit"
Expand Down Expand Up @@ -2727,6 +2759,7 @@ arb:
# saccharomyces_cerevisiae: "Saccharomyces cerevisiae"
# saccharomyces_cerevisiae_jb3: "Saccharomyces cerevisiae - jb3"
# saccharomycetaceae: "Saccharomycetaceae"
# saccharose: "Saccharose"
# salmo: "Salmonidé"
# salt: "Sel"
# sand: "Sable"
Expand All @@ -2740,12 +2773,15 @@ arb:
# slurry: "Lisier"
# solanaceae: "Solanaceae"
# solanum: "Pomme de terre"
# solanum_tuberosum: "Solanum tuberosum"
# solanum_tuberosum_agata: "Solanum tuberosum - Agata"
# sorghum: "Sorgho"
# sower: "Semoir"
# sprayer: "Pulvérisateur"
# spreader: "Épandeur"
# straw: "Paille"
# sub_zone: "Sous zone"
# sugar: "Sucre"
# sus: "Porcin"
# tank: "Réservoir"
# tonda_giffoni: "Tonda giffoni"
Expand Down Expand Up @@ -2838,5 +2874,9 @@ arb:
varieties-plant: #?
varieties-poaceae: #?
varieties-triticum_aestivum: #?
working_sets:
items:
# oenological_regulateds: "Produits oenologiques détenus"
property_natures: #?
procedures: #?
variables: #?
1 change: 1 addition & 0 deletions config/locales/eng/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ eng:
included: "Included"
income_reasons: "Income reasons" #?
incoming_deliveries: "Incoming deliveries"
# incoming_delivery_item: "Incoming delivery item"
# incoming_delivery_items: "Éléments d’approvisionnement"
incoming_delivery_lines: "Incoming delivery lines" #?
incoming_delivery_modes: "Incoming delivery modes" #?
Expand Down
Loading

0 comments on commit dd28076

Please sign in to comment.