apidae 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/apidae/import_controller.rb +12 -19
- data/app/controllers/apidae/objects_controller.rb +1 -1
- data/app/models/apidae/export.rb +0 -1
- data/app/models/apidae/object.rb +10 -16
- data/app/views/apidae/dashboard/index.html.erb +5 -5
- data/app/views/apidae/objects/index.html.erb +8 -3
- data/app/views/apidae/selections/index.html.erb +8 -3
- data/lib/apidae/engine.rb +1 -1
- data/lib/apidae/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2df93504655edcacc1527f70788f1e2cea326cd2
|
4
|
+
data.tar.gz: 0683c0b435a9a0b474d1fca15e7a33a78b2a587a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 640e73f427753e7bc1963066180b2cc032056e0373f884a1c3db341268bbb1e01a7babcb7c396193a60dbb1cb750dff1621b27d00789d9d70ab46633009963d3
|
7
|
+
data.tar.gz: c2e0065d476896b77fcdd2b5fb5f3b7cdfee2e5a19a7831efd77ea575795d380500eb1a0c913506a4423c31c03c6a1637676ff585fdfd74b9a200d314c58e948
|
@@ -33,27 +33,20 @@ module Apidae
|
|
33
33
|
def run
|
34
34
|
success = true
|
35
35
|
Export.pending.each do |e|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
http.request(req)
|
44
|
-
end
|
45
|
-
e.update(status: Export::COMPLETE)
|
46
|
-
rescue Exception => ex
|
47
|
-
logger.error("Failed to import export file : #{e.file_url}")
|
48
|
-
logger.error("Error is : #{ex} \n#{ex.backtrace.join("\n") unless ex.backtrace.blank?}")
|
49
|
-
success = false
|
36
|
+
open(e.file_url) do |f|
|
37
|
+
begin
|
38
|
+
FileImport.import(f)
|
39
|
+
uri = URI(e.confirm_url)
|
40
|
+
req = Net::HTTP::Post.new(uri)
|
41
|
+
Net::HTTP.start(uri.hostname, uri.port) do |http|
|
42
|
+
http.request(req)
|
50
43
|
end
|
44
|
+
e.update(status: Export::COMPLETE)
|
45
|
+
rescue Exception => ex
|
46
|
+
logger.error("Failed to retrieve export file : #{ex.file_url}")
|
47
|
+
logger.error("Error is : #{ex}")
|
48
|
+
success = false
|
51
49
|
end
|
52
|
-
rescue OpenURI::HTTPError => err
|
53
|
-
logger.error("Failed to download export file : #{e.file_url}")
|
54
|
-
logger.error("Error is : #{err}")
|
55
|
-
success = false
|
56
|
-
e.update(status: Export::CANCELLED)
|
57
50
|
end
|
58
51
|
end
|
59
52
|
render nothing: true, status: (success ? :ok : :internal_server_error)
|
data/app/models/apidae/export.rb
CHANGED
data/app/models/apidae/object.rb
CHANGED
@@ -112,30 +112,24 @@ module Apidae
|
|
112
112
|
|
113
113
|
def self.address(address_hash)
|
114
114
|
computed_address = []
|
115
|
-
unless address_hash.blank?
|
116
|
-
|
117
|
-
|
118
|
-
computed_address << address_hash[:adresse3] unless address_hash[:adresse3].blank?
|
119
|
-
end
|
115
|
+
computed_address << address_hash[:adresse1] unless address_hash[:adresse1].blank?
|
116
|
+
computed_address << address_hash[:adresse2] unless address_hash[:adresse2].blank?
|
117
|
+
computed_address << address_hash[:adresse3] unless address_hash[:adresse3].blank?
|
120
118
|
{address_fields: computed_address}
|
121
119
|
end
|
122
120
|
|
123
|
-
def self.town(address_hash
|
124
|
-
|
121
|
+
def self.town(address_hash)
|
122
|
+
address_hash[:commune] ? Town.find_by_apidae_id(address_hash[:commune][:id]) : nil
|
125
123
|
end
|
126
124
|
|
127
125
|
def self.latitude(location_hash)
|
128
|
-
|
129
|
-
|
130
|
-
(geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][1] : nil
|
131
|
-
end
|
126
|
+
geoloc_details = location_hash[:geolocalisation]
|
127
|
+
(geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][1] : nil
|
132
128
|
end
|
133
129
|
|
134
|
-
def self.longitude(location_hash
|
135
|
-
|
136
|
-
|
137
|
-
(geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][0] : nil
|
138
|
-
end
|
130
|
+
def self.longitude(location_hash)
|
131
|
+
geoloc_details = location_hash[:geolocalisation]
|
132
|
+
(geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][0] : nil
|
139
133
|
end
|
140
134
|
|
141
135
|
def self.openings(openings_hash)
|
@@ -1,20 +1,20 @@
|
|
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', :back, class: styles[:back] %>
|
3
4
|
<h1 class="<%= styles[:h1] %>">Apidae</h1>
|
4
5
|
</div>
|
5
6
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
6
7
|
<div id="apidae_imports_panel" class="<%= styles[:body] %>">
|
7
8
|
<h2 class="<%= styles[:h2] %>">Derniers imports</h2>
|
8
9
|
<table id="apidae_imports" class="<%= styles[:table] %>">
|
9
|
-
<thead>
|
10
|
+
<thead class="<%= styles[:table_head] %>">
|
10
11
|
<tr>
|
11
12
|
<th>Date</th>
|
12
13
|
<th>Fichier</th>
|
13
14
|
<th>Statut</th>
|
14
15
|
</tr>
|
15
16
|
</thead>
|
16
|
-
|
17
|
-
<tbody>
|
17
|
+
<tbody class="<%= styles[:table_body] %>">
|
18
18
|
<% @last_imports.each do |import| %>
|
19
19
|
<tr>
|
20
20
|
<td><%= import.updated_at.strftime('Le %d/%m/%Y à %H:%M') if import.updated_at %></td>
|
@@ -32,8 +32,8 @@
|
|
32
32
|
</div>
|
33
33
|
<div id="apidae_navigation_panel" class="<%= styles[:body] %>">
|
34
34
|
<h2 class="<%= styles[:h2] %>">Données issues d'Apidae</h2>
|
35
|
-
|
36
|
-
|
35
|
+
<%= link_to pluralize(@selections, 'sélection', 'sélections'), apidae.selections_path, class: styles[:selections] %>
|
36
|
+
<%= link_to pluralize(@objects, 'objet touristique', 'objets touristiques'), apidae.objects_path, class: styles[:objects] %>
|
37
37
|
</div>
|
38
38
|
</div>
|
39
39
|
<% end %>
|
@@ -1,11 +1,12 @@
|
|
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', :back, class: styles[:back] %>
|
3
4
|
<h1 class="<%= styles[:h1] %>">Apidae - Objets touristiques</h1>
|
4
5
|
</div>
|
5
6
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
6
7
|
<div id="apidae_imports_panel" class="<%= styles[:body] %>">
|
7
8
|
<table id="apidae_objects" class="<%= styles[:table] %>">
|
8
|
-
<thead>
|
9
|
+
<thead class="<%= styles[:table_head] %>">
|
9
10
|
<tr>
|
10
11
|
<th>Titre</th>
|
11
12
|
<th>Identifiant</th>
|
@@ -13,8 +14,7 @@
|
|
13
14
|
<th>Mise à jour</th>
|
14
15
|
</tr>
|
15
16
|
</thead>
|
16
|
-
|
17
|
-
<tbody>
|
17
|
+
<tbody class="<%= styles[:table_body] %>">
|
18
18
|
<% @objects.each do |object| %>
|
19
19
|
<tr>
|
20
20
|
<td><%= object.title %></td>
|
@@ -23,6 +23,11 @@
|
|
23
23
|
<td><%= object.updated_at.strftime('Le %d/%m/%Y à %H:%M') if object.updated_at %></td>
|
24
24
|
</tr>
|
25
25
|
<% end %>
|
26
|
+
<% if @objects.empty? %>
|
27
|
+
<tr>
|
28
|
+
<td colspan="4">Aucun objet importé pour le moment.</td>
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
26
31
|
</tbody>
|
27
32
|
</table>
|
28
33
|
</div>
|
@@ -1,11 +1,12 @@
|
|
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', :back, class: styles[:back] %>
|
3
4
|
<h1 class="<%= styles[:h1] %>">Apidae - Sélections</h1>
|
4
5
|
</div>
|
5
6
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
6
7
|
<div id="apidae_imports_panel" class="<%= styles[:body] %>">
|
7
8
|
<table id="apidae_selections" class="<%= styles[:table] %>">
|
8
|
-
<thead>
|
9
|
+
<thead class="<%= styles[:table_head] %>">
|
9
10
|
<tr>
|
10
11
|
<th>Label</th>
|
11
12
|
<th>Reference</th>
|
@@ -13,8 +14,7 @@
|
|
13
14
|
<th>Nombre d'objets</th>
|
14
15
|
</tr>
|
15
16
|
</thead>
|
16
|
-
|
17
|
-
<tbody>
|
17
|
+
<tbody class="<%= styles[:table_body] %>">
|
18
18
|
<% @selections.each do |selection| %>
|
19
19
|
<tr>
|
20
20
|
<td><%= selection.label %></td>
|
@@ -23,6 +23,11 @@
|
|
23
23
|
<td><%= selection.objects.count %></td>
|
24
24
|
</tr>
|
25
25
|
<% end %>
|
26
|
+
<% if @selections.empty? %>
|
27
|
+
<tr>
|
28
|
+
<td colspan="4">Aucune sélection importée pour le moment.</td>
|
29
|
+
</tr>
|
30
|
+
<% end %>
|
26
31
|
</tbody>
|
27
32
|
</table>
|
28
33
|
</div>
|
data/lib/apidae/engine.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
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-01-
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: paperclip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|