Skip to content

Commit

Permalink
Merge branch 'master' into change_financial_year_system
Browse files Browse the repository at this point in the history
Conflicts:
	db/structure.sql
  • Loading branch information
Brice TEXIER committed Mar 15, 2017
2 parents 9cc59c6 + 64453a3 commit edfd496
Show file tree
Hide file tree
Showing 28 changed files with 254 additions and 186 deletions.
48 changes: 24 additions & 24 deletions Gemfile.lock
Expand Up @@ -74,7 +74,7 @@ GEM
sidekiq (>= 2.11)
arel (6.0.4)
ast (2.3.0)
autoprefixer-rails (6.7.4)
autoprefixer-rails (6.7.7)
execjs
awesome_nested_set (3.0.3)
activerecord (>= 4.0.0, < 5)
Expand All @@ -97,7 +97,7 @@ GEM
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
bootstrap3-datetimepicker-rails (4.17.43)
bootstrap3-datetimepicker-rails (4.17.47)
momentjs-rails (>= 2.8.1)
browser (2.3.0)
builder (3.2.3)
Expand All @@ -114,7 +114,7 @@ GEM
capybara (>= 2.3.0, < 2.13.0)
json
charlock_holmes (0.7.3)
childprocess (0.6.1)
childprocess (0.6.2)
ffi (~> 1.0, >= 1.0.11)
climate_control (0.1.0)
cocaine (0.5.8)
Expand All @@ -134,7 +134,7 @@ GEM
execjs
coffee-script-source (1.12.2)
colored (1.2)
concurrent-ruby (1.0.4)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
coveralls (0.8.19)
json (>= 1.8, < 3)
Expand All @@ -159,29 +159,29 @@ GEM
actionmailer (>= 4.1.0)
devise (>= 4.0.0)
docile (1.1.5)
domain_name (0.5.20161129)
domain_name (0.5.20170223)
unf (>= 0.0.5, < 1.0.0)
enumerize (2.0.1)
activesupport (>= 3.2)
erubis (2.7.0)
eventmachine (1.2.2)
eventmachine (1.2.3)
exception_notification (4.2.1)
actionmailer (>= 4.0, < 6)
activesupport (>= 4.0, < 6)
execjs (2.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
faraday (0.10.1)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.11.0.1)
faraday (>= 0.7.4, < 1.0)
feedjira (2.1.0)
feedjira (2.1.2)
faraday (>= 0.9)
faraday_middleware (>= 0.9)
loofah (>= 2.0)
sax-machine (>= 1.0)
ffaker (2.5.0)
ffi (1.9.17)
ffi (1.9.18)
figaro (1.1.1)
thor (~> 0.14)
foreman (0.83.0)
Expand All @@ -196,7 +196,7 @@ GEM
builder (>= 2.1.2)
haml (4.0.7)
tilt
hashie (3.5.3)
hashie (3.5.5)
hpricot (0.8.6)
http-cookie (1.0.3)
domain_name (~> 0.5)
Expand All @@ -205,14 +205,14 @@ GEM
rack
socksify
humanize (1.3.0)
i18n (0.8.0)
i18n (0.8.1)
i18n-complements (1.1.0)
i18n (>= 0.6)
i18n-js (3.0.0.rc15)
i18n (~> 0.6, >= 0.6.6)
iban-tools (1.1.0)
jbuilder (2.6.1)
activesupport (>= 3.0.0, < 5.1)
jbuilder (2.6.3)
activesupport (>= 3.0.0, < 5.2)
multi_json (~> 1.2)
jc-validates_timeliness (3.1.1)
timeliness (~> 0.3.7)
Expand Down Expand Up @@ -246,7 +246,7 @@ GEM
addressable (~> 2.3)
letter_opener (1.4.1)
launchy (~> 2.2)
libv8 (3.16.14.17)
libv8 (3.16.14.19)
loofah (2.0.3)
nokogiri (>= 1.5.9)
luhn (1.0.2)
Expand Down Expand Up @@ -285,8 +285,8 @@ GEM
mini_portile2 (~> 2.1.0)
nori (2.6.0)
ntlm-http (0.1.1)
oauth2 (1.3.0)
faraday (>= 0.8, < 0.11)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
Expand All @@ -309,7 +309,7 @@ GEM
paperclip (>= 3.1, < 5.2)
parser (2.4.0.0)
ast (~> 2.2)
pg (0.19.0)
pg (0.20.0)
polyglot (0.3.5)
possibly (1.0.1)
powerpack (0.1.1)
Expand Down Expand Up @@ -352,7 +352,7 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails_best_practices (1.17.0)
rails_best_practices (1.18.0)
activesupport
code_analyzer (>= 0.4.3)
erubis
Expand Down Expand Up @@ -381,7 +381,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rgeo (0.5.3)
rgeo (0.6.0)
rgeo-activerecord (4.0.5)
activerecord (~> 4.2)
rgeo (~> 0.3)
Expand Down Expand Up @@ -431,7 +431,7 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
selenium-webdriver (3.1.0)
selenium-webdriver (3.3.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
Expand All @@ -453,7 +453,7 @@ GEM
sidekiq-unique-jobs (4.0.18)
sidekiq (>= 2.6)
thor
simple_calendar (2.2.3)
simple_calendar (2.2.5)
rails (>= 3.0)
simple_form (3.2.1)
actionpack (> 4, < 5.1)
Expand All @@ -464,7 +464,7 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
socksify (1.7.0)
socksify (1.7.1)
spring (2.0.1)
activesupport (>= 4.2)
sprockets (3.7.1)
Expand All @@ -489,7 +489,7 @@ GEM
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.19.4)
thread_safe (0.3.5)
thread_safe (0.3.6)
tilt (2.0.6)
timecop (0.8.1)
timeliness (0.3.8)
Expand All @@ -504,7 +504,7 @@ GEM
railties (>= 3.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.4)
uglifier (3.1.7)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
Expand Down
20 changes: 16 additions & 4 deletions app/controllers/backend/integrations_controller.rb
Expand Up @@ -21,13 +21,13 @@ def new
return
end
@integration = Integration.new(nature: params[:nature], parameters: (params[:parameters] || {}))
t3e(@integration.attributes.merge(name: @integration.nature.camelize))
t3e(@integration.attributes.merge(name: @integration.name))
render(locals: { cancel_url: :back })
end

