apidae 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/apidae/objects_controller.rb +3 -2
- data/app/helpers/apidae/references_helper.rb +1 -1
- data/app/models/apidae/file_import.rb +14 -7
- data/app/models/apidae/obj.rb +2 -1
- data/app/views/apidae/objects/index.html.erb +1 -1
- data/app/views/apidae/objects/index.json.jbuilder +6 -0
- data/app/views/apidae/objects/show.json.jbuilder +1 -0
- data/app/views/apidae/references/index.html.erb +1 -1
- data/app/views/apidae/selections/index.html.erb +1 -1
- data/config/routes.rb +2 -2
- data/lib/apidae/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f70b5fe26642a9edae0f542465d6914084c18c
|
4
|
+
data.tar.gz: 34d359453c6c3da2b2bfd73e5734c7a35a837dce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 344e11193415d6c193d22f75b3a49f72f54867f71e3e5867c2200382fac19668168839f2d9e1f45b05cd55792a48af33411565ecd45b9f718741bdc36bacf608
|
7
|
+
data.tar.gz: 8eaae4b4be226524437caf86b2f560cc28581f1e9e07c6705411ed8f8b123868f4bf3df17542e77f27019f22a0d42944bca38753e7d62af6104353e40bf199fa
|
@@ -3,13 +3,14 @@ require_dependency "apidae/application_controller"
|
|
3
3
|
module Apidae
|
4
4
|
class ObjectsController < ApplicationController
|
5
5
|
before_action :set_object, only: [:show, :edit, :update, :destroy]
|
6
|
+
skip_before_action Rails.application.config.apidae_auth, only: [:index, :show]
|
6
7
|
|
7
8
|
def index
|
8
9
|
if params[:selection_id]
|
9
10
|
@selection = Selection.find(params[:selection_id])
|
10
|
-
@objects = @selection.objects.select(:apidae_id, :title, :apidae_type, :updated_at)
|
11
|
+
@objects = @selection.objects.select(:id, :apidae_id, :title, :apidae_type, :updated_at)
|
11
12
|
else
|
12
|
-
@objects = Obj.all.select(:apidae_id, :title, :apidae_type, :updated_at)
|
13
|
+
@objects = Obj.all.select(:id, :apidae_id, :title, :apidae_type, :updated_at)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -64,13 +64,20 @@ module Apidae
|
|
64
64
|
def self.add_or_update_objects(objects_json, result)
|
65
65
|
objects_hashes = JSON.parse(objects_json, symbolize_names: true)
|
66
66
|
objects_hashes.each do |object_data|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
begin
|
68
|
+
existing = Obj.find_by_apidae_id(object_data[:id])
|
69
|
+
if existing
|
70
|
+
Obj.update_object(existing, object_data)
|
71
|
+
result[:updated] += 1
|
72
|
+
else
|
73
|
+
Obj.add_object(object_data)
|
74
|
+
result[:created] += 1
|
75
|
+
end
|
76
|
+
rescue Exception => e
|
77
|
+
puts "Failed to import object #{object_data[:id]}"
|
78
|
+
puts e.message
|
79
|
+
puts e.backtrace[0..5].join("\n")
|
80
|
+
raise e
|
74
81
|
end
|
75
82
|
end
|
76
83
|
end
|
data/app/models/apidae/obj.rb
CHANGED
@@ -187,8 +187,9 @@ module Apidae
|
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
def self.parse_type_data(apidae_obj, data_hash,
|
190
|
+
def self.parse_type_data(apidae_obj, data_hash, presta_hash)
|
191
191
|
if data_hash
|
192
|
+
prestations_hash = presta_hash || {}
|
192
193
|
apidae_obj.apidae_subtype = lists_ids(data_hash[:typesManifestation]).first if apidae_obj.apidae_type == FEM
|
193
194
|
apidae_obj.apidae_subtype = node_id(data_hash, :rubrique) if apidae_obj.apidae_type == EQU
|
194
195
|
{
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
2
2
|
<div id="apidae_header" class="<%= styles[:header] %>">
|
3
|
-
<%= link_to 'Retour', :
|
3
|
+
<%= link_to 'Retour', @selection ? selections_path : root_path, class: styles[:back] %>
|
4
4
|
<h1 class="<%= styles[:h1] %>">Apidae - <%= @selection ? "Sélection \"#{@selection.label}\"" : "Tous les objets touristiques" %></h1>
|
5
5
|
</div>
|
6
6
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
@@ -0,0 +1 @@
|
|
1
|
+
json.extract! @object, :title
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
2
2
|
<div id="apidae_header" class="<%= styles[:header] %>">
|
3
|
-
<%= link_to 'Retour',
|
3
|
+
<%= link_to 'Retour', root_path, class: styles[:back] %>
|
4
4
|
<h1 class="<%= styles[:h1] %>">Apidae - Eléments de référence</h1>
|
5
5
|
</div>
|
6
6
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
2
2
|
<div id="apidae_header" class="<%= styles[:header] %>">
|
3
|
-
<%= link_to 'Retour',
|
3
|
+
<%= link_to 'Retour', root_path, class: styles[:back] %>
|
4
4
|
<h1 class="<%= styles[:h1] %>">Apidae - Sélections</h1>
|
5
5
|
</div>
|
6
6
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Apidae::Engine.routes.draw do
|
2
2
|
|
3
|
-
resources :objects, only: [:index], path: 'objets'
|
3
|
+
resources :objects, only: [:index, :show], path: 'objets'
|
4
4
|
resources :selections, only: [:index] do
|
5
|
-
resources :objects, only: [:index]
|
5
|
+
resources :objects, only: [:index], path: 'objets'
|
6
6
|
end
|
7
7
|
resources :references, only: [:index]
|
8
8
|
|
data/lib/apidae/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apidae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jbuilder
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: To be completed
|
56
70
|
email:
|
57
71
|
- jbvilain@gmail.com
|
@@ -92,8 +106,10 @@ files:
|
|
92
106
|
- app/views/apidae/objects/_form.html.erb
|
93
107
|
- app/views/apidae/objects/edit.html.erb
|
94
108
|
- app/views/apidae/objects/index.html.erb
|
109
|
+
- app/views/apidae/objects/index.json.jbuilder
|
95
110
|
- app/views/apidae/objects/new.html.erb
|
96
111
|
- app/views/apidae/objects/show.html.erb
|
112
|
+
- app/views/apidae/objects/show.json.jbuilder
|
97
113
|
- app/views/apidae/references/index.html.erb
|
98
114
|
- app/views/apidae/selections/_form.html.erb
|
99
115
|
- app/views/apidae/selections/edit.html.erb
|