apidae 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87cd9a41caead065a805e975fbe7fc5f4227cfdf
4
- data.tar.gz: bf3ac2b75b2e4a2ee96d5a0a0298ce105460afc4
3
+ metadata.gz: 2df93504655edcacc1527f70788f1e2cea326cd2
4
+ data.tar.gz: 0683c0b435a9a0b474d1fca15e7a33a78b2a587a
5
5
  SHA512:
6
- metadata.gz: 16697f8ea3872f0b10db80aa23df7f7e475945b56787b131d89875fdb31c4a340729376f35160fbc715af0f2da68a862c3336334a8e34fb699d3ea6fbea2f098
7
- data.tar.gz: 89856a0a71ddf723f2a8dffd3631d9950d93523e406c63a1032bf1fdd761fb5f6310aab7440f863dbdd6ceb7b0f7803d7e8cdf00d0e24b457ef925b184f253c2
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
- begin
37
- open(e.file_url) do |f|
38
- begin
39
- FileImport.import(f)
40
- uri = URI(e.confirm_url)
41
- req = Net::HTTP::Post.new(uri)
42
- Net::HTTP.start(uri.hostname, uri.port) do |http|
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)
@@ -6,7 +6,7 @@ module Apidae
6
6
 
7
7
  # GET /objects
8
8
  def index
9
- @objects = Object.all
9
+ @objects = Object.all.select(:apidae_id, :title, :apidae_type, :updated_at)
10
10
  end
11
11
 
12
12
  # GET /objects/1
@@ -3,7 +3,6 @@ module Apidae
3
3
 
4
4
  PENDING = 'pending'
5
5
  COMPLETE = 'complete'
6
- CANCELLED = 'cancelled'
7
6
 
8
7
  # Note : handle reset case
9
8
  def self.pending
@@ -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
- computed_address << address_hash[:adresse1] unless address_hash[:adresse1].blank?
117
- computed_address << address_hash[:adresse2] unless address_hash[:adresse2].blank?
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
- (!address_hash.blank? && address_hash[:commune]) ? Town.find_by_apidae_id(address_hash[:commune][:id]) : nil
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
- unless location_hash.blank?
129
- geoloc_details = location_hash[:geolocalisation]
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
- unless location_hash.blank?
136
- geoloc_details = location_hash[:geolocalisation]
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
- <h3 class="<%= styles[:h3] %>"><%= link_to pluralize(@selections, 'sélection'), apidae.selections_path %></h3>
36
- <h3 class="<%= styles[:h3] %>"><%= link_to pluralize(@objects, 'objet touristique', 'objets touristiques'), apidae.objects_path %></h3>
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
@@ -1,5 +1,5 @@
1
1
  module Apidae
2
- class Engine < ::Rails::Engine
2
+ class Engine < Rails::Engine
3
3
  isolate_namespace Apidae
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.6
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-25 00:00:00.000000000 Z
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: 4.2.8
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: 4.2.8
26
+ version: 5.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: paperclip
29
29
  requirement: !ruby/object:Gem::Requirement