Skip to content

Commit

Permalink
Merge branch 'master' into add_settlement_abilities
Browse files Browse the repository at this point in the history
Conflicts:
	db/nomenclatures/db.xml
  • Loading branch information
Brice TEXIER committed Nov 5, 2016
2 parents 3d4396a + 7452bdb commit 86987d5
Show file tree
Hide file tree
Showing 298 changed files with 3,665 additions and 5,021 deletions.
35 changes: 18 additions & 17 deletions Gemfile.lock
Expand Up @@ -57,7 +57,8 @@ GEM
tzinfo (~> 1.1)
acts_as_list (0.8.2)
activerecord (>= 3.0)
addressable (2.4.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
agric (3.0.1)
railties (>= 3.2, < 6.0)
sass-rails
Expand All @@ -73,7 +74,7 @@ GEM
sidekiq (>= 2.11)
arel (6.0.3)
ast (2.3.0)
autoprefixer-rails (6.5.0.2)
autoprefixer-rails (6.5.1.1)
execjs
awesome_nested_set (3.0.3)
activerecord (>= 4.0.0, < 5)
Expand All @@ -96,7 +97,7 @@ GEM
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
browser (2.2.0)
browser (2.3.0)
builder (3.2.2)
burisu-docsplit (0.7.9)
byebug (9.0.6)
Expand Down Expand Up @@ -140,7 +141,7 @@ GEM
tins (>= 1.6.0, < 2)
daemons (1.2.4)
database_cleaner (1.5.3)
dbf (3.0.7)
dbf (3.0.8)
debug_inspector (0.0.2)
deep_cloneable (2.2.2)
activerecord (>= 3.1.0, < 5.2.0)
Expand All @@ -155,9 +156,9 @@ GEM
actionmailer (>= 4.0.0)
devise (>= 4.0.0)
docile (1.1.5)
domain_name (0.5.20160826)
domain_name (0.5.20161021)
unf (>= 0.0.5, < 1.0.0)
enumerize (2.0.0)
enumerize (2.0.1)
activesupport (>= 3.2)
erubis (2.7.0)
eventmachine (1.2.0.1)
Expand Down Expand Up @@ -194,7 +195,7 @@ GEM
hpricot (0.8.6)
http-cookie (1.0.3)
domain_name (~> 0.5)
http_accept_language (2.0.5)
http_accept_language (2.1.0)
httpi (2.4.2)
rack
socksify
Expand Down Expand Up @@ -252,7 +253,7 @@ GEM
mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.9.1)
minitest-reporters (1.1.11)
minitest-reporters (1.1.12)
ansi
builder
minitest (>= 5.0)
Expand Down Expand Up @@ -307,6 +308,7 @@ GEM
unicode (~> 0.4.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
public_suffix (2.0.3)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.4)
Expand Down Expand Up @@ -349,8 +351,7 @@ GEM
rainbow (2.1.0)
raindrops (0.17.0)
rake (11.3.0)
rdoc (4.2.2)
json (~> 1.4)
rdoc (4.3.0)
redis (3.3.1)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
Expand All @@ -372,7 +373,7 @@ GEM
rgeo-shapefile (0.4.1)
dbf (~> 3.0)
rgeo (~> 0.3)
rjb (1.5.4)
rjb (1.5.5)
rjb-loader (0.0.2)
rails (>= 3.2)
rjb (>= 1.4.8)
Expand All @@ -383,7 +384,7 @@ GEM
roo (2.5.1)
nokogiri (~> 1)
rubyzip (~> 1.1, < 2.0.0)
rubocop (0.43.0)
rubocop (0.45.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
Expand Down Expand Up @@ -412,7 +413,7 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
selenium-webdriver (2.53.4)
selenium-webdriver (3.0.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
Expand All @@ -422,10 +423,10 @@ GEM
iban-tools
sexp_processor (4.7.0)
shoulda-context (1.2.1)
sidekiq (4.2.2)
sidekiq (4.2.5)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (~> 1.5)
rack-protection (>= 1.5.0)
redis (~> 3.2, >= 3.2.1)
sidekiq-cron (0.4.4)
redis-namespace (>= 1.5.2)
Expand Down Expand Up @@ -482,14 +483,14 @@ GEM
railties (>= 3.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.2)
uglifier (3.0.3)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unicode (0.4.4.2)
unicode-display_width (1.1.1)
unicorn (5.1.0)
unicorn (5.2.0)
kgio (~> 2.6)
raindrops (~> 0.7)
uuidtools (2.1.5)
Expand Down
5 changes: 0 additions & 5 deletions PITCHME.md

This file was deleted.

3 changes: 0 additions & 3 deletions PITCHME.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion Procfile
@@ -1,2 +1,2 @@
web: bundle exec unicorn_rails
job: bundle exec sidekiq -c 2
job: bundle exec sidekiq
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.14.0
2.15.1
4 changes: 2 additions & 2 deletions app/assets/javascripts/core_ext.js.coffee
Expand Up @@ -29,8 +29,8 @@ Math.round2 = (number, round = 1) ->
Math.humanize = (value, power = 0) ->
return Math.round(value)
# return Math.round(value / Math.pow(10, power)) + "e#{power}"
size = Math.round(power / 3)
return Math.round(value / Math.pow(10, 3 * size)) + "pnµm KMGTPE"[size + 4]
# size = Math.round(power / 3)
# return Math.round(value / Math.pow(10, 3 * size)) + "pnµm KMGTPE"[size + 4]

Math.ceil2 = (number, round = 1) ->
return round * Math.ceil(number / round)
Expand Down
Expand Up @@ -4,9 +4,11 @@ module V1
class InterventionParticipationsController < Api::V1::BaseController
def create
params = permitted_params
return render json: :unprocessable_entity if params.blank?
return render json: { message: :unprocessable_entity }, status: :unprocessable_entity if params.blank?

intervention = Intervention.find(params[:request_intervention_id]).initialize_record
intervention = Intervention.find(params[:request_intervention_id]).initialize_record(state: :in_progress)
intervention.creator_id = current_user
intervention.created_at = Time.zone.now
intervention.save!

participation = intervention.participations.find_or_initialize_by(
Expand All @@ -17,6 +19,7 @@ def create
participation.state = params[:state]
participation.save!

params[:working_periods] ||= []
params[:working_periods].each do |wp_params|
period = participation.working_periods.find_or_initialize_by(
**wp_params
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/api/v1/interventions_controller.rb
Expand Up @@ -35,7 +35,15 @@ def index
end
@interventions = @interventions.with_doers(user.worker)
end

return render json: { message: :no_worker_account.tl }, status: :precondition_required if user && user.worker.nil?

if nature == 'request'
@interventions = @interventions
.joins('LEFT JOIN interventions record_interventions_interventions ON record_interventions_interventions.request_intervention_id = interventions.id')
.joins('LEFT JOIN intervention_participations ON record_interventions_interventions.id = intervention_participations.intervention_id')
.joins('LEFT JOIN products AS workers_included ON intervention_participations.product_id = workers_included.id')
.where('workers_included.id IS NULL OR workers_included.id != ?', user.worker.id)
if params[:with_interventions]
if params[:with_interventions] == 'true'
@interventions = @interventions.where(id: Intervention.select(:request_intervention_id))
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/plant_countings_controller.rb
Expand Up @@ -14,7 +14,7 @@ def create
protected

def permitted_params
super.permit(:comment, :plant_density_abacus_item_id, :average_value, :read_at, :plant_id, items_attributes: [:value])
super.permit(:comment, :plant_density_abacus_item_id, :average_value, :read_at, :number, :nature, :plant_id, items_attributes: [:value])
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/backend/base_controller.rb
Expand Up @@ -270,12 +270,12 @@ def search_conditions(search = {}, options = {})
code << "#{variable}.to_s.lower.split(/\\s+/).each do |kw|\n"
code << " kw = '%'+kw+'%'\n"
filters = columns.collect do |x|
'LOWER(CAST(' + x.to_s + ' AS VARCHAR)) ILIKE ?'
'unaccent(' + x.to_s + '::VARCHAR) ILIKE unaccent(?)'
end
exp_count = columns.size
if options[:expressions]
filters += options[:expressions].collect do |x|
x.to_s + ' ILIKE ?'
'unaccent(' + x.to_s + ') ILIKE unaccent(?)'
end
exp_count += options[:expressions].count
end
Expand Down
81 changes: 81 additions & 0 deletions app/controllers/backend/contracts_controller.rb
@@ -0,0 +1,81 @@
# == License
# Ekylibre - Simple agricultural ERP
# Copyright (C) 2008-2011 Brice Texier, Thibaud Merigon
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

module Backend
class ContractsController < Backend::BaseController
manage_restfully currency: 'Preference[:currency]'.c

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

# params:
# :q Text search
# :state State search
# :period Two dates with "_" separator
def self.conditions
code = ''
code = search_conditions(contracts: [:pretax_amount, :number, :description], entities: [:number, :full_name]) + " ||= []\n"
code << "if params[:responsible_id].to_i > 0\n"
code << " c[0] += \" AND \#{Contract.table_name}.responsible_id = ?\"\n"
code << " c << params[:responsible_id]\n"
code << "end\n"
code << "c\n "
code.c
end

list(conditions: conditions, joins: :supplier, line_class: :status, order: { created_at: :desc, number: :desc }) do |t|
t.action :edit
t.action :destroy, if: :destroyable?
t.column :number, url: true
t.column :reference_number, url: true
t.column :created_at
t.column :started_on
t.column :stopped_on, hidden: true
t.column :supplier, url: true
t.column :responsible, url: true, hidden: true
t.column :description, hidden: true
t.status
t.column :state_label
t.column :pretax_amount, currency: true
end

list(:items, model: :contract_items, conditions: { contract_id: 'params[:id]'.c }) do |t|
t.column :variant, url: true
t.column :quantity
t.column :unit_pretax_amount, currency: true
t.column :pretax_amount, currency: true
end

list(:parcels, model: :parcels, children: :items, conditions: { contract_id: 'params[:id]'.c }) do |t|
t.action :edit, if: :draft?
t.action :destroy, if: :draft?
t.column :number, url: true
t.column :reference_number, url: true
t.column :content_sentence, label: :contains
t.column :address, hidden: true
t.column :given_at
t.status
t.column :pretax_amount, currency: true
end

Contract.state_machine.events.each do |event|
define_method event.name do
fire_event(event.name)
end
end
end
end
3 changes: 1 addition & 2 deletions app/controllers/backend/dashboards_controller.rb
Expand Up @@ -65,6 +65,7 @@ def sandbox
# This action permits to search across all the main data of the application
# TODO: Clean this!!!
def search
self.class.build_centralizing_query unless @@centralizing_query
per_page = 10
page = params[:page].to_i
page = 1 if page.zero?
Expand Down Expand Up @@ -181,7 +182,5 @@ def self.build_centralizing_query

@@centralizing_query = '(' + queries.join(') UNION ALL (') + ')'
end

build_centralizing_query
end
end
33 changes: 33 additions & 0 deletions app/controllers/backend/entities_controller.rb
Expand Up @@ -100,6 +100,21 @@ def self.entities_conditions
# t.column :balance, currency: true, hidden: true
end

list(:contracts, conditions: { supplier_id: 'params[:id]'.c }, order: { created_at: :desc }) do |t|
t.action :edit
t.action :destroy, if: :destroyable?
t.column :number, url: true
t.column :reference_number, url: true
t.column :created_at
t.column :started_on
t.column :stopped_on, hidden: true
t.column :responsible, url: true, hidden: true
t.column :description, hidden: true
t.status
t.column :state_label
t.column :pretax_amount, currency: true
end

list(:event_participations, conditions: { participant_id: 'params[:id]'.c }, order: { created_at: :desc }) do |t|
t.action :edit
t.action :destroy
Expand Down Expand Up @@ -162,6 +177,24 @@ def self.entities_conditions
t.column :amount, currency: true, url: true
end

list(:incoming_parcels, model: :parcels, conditions: { sender_id: 'params[:id]'.c }, per_page: 5, order: { created_at: :desc }, line_class: :status) do |t|
t.column :number, url: true
t.column :content_sentence, label: :contains
t.column :planned_at
t.column :created_at, hidden: true
t.column :state, label_method: :human_state_name
t.column :purchase, url: true
end

list(:outgoing_parcels, model: :parcels, conditions: { recipient_id: 'params[:id]'.c }, per_page: 5, order: { created_at: :desc }, line_class: :status) do |t|
t.column :number, url: true
t.column :content_sentence, label: :contains
t.column :planned_at
t.column :created_at, hidden: true
t.column :state, label_method: :human_state_name
t.column :sale, url: true
end

list(:purchases, conditions: { supplier_id: 'params[:id]'.c }, line_class: "(RECORD.affair_closed? ? nil : 'warning')".c) do |t|
# t.action :show, url: {format: :pdf}, image: :print, hidden: true
t.action :edit
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/backend/integrations_controller.rb
Expand Up @@ -16,7 +16,7 @@ def new
head :unprocessable_entity
return
end
if existing = Integration.find_by_nature(params[:nature])
if existing = Integration.find_by(nature: params[:nature])
redirect_to action: :edit, controller: :integrations, id: existing.id
return
end
Expand All @@ -32,7 +32,7 @@ def edit
end

def destroy
return unless existing = Integration.find_by_nature(params[:nature])
return unless existing = Integration.find_by(nature: params[:nature])
redirect_to action: :index, controller: :integrations if existing.destroy!
end

Expand Down

0 comments on commit 86987d5

Please sign in to comment.