def edit
return unless @integration = find_and_check(:integration)
t3e(@integration.attributes.merge(name: @integration.nature.camelize))
t3e(@integration.attributes.merge(name: @integration.name))
render(locals: { cancel_url: :back })
end

Expand All @@ -38,17 +38,29 @@ def destroy

def create
@integration = resource_model.new(permitted_params)
t3e(@integration.attributes.merge(name: @integration.nature.camelize))
t3e(@integration.attributes.merge(name: @integration.name))
return if save_and_redirect(@integration, url: :backend_integrations)
render(locals: { cancel_url: :backend_integrations })
end

def update
return unless @integration = find_and_check(:integration)
t3e(@integration.attributes.merge(name: @integration.nature.camelize))
t3e(@integration.attributes.merge(name: @integration.name))
@integration.attributes = permitted_params
return if save_and_redirect(@integration, url: :backend_integrations)
render(locals: { cancel_url: :back })
end

def check
unless params[:nature]
head :unprocessable_entity
return
end
@integration = Integration.find_or_initialize_by(nature: params[:nature])
@integration.parameters[:access_token] = params[:access_token]
@integration.parameters[:token_type] = params[:token_type] if params[:token_type]
@integration.save!
redirect_to action: :index
end
end
end
8 changes: 4 additions & 4 deletions app/exchangers/ekylibre/sales_exchanger.rb
Expand Up @@ -66,10 +66,10 @@ def import
# find or create a purchase line
if sale && variant && r.unit_pretax_amount && r.quantity && sale_item_tax
unless sale_item = SaleItem.where(
sale_id: sale.id,
pretax_amount: r.pretax_amount,
variant_id: variant.id
).first
sale_id: sale.id,
pretax_amount: r.pretax_amount,
variant_id: variant.id
).first
sale.items.create!(
quantity: r.quantity,
tax: sale_item_tax,
Expand Down
6 changes: 3 additions & 3 deletions app/models/call_message.rb
Expand Up @@ -27,7 +27,7 @@
# created_at :datetime not null
# creator_id :integer
# format :string
# headers :string
# headers :text
# id :integer not null, primary key
# ip_address :string
# lock_version :integer default(0), not null
Expand All @@ -48,8 +48,8 @@ class CallMessage < Ekylibre::Record::Base
enumerize :nature, in: [:incoming, :outgoing], predicates: true

# [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
validates :body, length: { maximum: 500_000 }, allow_blank: true
validates :format, :headers, :ip_address, :ssl, :status, :url, :verb, length: { maximum: 500 }, allow_blank: true
validates :body, :headers, length: { maximum: 500_000 }, allow_blank: true
validates :format, :ip_address, :ssl, :status, :url, :verb, length: { maximum: 500 }, allow_blank: true
validates :nature, presence: true
# ]VALIDATORS]
end
2 changes: 1 addition & 1 deletion app/models/call_request.rb
Expand Up @@ -27,7 +27,7 @@
# created_at :datetime not null
# creator_id :integer
# format :string
# headers :string
# headers :text
# id :integer not null, primary key
# ip_address :string
# lock_version :integer default(0), not null
Expand Down
4 changes: 2 additions & 2 deletions app/models/call_response.rb
Expand Up @@ -27,7 +27,7 @@
# created_at :datetime not null
# creator_id :integer
# format :string
# headers :string
# headers :text
# id :integer not null, primary key
# ip_address :string
# lock_version :integer default(0), not null
Expand Down Expand Up @@ -100,7 +100,7 @@ def self.create_from_savon_httpi_response!(response, request)
status: response.code,
headers: response.headers,
body: response.raw_body,
format: response.headers['content-type'].split(';').first,
format: response.headers['Content-Type'].split(';').first,
request: request
)
r.save!
Expand Down
2 changes: 1 addition & 1 deletion app/models/deposit.rb
Expand Up @@ -74,7 +74,7 @@ class Deposit < Ekylibre::Record::Base

