apidae 0.7.6 → 0.7.7
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 +1 -1
- data/app/controllers/apidae/objects_controller.rb +11 -10
- data/app/models/apidae/obj.rb +1 -1
- data/app/models/apidae/selection.rb +1 -1
- data/app/views/apidae/objects/edit.html.erb +1 -1
- data/app/views/apidae/objects/index.html.erb +3 -2
- data/app/views/apidae/objects/new.html.erb +32 -4
- data/config/routes.rb +1 -1
- data/lib/apidae/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c720ab33eaef78cb4204c9a762bb8a99cc9b789
|
4
|
+
data.tar.gz: ba76e69c7b40c4b4e6236567879c74983d18744d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4885ebfb95a966eb54cdee590498a24c5e6bced783d61d12edd5c13f53c8792421bc46dc1b3000f5a2fd89573fe0ef73ba213b575f285fc074fd36de40b4cef9
|
7
|
+
data.tar.gz: 0fa597db6dd22bc8a78e79ce64079828d23f7c8d89c82a303e6641800c907a748bf608ac1b6d9eb76c74e2d2419e838b14db211ba454ba1e36d7adf5fbce087a
|
@@ -46,7 +46,7 @@ module Apidae
|
|
46
46
|
http.request(req)
|
47
47
|
end
|
48
48
|
e.update(status: Export::COMPLETE)
|
49
|
-
if Rails.application.config.apidae_import_callback
|
49
|
+
if Rails.application.config.respond_to?(:apidae_import_callback)
|
50
50
|
Rails.application.config.apidae_import_callback.call(e)
|
51
51
|
end
|
52
52
|
rescue Exception => ex
|
@@ -19,38 +19,39 @@ module Apidae
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def new
|
22
|
-
@
|
22
|
+
@obj = Obj.new
|
23
23
|
end
|
24
24
|
|
25
25
|
def edit
|
26
26
|
end
|
27
27
|
|
28
28
|
def create
|
29
|
-
@
|
30
|
-
|
31
|
-
if @
|
32
|
-
redirect_to
|
29
|
+
@obj = Obj.new(object_params)
|
30
|
+
selection = params[:selection_apidae_id].blank? ? Selection.last : Selection.find_by_apidae_id(params[:selection_apidae_id])
|
31
|
+
if @obj.save && selection.refresh_obj(@obj.apidae_id)
|
32
|
+
redirect_to objects_url, notice: "L'objet a bien été importé"
|
33
33
|
else
|
34
|
+
flash[:alert] = "Une erreur s'est produite lors de l'import de l'objet."
|
34
35
|
render :new
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
def update
|
39
|
-
if @
|
40
|
-
redirect_to @
|
40
|
+
if @obj.update(object_params)
|
41
|
+
redirect_to @obj, notice: 'Object was successfully updated.'
|
41
42
|
else
|
42
43
|
render :edit
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
def destroy
|
47
|
-
@
|
48
|
+
@obj.destroy
|
48
49
|
redirect_to objects_url, notice: 'Object was successfully destroyed.'
|
49
50
|
end
|
50
51
|
|
51
52
|
def refresh
|
52
53
|
referrer = session.delete(:referrer)
|
53
|
-
if @
|
54
|
+
if @obj && @obj.selections.first.refresh_obj(@obj.apidae_id)
|
54
55
|
redirect_to referrer, notice: "L'objet touristique a bien été mis à jour."
|
55
56
|
else
|
56
57
|
redirect_to referrer, alert: "Une erreur s'est produite lors de la mise à jour de l'objet."
|
@@ -59,7 +60,7 @@ module Apidae
|
|
59
60
|
|
60
61
|
private
|
61
62
|
def set_object
|
62
|
-
@
|
63
|
+
@obj = Obj.find(params[:id])
|
63
64
|
end
|
64
65
|
|
65
66
|
def object_params
|
data/app/models/apidae/obj.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Apidae
|
2
2
|
class Obj < ActiveRecord::Base
|
3
3
|
|
4
|
-
belongs_to :town, class_name: 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code
|
4
|
+
belongs_to :town, class_name: 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code, optional: true
|
5
5
|
has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_object_id
|
6
6
|
has_many :selections, class_name: 'Apidae::Selection', source: :apidae_selection, through: :apidae_selection_objects
|
7
7
|
|
@@ -95,7 +95,7 @@ module Apidae
|
|
95
95
|
obj = Obj.find_by_apidae_id(apidae_obj_id)
|
96
96
|
if obj
|
97
97
|
refreshed = Obj.update_object(obj, obj_data)
|
98
|
-
if refreshed && Rails.application.config.apidae_obj_refresh_callback
|
98
|
+
if refreshed && Rails.application.config.respond_to?(:apidae_obj_refresh_callback)
|
99
99
|
Rails.application.config.apidae_obj_refresh_callback.call(apidae_obj_id)
|
100
100
|
end
|
101
101
|
refreshed
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
2
2
|
<div id="apidae_header" class="<%= styles[:header] %>">
|
3
|
-
<%= link_to '
|
3
|
+
<%= link_to 'Importer un objet', apidae.new_object_path, class: styles[:objects] %>
|
4
|
+
<%= link_to 'Retour', @selection ? apidae.selections_path : root_path, class: styles[:back] %>
|
4
5
|
<h1 class="<%= styles[:h1] %>">Apidae - <%= @selection ? "Sélection \"#{@selection.label}\"" : "Tous les objets touristiques" %></h1>
|
5
6
|
</div>
|
6
7
|
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
@@ -22,7 +23,7 @@
|
|
22
23
|
<td><%= object.apidae_id %></td>
|
23
24
|
<td><%= object.apidae_type %></td>
|
24
25
|
<td><%= object.updated_at.strftime('Le %d/%m/%Y à %H:%M') if object.updated_at %></td>
|
25
|
-
<td><%= link_to 'Rafraîchir', refresh_object_path(object), method: :post,
|
26
|
+
<td><%= link_to 'Rafraîchir', apidae.refresh_object_path(object), method: :post,
|
26
27
|
data: {confirm: 'Voulez-vous vraiment rafraîchir cet objet ? Les données existantes seront écrasées.'} %></td>
|
27
28
|
</tr>
|
28
29
|
<% end %>
|
@@ -1,5 +1,33 @@
|
|
1
|
-
|
1
|
+
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
2
|
+
<div id="apidae_header" class="<%= styles[:header] %>">
|
3
|
+
<%= link_to 'Retour', :back, class: styles[:back] %>
|
4
|
+
<h1 class="<%= styles[:h1] %>">Apidae - Importer un objet</h1>
|
5
|
+
</div>
|
6
|
+
<div id="apidae_new_object" class="<%= styles[:wrapper] %>">
|
7
|
+
<div id="apidae_form" class="<%= styles[:body] %>">
|
8
|
+
<%= form_for(@obj, class: styles[:form]) do |f| %>
|
9
|
+
<% if @obj.errors.any? %>
|
10
|
+
<div id="apidae_form_errors">
|
11
|
+
<ul>
|
12
|
+
<% @obj.errors.full_messages.each do |message| %>
|
13
|
+
<li><%= message %></li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
2
18
|
|
3
|
-
<%=
|
4
|
-
|
5
|
-
|
19
|
+
<div class="<%= styles[:form_field] %>">
|
20
|
+
<div><%= f.label :apidae_id %></div>
|
21
|
+
<div><%= f.text_field :apidae_id %></div>
|
22
|
+
</div>
|
23
|
+
<div class="<%= styles[:form_field] %>">
|
24
|
+
<div><%= label_tag :selection_apidae_id %></div>
|
25
|
+
<div><%= text_field_tag :selection_apidae_id %></div>
|
26
|
+
</div>
|
27
|
+
<div class="<%= styles[:form_actions] %>">
|
28
|
+
<%= f.submit 'Valider' %>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
data/config/routes.rb
CHANGED
data/lib/apidae/version.rb
CHANGED