apidae 0.2.5 → 0.2.6
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 +7 -11
- data/app/models/apidae/object.rb +20 -14
- data/app/views/apidae/objects/index.html.erb +1 -1
- data/app/views/apidae/selections/index.html.erb +2 -2
- data/config/routes.rb +3 -1
- data/db/migrate/20180222104915_add_rates_data_to_apidae_objects.rb +6 -0
- data/db/migrate/20180222105302_rename_openings_to_openings_data.rb +5 -0
- data/lib/apidae/engine.rb +4 -0
- data/lib/apidae/version.rb +1 -1
- data/test/dummy/db/schema.rb +3 -3
- data/test/dummy/log/development.log +24 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a65b8e65f96393ad346b2e3e75c2d9b03fa36917
|
4
|
+
data.tar.gz: c294dbec3f0fb0ce086d219a64bf4d926d6be51e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 816137aec948bde71a5c5ebd274f630f45c72df31ec19c29c162076fa44949fb64388ae68c8be7aa38665eebef470624e58c76fff0713b736e495edcd77beb14
|
7
|
+
data.tar.gz: f7ee150be2b37199b8c21092f0c8760f642cb6dbfd680aaaf2e256f9f1135be7577b81ad3b80959bdbd59c72466bea52a6e6271ef9b2c00b3bca254650429681
|
@@ -4,25 +4,25 @@ module Apidae
|
|
4
4
|
class ObjectsController < ApplicationController
|
5
5
|
before_action :set_object, only: [:show, :edit, :update, :destroy]
|
6
6
|
|
7
|
-
# GET /objects
|
8
7
|
def index
|
9
|
-
|
8
|
+
if params[:selection_id]
|
9
|
+
@selection = Selection.find(params[:selection_id])
|
10
|
+
@objects = @selection.objects.select(:apidae_id, :title, :apidae_type, :updated_at)
|
11
|
+
else
|
12
|
+
@objects = Object.all.select(:apidae_id, :title, :apidae_type, :updated_at)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
|
-
# GET /objects/1
|
13
16
|
def show
|
14
17
|
end
|
15
18
|
|
16
|
-
# GET /objects/new
|
17
19
|
def new
|
18
20
|
@object = Object.new
|
19
21
|
end
|
20
22
|
|
21
|
-
# GET /objects/1/edit
|
22
23
|
def edit
|
23
24
|
end
|
24
25
|
|
25
|
-
# POST /objects
|
26
26
|
def create
|
27
27
|
@object = Object.new(object_params)
|
28
28
|
|
@@ -33,7 +33,6 @@ module Apidae
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
# PATCH/PUT /objects/1
|
37
36
|
def update
|
38
37
|
if @object.update(object_params)
|
39
38
|
redirect_to @object, notice: 'Object was successfully updated.'
|
@@ -42,21 +41,18 @@ module Apidae
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
# DELETE /objects/1
|
46
44
|
def destroy
|
47
45
|
@object.destroy
|
48
46
|
redirect_to objects_url, notice: 'Object was successfully destroyed.'
|
49
47
|
end
|
50
48
|
|
51
49
|
private
|
52
|
-
# Use callbacks to share common setup or constraints between actions.
|
53
50
|
def set_object
|
54
51
|
@object = Object.find(params[:id])
|
55
52
|
end
|
56
53
|
|
57
|
-
# Only allow a trusted parameter "white list" through.
|
58
54
|
def object_params
|
59
|
-
params.require(:object).permit
|
55
|
+
params.require(:object).permit!
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
data/app/models/apidae/object.rb
CHANGED
@@ -7,11 +7,12 @@ module Apidae
|
|
7
7
|
has_many :selections, class_name: 'Apidae::Selection', source: :apidae_selection, through: :apidae_selection_objects
|
8
8
|
|
9
9
|
store_accessor :pictures_data, :pictures
|
10
|
-
store_accessor :type_data, :categories, :themes, :capacite, :classement
|
10
|
+
store_accessor :type_data, :categories, :themes, :capacite, :classement, :labels
|
11
11
|
store_accessor :entity_data, :entity_id, :entity_name
|
12
12
|
store_accessor :contact, :telephone, :email, :website
|
13
13
|
store_accessor :address, :address_fields
|
14
|
-
store_accessor :
|
14
|
+
store_accessor :openings_data, :openings_desc, :openings
|
15
|
+
store_accessor :rates_data, :rates_desc, :rates
|
15
16
|
|
16
17
|
ACT = 'ACTIVITE'
|
17
18
|
COS = 'COMMERCE_ET_SERVICE'
|
@@ -70,9 +71,9 @@ module Apidae
|
|
70
71
|
apidae_obj.town = town(object_data[:localisation][:adresse])
|
71
72
|
apidae_obj.latitude = latitude(object_data[:localisation])
|
72
73
|
apidae_obj.longitude = longitude(object_data[:localisation])
|
73
|
-
apidae_obj.
|
74
|
-
apidae_obj.
|
75
|
-
apidae_obj.reservation =
|
74
|
+
apidae_obj.openings_data = parse_openings(object_data[:ouverture])
|
75
|
+
apidae_obj.rates_data = parse_rates(object_data[:descriptionTarif])
|
76
|
+
apidae_obj.reservation = parse_reservation(object_data[:reservation])
|
76
77
|
apidae_obj.type_data = object_data[type_fields[:node]]
|
77
78
|
apidae_obj.pictures_data = pictures_urls(object_data[:illustrations])
|
78
79
|
apidae_obj.entity_data = entity_fields(object_data[:informations])
|
@@ -140,23 +141,21 @@ module Apidae
|
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
143
|
-
def self.
|
144
|
+
def self.parse_openings(openings_hash)
|
144
145
|
if openings_hash && openings_hash[:periodeEnClair]
|
145
|
-
{
|
146
|
+
{openings_desc: openings_hash[:periodeEnClair][:libelleFr], openings: openings_hash[:periodesOuvertures]}
|
146
147
|
end
|
147
148
|
end
|
148
149
|
|
149
|
-
def self.
|
150
|
+
def self.parse_rates(rates_hash)
|
150
151
|
if rates_hash
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
rates_hash[:tarifsEnClair][:libelleFr]
|
155
|
-
end
|
152
|
+
desc = rates_hash[:gratuit] ? 'gratuit' : node_value(rates_hash, :tarifsEnClair)
|
153
|
+
values = rates_hash[:periodes].blank? ? [] : rates_hash[:periodes].map {|p| build_rate(p)}
|
154
|
+
{rates_desc: desc, rates: values}
|
156
155
|
end
|
157
156
|
end
|
158
157
|
|
159
|
-
def self.
|
158
|
+
def self.parse_reservation(reservation_hash)
|
160
159
|
if reservation_hash
|
161
160
|
if reservation_hash[:complement]
|
162
161
|
reservation_hash[:complement][:libelleFr]
|
@@ -184,6 +183,13 @@ module Apidae
|
|
184
183
|
pictures.any? ? pictures[0]["url"] : "/#{Rails.application.config.apidae_pictures_path}/default/logo.png"
|
185
184
|
end
|
186
185
|
|
186
|
+
def self.build_rate(rate_period)
|
187
|
+
{
|
188
|
+
id: rate_period[:identifiant], from: rate_period[:dateDebut], to: rate_period[:dateFin],
|
189
|
+
values: rate_period[:tarifs].blank? ? [] : rate_period[:tarifs].map {|t| {min: t[:minimum], max: t[:maximum], type: t[:type][:id], details: node_value(t, :precisionTarif)}}
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
187
193
|
private
|
188
194
|
|
189
195
|
def self.node_value(node, key)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
2
2
|
<div id="apidae_header" class="<%= styles[:header] %>">
|
3
3
|
<%= link_to 'Retour', :back, class: styles[:back] %>
|
4
|
-
<h1 class="<%= styles[:h1] %>">Apidae -
|
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] %>">
|
7
7
|
<div id="apidae_imports_panel" class="<%= styles[:body] %>">
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<th>Label</th>
|
12
12
|
<th>Reference</th>
|
13
13
|
<th>Identifiant</th>
|
14
|
-
<th>
|
14
|
+
<th>Objets</th>
|
15
15
|
</tr>
|
16
16
|
</thead>
|
17
17
|
<tbody class="<%= styles[:table_body] %>">
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<td><%= selection.label %></td>
|
21
21
|
<td><%= selection.reference %></td>
|
22
22
|
<td><%= selection.apidae_id %></td>
|
23
|
-
<td><%= selection.objects.count %></td>
|
23
|
+
<td><%= link_to selection.objects.count, selection_objects_path(selection) %></td>
|
24
24
|
</tr>
|
25
25
|
<% end %>
|
26
26
|
<% if @selections.empty? %>
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
Apidae::Engine.routes.draw do
|
2
2
|
|
3
3
|
resources :objects, only: [:index], path: 'objets'
|
4
|
-
resources :selections, only: [:index]
|
4
|
+
resources :selections, only: [:index] do
|
5
|
+
resources :objects, only: [:index]
|
6
|
+
end
|
5
7
|
|
6
8
|
match 'import/callback', via: :post, to: 'import#callback'
|
7
9
|
match 'import/run', via: :post, to: 'import#run'
|
data/lib/apidae/engine.rb
CHANGED
data/lib/apidae/version.rb
CHANGED
data/test/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20180222105302) do
|
14
14
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
16
16
|
enable_extension "plpgsql"
|
@@ -62,8 +62,7 @@ ActiveRecord::Schema.define(version: 20180218231319) do
|
|
62
62
|
t.jsonb "type_data"
|
63
63
|
t.float "latitude"
|
64
64
|
t.float "longitude"
|
65
|
-
t.jsonb "
|
66
|
-
t.text "rates"
|
65
|
+
t.jsonb "openings_data"
|
67
66
|
t.text "reservation"
|
68
67
|
t.datetime "created_at", null: false
|
69
68
|
t.datetime "updated_at", null: false
|
@@ -71,6 +70,7 @@ ActiveRecord::Schema.define(version: 20180218231319) do
|
|
71
70
|
t.jsonb "pictures_data"
|
72
71
|
t.jsonb "entity_data"
|
73
72
|
t.jsonb "service_data"
|
73
|
+
t.jsonb "rates_data"
|
74
74
|
end
|
75
75
|
|
76
76
|
create_table "apidae_objects_selections", id: :serial, force: :cascade do |t|
|
@@ -283,3 +283,27 @@ Migrating to AddServiceDataToApidaeObjects (20180218231319)
|
|
283
283
|
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
284
284
|
[1m[35m (0.3ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
285
285
|
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
286
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
287
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
288
|
+
Migrating to AddRatesDataToApidaeObjects (20180222104915)
|
289
|
+
[1m[35m (12.2ms)[0m [1m[35mBEGIN[0m
|
290
|
+
[1m[35m (18.3ms)[0m [1m[35mALTER TABLE "apidae_objects" ADD "rates_data" jsonb[0m
|
291
|
+
[1m[35m (3.4ms)[0m [1m[35mALTER TABLE "apidae_objects" DROP "rates"[0m
|
292
|
+
[1m[35mSQL (1.0ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20180222104915"]]
|
293
|
+
[1m[35m (1.3ms)[0m [1m[35mCOMMIT[0m
|
294
|
+
Migrating to RenameOpeningsToOpeningsData (20180222105302)
|
295
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
296
|
+
[1m[35m (0.1ms)[0m [1m[31mROLLBACK[0m
|
297
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
298
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
299
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
300
|
+
Migrating to RenameOpeningsToOpeningsData (20180222105302)
|
301
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
302
|
+
[1m[35m (2.4ms)[0m [1m[35mALTER TABLE "apidae_objects" RENAME COLUMN "openings" TO "openings_data"[0m
|
303
|
+
[1m[35mSQL (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20180222105302"]]
|
304
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
305
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
306
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
307
|
+
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
308
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
309
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
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.2.
|
4
|
+
version: 0.2.6
|
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-02-
|
11
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- db/migrate/20180217222410_create_apidae_selection_objects.rb
|
126
126
|
- db/migrate/20180218172704_change_text_columns_to_json.rb
|
127
127
|
- db/migrate/20180218231319_add_service_data_to_apidae_objects.rb
|
128
|
+
- db/migrate/20180222104915_add_rates_data_to_apidae_objects.rb
|
129
|
+
- db/migrate/20180222105302_rename_openings_to_openings_data.rb
|
128
130
|
- lib/apidae.rb
|
129
131
|
- lib/apidae/engine.rb
|
130
132
|
- lib/apidae/version.rb
|