validate do
if self.cash
error.add(:cash_id, :must_be_a_bank_account) unless self.cash.bank_account?
errors.add(:cash_id, :must_be_a_bank_account) unless self.cash.bank_account?
end
end

Expand Down
30 changes: 23 additions & 7 deletions app/models/integration.rb
Expand Up @@ -32,23 +32,35 @@
# updated_at :datetime not null
# updater_id :integer
#

# Integration model is here to save connection parameters in (encrypted) store
# to keep them reusable when necessary.
class Integration < Ekylibre::Record::Base
# [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
validates :nature, presence: true, uniqueness: true, length: { maximum: 500 }
# ]VALIDATORS]
delegate :auth_type, :check_connection, :integration_name, to: :integration_type
delegate :authentication_mode, :check_connection, :integration_name, to: :integration_type
composed_of :parameters,
class_name: 'ActionIntegration::Parameters',
mapping: [%w(ciphered_parameters ciphered), %w(initialization_vectors ivs)],
converter: proc { |parameters| ActionIntegration::Parameters.cipher(parameters) }

validate do
check_connection attributes do |c|
c.redirect do
errors.add(:parameters, :check_redirected)
end
c.error do
errors.add(:parameters, :check_errored)
if integration_type
if authentication_mode == :check
check_connection attributes do |c|
c.redirect do
errors.add(:parameters, :check_redirected)
end
c.error do
errors.add(:parameters, :check_errored)
end
end
elsif authentication_mode == :check
list = parameters.keys.map(&:to_s)
unless parameters && !integration_type.parameters.detect { |p| list.include?(p.to_s) }
errors.add(:parameters, :check_errored)
end
end
end
end
Expand All @@ -73,4 +85,8 @@ def integration_type
def parameter_keys
integration_type.parameters
end

def name
nature.to_s.camelize
end
end
1 change: 1 addition & 0 deletions app/themes/tekyla/stylesheets/integrations.scss
Expand Up @@ -22,6 +22,7 @@
position: absolute;
right: 1em;
top: 1em;
padding: 0.3em 0.4em;
}

.integration-card {
Expand Down
2 changes: 1 addition & 1 deletion app/views/backend/integrations/_form.html.haml
Expand Up @@ -11,4 +11,4 @@
%p
= :website.tl
= link_to(url_name, url)
= render resource.auth_type.to_s, f: f
= render resource.authentication_mode.to_s, f: f
1 change: 1 addition & 0 deletions config/locales/eng/action.yml
Expand Up @@ -353,6 +353,7 @@ eng:
new: "New product grading"
show: "Product grading\_: %{number}"
backend/integrations:
# check: "Check integration: %{name}"
edit: "Edit integration: %{name}"
index: "Integrations"
new: "Activate integration: %{name}"
Expand Down
1 change: 1 addition & 0 deletions config/navigation.xml
Expand Up @@ -1107,6 +1107,7 @@
<page to="backend/integrations#create"/>
<page to="backend/integrations#update"/>
<page to="backend/integrations#destroy"/>
<page to="backend/integrations#check"/>
<page to="backend/net_services#index"/>
<page to="backend/net_services#create"/>
<page to="backend/net_services#destroy"/>
Expand Down
1 change: 1 addition & 0 deletions config/rights.yml
Expand Up @@ -1120,6 +1120,7 @@ integrations:
- "backend/identifiers#edit"
- "backend/identifiers#new"
- "backend/identifiers#update"
- "backend/integrations#check"
- "backend/integrations#create"
- "backend/integrations#destroy"
- "backend/integrations#edit"
Expand Down

0 comments on commit edfd496

Please sign in to comment.