apidae 0.4.5 → 0.5.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: e25a6430bdd39784b105556de0aa19e44ade0a88
4
- data.tar.gz: f58818fd7eda17b51846270440e03b5ba5c174a1
3
+ metadata.gz: 2f547cf4610e683c3aaea19fcd199a9eb22938ef
4
+ data.tar.gz: 4aa87029f4a8c5781c8545682bf574c722842cc4
5
5
  SHA512:
6
- metadata.gz: cf1539b6f2f4e1e6e7b3f679192bf2eabbb7bd16c0dc1783c380d988989d755a2b63e5979073ac55f1523572884a09bc3add495d6788346d2253f627a6f037d7
7
- data.tar.gz: 5fa24cb1d6966a4f40b5a76f455fd6c9480b46d42f1087d56f6c64f89570181f9822b1cad300cf481c76156ee44bfe9e9274157aa032c3798104c26fe416be78
6
+ metadata.gz: a6c3da77b3d4f508cfce7635cd18e9370f2e1af3c45e44a2f0184194e285b47cadb4cd6c0cb9282975abd1534eb8faf7d0760c7125df2dfe050a93560210a4f5
7
+ data.tar.gz: e84e25d392c3b1cca5edc9b5395abc3f964b34f6f13b840f48dee6d86640127bf78219baeace49ea3bad00ccb2f72c5066ec65cdbaea5424ff22aee72e5f7c16
@@ -6,8 +6,8 @@ module Apidae
6
6
  def selection
7
7
  @objects = []
8
8
  unless params[:selection_id].blank?
9
- objects_ids = Apidae::Selection.find(params[:selection_id]).api_results[:results]
10
- @objects = Apidae::Object.where(id: objects_ids)
9
+ objects_ids = Selection.find(params[:selection_id]).api_results[:results]
10
+ @objects = Obj.where(id: objects_ids)
11
11
  end
12
12
  end
13
13
 
@@ -17,8 +17,8 @@ module Apidae
17
17
  def agenda
18
18
  @objects = []
19
19
  unless params[:selection_id].blank?
20
- objects_ids = Apidae::Selection.find(params[:selection_id]).api_agenda(params[:from], params[:to])[:results]
21
- @objects = Apidae::Object.where(id: objects_ids)
20
+ objects_ids = Selection.find(params[:selection_id]).api_agenda(params[:from], params[:to])[:results]
21
+ @objects = Obj.where(id: objects_ids)
22
22
  end
23
23
  end
24
24
  end
@@ -1,5 +1,6 @@
1
1
  module Apidae
2
2
  class ApplicationController < ActionController::Base
3
3
  protect_from_forgery with: :exception
4
+ before_action Rails.application.config.apidae_auth
4
5
  end
5
6
  end
@@ -3,9 +3,10 @@ require_dependency "apidae/application_controller"
3
3
  module Apidae
4
4
  class DashboardController < ApplicationController
5
5
  def index
6
- @objects = Apidae::Object.count
7
- @selections = Apidae::Selection.count
8
- @last_imports = Apidae::FileImport.order(id: :desc).take(5)
6
+ @objects = Obj.count
7
+ @selections = Selection.count
8
+ @references = Reference.count
9
+ @last_imports = FileImport.order(id: :desc).take(5)
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,9 @@
1
+ require_dependency "apidae/application_controller"
2
+
3
+ module Apidae
4
+ class ReferencesController < ApplicationController
5
+ def index
6
+ @references = Reference.all
7
+ end
8
+ end
9
+ end
@@ -4,25 +4,20 @@ module Apidae
4
4
  class SelectionsController < ApplicationController
5
5
  before_action :set_selection, only: [:show, :edit, :update, :destroy]
6
6
 
7
- # GET /selections
8
7
  def index
9
8
  @selections = Selection.all
10
9
  end
11
10
 
12
- # GET /selections/1
13
11
  def show
14
12
  end
15
13
 
16
- # GET /selections/new
17
14
  def new
18
15
  @selection = Selection.new
19
16
  end
20
17
 
21
- # GET /selections/1/edit
22
18
  def edit
23
19
  end
24
20
 
25
- # POST /selections
26
21
  def create
27
22
  @selection = Selection.new(selection_params)
28
23
 
@@ -33,7 +28,6 @@ module Apidae
33
28
  end
34
29
  end
35
30
 
36
- # PATCH/PUT /selections/1
37
31
  def update
38
32
  if @selection.update(selection_params)
39
33
  redirect_to @selection, notice: 'Selection was successfully updated.'
@@ -42,19 +36,16 @@ module Apidae
42
36
  end
43
37
  end
44
38
 
45
- # DELETE /selections/1
46
39
  def destroy
47
40
  @selection.destroy
48
41
  redirect_to selections_url, notice: 'Selection was successfully destroyed.'
49
42
  end
50
43
 
51
44
  private
52
- # Use callbacks to share common setup or constraints between actions.
53
45
  def set_selection
54
46
  @selection = Selection.find(params[:id])
55
47
  end
56
48
 
57
- # Only allow a trusted parameter "white list" through.
58
49
  def selection_params
59
50
  params.require(:selection).permit(:label, :reference, :apidae_id)
60
51
  end
@@ -0,0 +1,4 @@
1
+ module Apidae
2
+ module Apidae::ReferencesHelper
3
+ end
4
+ end
@@ -64,12 +64,12 @@ 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
- existing = Apidae::Object.find_by_apidae_id(object_data[:id])
67
+ existing = Obj.find_by_apidae_id(object_data[:id])
68
68
  if existing
69
- Apidae::Object.update_object(existing, object_data)
69
+ Obj.update_object(existing, object_data)
70
70
  result[:updated] += 1
71
71
  else
72
- Apidae::Object.add_object(object_data)
72
+ Obj.add_object(object_data)
73
73
  result[:created] += 1
74
74
  end
75
75
  end
@@ -85,7 +85,7 @@ module Apidae
85
85
  def self.delete_objects(deleted_json, result)
86
86
  deleted_ids = JSON.parse(deleted_json)
87
87
  deleted_ids.each do |id|
88
- obj = Apidae::Object.find_by_apidae_id(id)
88
+ obj = Obj.find_by_apidae_id(id)
89
89
  if obj
90
90
  obj.destroy!
91
91
  result[:deleted] += 1
@@ -104,7 +104,7 @@ module Apidae
104
104
  objects_json = File.read(json_file)
105
105
  objects_hashes = JSON.parse(objects_json, symbolize_names: true)
106
106
  objects_hashes.each do |object_data|
107
- obj = Apidae::Object.find_by_apidae_id(object_data[:id])
107
+ obj = Obj.find_by_apidae_id(object_data[:id])
108
108
  if obj
109
109
  yield(obj, object_data)
110
110
  obj.save!
@@ -140,13 +140,13 @@ module Apidae
140
140
 
141
141
  def self.add_or_update_selections(selections_json, result)
142
142
  selections_hashes = JSON.parse(selections_json, symbolize_names: true)
143
- deleted_ids = Apidae::Selection.all.collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
144
- Apidae::Selection.where(apidae_id: deleted_ids).delete_all
143
+ deleted_ids = Selection.all.collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
144
+ Selection.where(apidae_id: deleted_ids).delete_all
145
145
  selections_hashes.each do |selection_data|
146
146
  logger.info "Updating selection #{selection_data[:id]}"
147
- Apidae::Selection.add_or_update(selection_data)
147
+ Selection.add_or_update(selection_data)
148
148
  end
149
- result[:selections] = Apidae::Selection.all
149
+ result[:selections] = Selection.all
150
150
  .collect {|sel| {apidae_id: sel.apidae_id, reference: sel.reference, objects: sel.objects.count}}
151
151
  end
152
152
  end
@@ -1,5 +1,5 @@
1
1
  module Apidae
2
- class Object < ActiveRecord::Base
2
+ class Obj < ActiveRecord::Base
3
3
 
4
4
  belongs_to :town, class_name: 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code
5
5
  # has_many :attached_files, class_name: 'Apidae::AttachedFile'
@@ -16,7 +16,7 @@ module Apidae
16
16
  store_accessor :location_data, :address, :place, :latitude, :longitude, :access
17
17
  store_accessor :openings_data, :openings_desc, :openings, :time_periods
18
18
  store_accessor :rates_data, :rates_desc, :rates, :payment_methods
19
- store_accessor :service_data, :services, :equipments, :comfort, :activities
19
+ store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
20
20
  store_accessor :tags_data, :promo, :internal
21
21
 
22
22
  ACT = 'ACTIVITE'
@@ -60,7 +60,7 @@ module Apidae
60
60
  WEBSITE = 205
61
61
 
62
62
  def self.add_object(object_data)
63
- apidae_obj = Apidae::Object.new(apidae_id: object_data[:id])
63
+ apidae_obj = Obj.new(apidae_id: object_data[:id])
64
64
  update_object(apidae_obj, object_data)
65
65
  end
66
66
 
@@ -202,7 +202,7 @@ module Apidae
202
202
  chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
203
203
  area: apidae_obj.apidae_type == DOS ? data_hash.except(:classification) : nil,
204
204
  track: apidae_obj.apidae_type == EQU ? data_hash[:itineraire] : nil,
205
- products: lists_ids(data_hash[:typesProduit], data_hash[:aopAocIgps]),
205
+ products: lists_ids(data_hash[:typesProduit], data_hash[:aopAocIgps], data_hash[:specialites]),
206
206
  audience: lists_ids(prestations_hash[:typesClientele]),
207
207
  animals: prestations_hash[:animauxAcceptes] == 'ACCEPTES',
208
208
  extra: node_value(prestations_hash, :complementAccueil),
@@ -218,7 +218,9 @@ module Apidae
218
218
  equipments: lists_ids(data_hash[:equipements]),
219
219
  comfort: lists_ids(data_hash[:conforts]),
220
220
  activities: lists_ids(data_hash[:activites], type_data_hash[:activites],
221
- type_data_hash[:activitesSportives], type_data_hash[:activitesCulturelles])
221
+ type_data_hash[:activitesSportives], type_data_hash[:activitesCulturelles]),
222
+ challenged: lists_ids(data_hash[:tourismesAdaptes]),
223
+ languages: lists_ids(data_hash[:languesParlees])
222
224
  }
223
225
  end
224
226
  end
@@ -39,7 +39,7 @@ module Apidae
39
39
  end
40
40
 
41
41
  def detailed_label(language)
42
- category ? "#{Apidae::Reference.find_by_apidae_id(category).label(language)} - #{label(language)}" : label(language)
42
+ category ? "#{Reference.find_by_apidae_id(category).label(language)} - #{label(language)}" : label(language)
43
43
  end
44
44
  end
45
45
  end
@@ -1,7 +1,7 @@
1
1
  module Apidae
2
2
  class Selection < ActiveRecord::Base
3
3
  has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_selection_id
4
- has_many :objects, class_name: 'Apidae::Object', source: :apidae_object, through: :apidae_selection_objects
4
+ has_many :objects, class_name: 'Apidae::Obj', source: :apidae_object, through: :apidae_selection_objects
5
5
 
6
6
  AGENDA_ENDPOINT = 'agenda/detaille/list-identifiants'
7
7
  SELECTION_ENDPOINT = 'recherche/list-identifiants'
@@ -12,7 +12,7 @@ module Apidae
12
12
  before_validation :generate_reference, on: :create
13
13
 
14
14
  def self.add_or_update(selection_data)
15
- apidae_sel = Apidae::Selection.where(apidae_id: selection_data[:id]).first_or_initialize
15
+ apidae_sel = Selection.where(apidae_id: selection_data[:id]).first_or_initialize
16
16
  apidae_sel.label = selection_data[:nom]
17
17
  apidae_sel.save!
18
18
 
@@ -24,12 +24,12 @@ module Apidae
24
24
  removed = current_objs - imported_objs
25
25
 
26
26
  added.each do |o|
27
- obj = Apidae::Object.find_by_apidae_id(o)
28
- Apidae::SelectionObject.create(apidae_selection_id: apidae_sel.id, apidae_object_id: obj.id)
27
+ obj = Obj.find_by_apidae_id(o)
28
+ SelectionObject.create(apidae_selection_id: apidae_sel.id, apidae_object_id: obj.id)
29
29
  end
30
30
 
31
- removed_ids = Apidae::Object.where(apidae_id: removed).map {|o| o.id}
32
- Apidae::SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
31
+ removed_ids = Obj.where(apidae_id: removed).map {|o| o.id}
32
+ SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
33
33
  end
34
34
 
35
35
  def results(where_clause, offset, size)
@@ -62,6 +62,10 @@ module Apidae
62
62
  res
63
63
  end
64
64
 
65
+ def as_text
66
+ "#{label} (#{apidae_id})"
67
+ end
68
+
65
69
  private
66
70
 
67
71
  def query_api(query_args, all_results = false)
@@ -1,6 +1,6 @@
1
1
  module Apidae
2
2
  class SelectionObject < ApplicationRecord
3
- belongs_to :apidae_object, class_name: 'Apidae::Object', foreign_key: :apidae_object_id
3
+ belongs_to :apidae_object, class_name: 'Apidae::Obj', foreign_key: :apidae_object_id
4
4
  belongs_to :apidae_selection, class_name: 'Apidae::Selection', foreign_key: :apidae_selection_id
5
5
  end
6
6
  end
@@ -1,5 +1,8 @@
1
1
  <%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
2
2
  <div id="apidae_header" class="<%= styles[:header] %>">
3
+ <%= link_to pluralize(@selections, 'sélection', 'sélections'), apidae.selections_path, class: styles[:selections] %>
4
+ <%= link_to pluralize(@objects, 'objet touristique', 'objets touristiques'), apidae.objects_path, class: styles[:objects] %>
5
+ <%= link_to (pluralize(@references, 'élément', 'éléments') + ' de référence'), apidae.references_path, class: styles[:references] %>
3
6
  <%= link_to 'Retour', :back, class: styles[:back] %>
4
7
  <h1 class="<%= styles[:h1] %>">Apidae</h1>
5
8
  </div>
@@ -28,16 +31,11 @@
28
31
  <% end %>
29
32
  <% if @last_imports.empty? %>
30
33
  <tr>
31
- <td colspan="3">Aucun import pour le moment.</td>
34
+ <td colspan="5">Aucun import pour le moment.</td>
32
35
  </tr>
33
36
  <% end %>
34
37
  </tbody>
35
38
  </table>
36
39
  </div>
37
- <div id="apidae_navigation_panel" class="<%= styles[:body] %>">
38
- <h2 class="<%= styles[:h2] %>">Données issues d'Apidae</h2>
39
- <%= link_to pluralize(@selections, 'sélection', 'sélections'), apidae.selections_path, class: styles[:selections] %>
40
- <%= link_to pluralize(@objects, 'objet touristique', 'objets touristiques'), apidae.objects_path, class: styles[:objects] %>
41
- </div>
42
40
  </div>
43
41
  <% end %>
@@ -0,0 +1,35 @@
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 - Eléments de référence</h1>
5
+ </div>
6
+ <div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
7
+ <div id="apidae_imports_panel" class="<%= styles[:body] %>">
8
+ <table id="apidae_references" class="<%= styles[:table] %>">
9
+ <thead class="<%= styles[:table_head] %>">
10
+ <tr>
11
+ <th>Titre</th>
12
+ <th>Identifiant</th>
13
+ <th>Type</th>
14
+ <th>Mise à jour</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody class="<%= styles[:table_body] %>">
18
+ <% @references.each do |ref| %>
19
+ <tr>
20
+ <td><%= ref.label(:fr) %></td>
21
+ <td><%= ref.apidae_id %></td>
22
+ <td><%= ref.apidae_type %></td>
23
+ <td><%= ref.updated_at.strftime('Le %d/%m/%Y à %H:%M') if ref.updated_at %></td>
24
+ </tr>
25
+ <% end %>
26
+ <% if @references.empty? %>
27
+ <tr>
28
+ <td colspan="4">Aucune référence importée pour le moment.</td>
29
+ </tr>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
33
+ </div>
34
+ </div>
35
+ <% end %>
@@ -4,6 +4,7 @@ Apidae::Engine.routes.draw do
4
4
  resources :selections, only: [:index] do
5
5
  resources :objects, only: [:index]
6
6
  end
7
+ resources :references, only: [:index]
7
8
 
8
9
  match 'import/callback', via: :post, to: 'import#callback'
9
10
  match 'import/run', via: :post, to: 'import#run'
@@ -0,0 +1,5 @@
1
+ class RenameObjectsToObj < ActiveRecord::Migration[5.1]
2
+ def change
3
+ rename_table :apidae_objects, :apidae_objs
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "0.4.5"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ module Apidae
4
+ class ReferencesControllerTest < ActionDispatch::IntegrationTest
5
+ include Engine.routes.url_helpers
6
+
7
+ test "should get index" do
8
+ get apidae_references_index_url
9
+ assert_response :success
10
+ end
11
+
12
+ end
13
+ end
@@ -18,6 +18,7 @@ module Dummy
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
20
  # config.i18n.default_locale = :de
21
+ config.apidae_auth = :dummy_auth
21
22
  end
22
23
  end
23
24
 
@@ -0,0 +1,18 @@
1
+ class DummyUser
2
+ attr_accessor :id
3
+
4
+ def initialize(id)
5
+ @id = id
6
+ end
7
+ end
8
+
9
+ DEFAULT_USER = DummyUser.new(1)
10
+
11
+ Apidae::ApplicationController.class_eval do
12
+ def dummy_auth
13
+ end
14
+
15
+ def dummy_user
16
+ DEFAULT_USER
17
+ end
18
+ end
@@ -10,24 +10,11 @@
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: 20180314093512) do
13
+ ActiveRecord::Schema.define(version: 20180625050400) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
17
17
 
18
- create_table "apidae_attached_files", id: :serial, force: :cascade do |t|
19
- t.string "name"
20
- t.string "credits"
21
- t.text "description"
22
- t.integer "apidae_object_id"
23
- t.string "picture_file_name"
24
- t.string "picture_content_type"
25
- t.integer "picture_file_size"
26
- t.datetime "picture_updated_at"
27
- t.datetime "created_at", null: false
28
- t.datetime "updated_at", null: false
29
- end
30
-
31
18
  create_table "apidae_exports", id: :serial, force: :cascade do |t|
32
19
  t.string "status"
33
20
  t.string "remote_status"
@@ -50,18 +37,18 @@ ActiveRecord::Schema.define(version: 20180314093512) do
50
37
  t.datetime "updated_at", null: false
51
38
  end
52
39
 
53
- create_table "apidae_objects", id: :serial, force: :cascade do |t|
54
- t.jsonb "address"
40
+ create_table "apidae_objects_selections", id: :serial, force: :cascade do |t|
41
+ t.integer "object_id"
42
+ t.integer "selection_id"
43
+ end
44
+
45
+ create_table "apidae_objs", id: :serial, force: :cascade do |t|
55
46
  t.integer "apidae_id"
56
47
  t.string "apidae_type"
57
48
  t.string "apidae_subtype"
58
49
  t.string "title"
59
- t.text "short_desc"
60
50
  t.jsonb "contact"
61
- t.text "long_desc"
62
51
  t.jsonb "type_data"
63
- t.float "latitude"
64
- t.float "longitude"
65
52
  t.jsonb "openings_data"
66
53
  t.text "reservation"
67
54
  t.datetime "created_at", null: false
@@ -73,11 +60,9 @@ ActiveRecord::Schema.define(version: 20180314093512) do
73
60
  t.jsonb "rates_data"
74
61
  t.jsonb "attachments_data"
75
62
  t.jsonb "tags_data"
76
- end
77
-
78
- create_table "apidae_objects_selections", id: :serial, force: :cascade do |t|
79
- t.integer "object_id"
80
- t.integer "selection_id"
63
+ t.jsonb "meta_data"
64
+ t.jsonb "location_data"
65
+ t.jsonb "description_data"
81
66
  end
82
67
 
83
68
  create_table "apidae_references", force: :cascade do |t|
@@ -86,7 +71,8 @@ ActiveRecord::Schema.define(version: 20180314093512) do
86
71
  t.jsonb "label_data"
87
72
  t.datetime "created_at", null: false
88
73
  t.datetime "updated_at", null: false
89
- t.index ["apidae_id"], name: "index_apidae_references_on_apidae_id", unique: true
74
+ t.jsonb "meta_data"
75
+ t.index ["apidae_id"], name: "index_apidae_references_on_apidae_id"
90
76
  end
91
77
 
92
78
  create_table "apidae_selection_objects", force: :cascade do |t|
@@ -112,7 +98,7 @@ ActiveRecord::Schema.define(version: 20180314093512) do
112
98
  t.string "postal_code"
113
99
  t.datetime "created_at", null: false
114
100
  t.datetime "updated_at", null: false
115
- t.index ["insee_code"], name: "index_apidae_towns_on_insee_code", unique: true
101
+ t.index ["insee_code"], name: "index_apidae_towns_on_insee_code"
116
102
  end
117
103
 
118
104
  end
@@ -344,3 +344,72 @@ Migrating to AddTagsDataToApidaeObjects (20180314093512)
344
344
   (0.1ms) COMMIT
345
345
   (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
346
346
   (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
347
+ DEPRECATION WARNING: Passing string to be evaluated in :if and :unless conditional options is deprecated and will be removed in Rails 5.2 without replacement. Pass a symbol for an instance method, or a lambda, proc or block, instead. (called from <class:ApplicationController> at /Users/jbvilain/workspace/code/apidae-engine-rails/app/controllers/apidae/application_controller.rb:4)
348
+  (6.6ms) SELECT pg_try_advisory_lock(6140174353533887940)
349
+  (2.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
350
+ Migrating to AddMetaDataToApidaeObjects (20180314132631)
351
+  (0.1ms) BEGIN
352
+  (31.7ms) ALTER TABLE "apidae_objects" ADD "meta_data" jsonb
353
+ SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180314132631"]]
354
+  (1.2ms) COMMIT
355
+ Migrating to RemoveApidaeIdUnicity (20180319143954)
356
+  (0.2ms) BEGIN
357
+  (5.5ms) DROP INDEX "index_apidae_references_on_apidae_id"
358
+  (4.5ms) CREATE INDEX "index_apidae_references_on_apidae_id" ON "apidae_references" ("apidae_id")
359
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180319143954"]]
360
+  (2.0ms) COMMIT
361
+ Migrating to AddLocationDataToApidaeObjects (20180417164604)
362
+  (0.3ms) BEGIN
363
+  (0.3ms) ALTER TABLE "apidae_objects" ADD "location_data" jsonb
364
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180417164604"]]
365
+  (6.0ms) COMMIT
366
+ Migrating to RemoveAddressFromApidaeObjects (20180417165744)
367
+  (0.2ms) BEGIN
368
+  (12.4ms) ALTER TABLE "apidae_objects" DROP "address"
369
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180417165744"]]
370
+  (6.1ms) COMMIT
371
+ Migrating to RemoveLatLngFromApidaeObjects (20180417171344)
372
+  (0.2ms) BEGIN
373
+  (0.4ms) ALTER TABLE "apidae_objects" DROP "latitude"
374
+  (0.3ms) ALTER TABLE "apidae_objects" DROP "longitude"
375
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180417171344"]]
376
+  (6.3ms) COMMIT
377
+ Migrating to AddDescriptionDataToApidaeObjects (20180418141248)
378
+  (0.2ms) BEGIN
379
+  (0.3ms) ALTER TABLE "apidae_objects" ADD "description_data" jsonb
380
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180418141248"]]
381
+  (6.2ms) COMMIT
382
+ Migrating to RemoveDescColumnsFromApidaeObjects (20180418141305)
383
+  (0.2ms) BEGIN
384
+  (0.4ms) ALTER TABLE "apidae_objects" DROP "short_desc"
385
+  (0.2ms) ALTER TABLE "apidae_objects" DROP "long_desc"
386
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180418141305"]]
387
+  (5.9ms) COMMIT
388
+ Migrating to AddMetaDataToApidaeReferences (20180424141656)
389
+  (0.2ms) BEGIN
390
+  (0.3ms) ALTER TABLE "apidae_references" ADD "meta_data" jsonb
391
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180424141656"]]
392
+  (5.8ms) COMMIT
393
+ Migrating to RemoveInseeCodeUnicity (20180519170210)
394
+  (0.2ms) BEGIN
395
+  (13.0ms) DROP INDEX "index_apidae_towns_on_insee_code"
396
+  (7.7ms) CREATE INDEX "index_apidae_towns_on_insee_code" ON "apidae_towns" ("insee_code")
397
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180519170210"]]
398
+  (1.8ms) COMMIT
399
+ Migrating to DestroyAttachedFiles (20180521211735)
400
+  (0.2ms) BEGIN
401
+  (29.0ms) DROP TABLE "apidae_attached_files"
402
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180521211735"]]
403
+  (2.0ms) COMMIT
404
+ Migrating to RenameObjectsToObj (20180625050400)
405
+  (0.1ms) BEGIN
406
+  (6.5ms) ALTER TABLE "apidae_objects" RENAME TO "apidae_objs"
407
+  (0.3ms) ALTER TABLE "public"."apidae_objects_id_seq" RENAME TO "apidae_objs_id_seq"
408
+  (0.9ms) ALTER INDEX "apidae_objects_pkey" RENAME TO "apidae_objs_pkey"
409
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180625050400"]]
410
+  (0.6ms) COMMIT
411
+ ActiveRecord::InternalMetadata Load (23.6ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
412
+  (0.2ms) BEGIN
413
+  (0.1ms) COMMIT
414
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
415
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
@@ -3,45 +3,45 @@ require 'test_helper'
3
3
  module Apidae
4
4
  class FileImportTest < ActiveSupport::TestCase
5
5
  setup do
6
- Apidae::Object.delete_all
7
- Apidae::Selection.delete_all
6
+ Obj.delete_all
7
+ Selection.delete_all
8
8
  @result = {created: 0, updated: 0, deleted: 0, selections: []}
9
9
  end
10
10
 
11
11
  test "new object insertion" do
12
12
  objects_json = File.read('test/data/structure.json')
13
13
  FileImport.add_or_update_objects(objects_json, @result)
14
- assert_equal 1, Apidae::Object.count
15
- new_obj = Apidae::Object.first
14
+ assert_equal 1, Obj.count
15
+ new_obj = Obj.first
16
16
  assert_equal 504, new_obj.apidae_id
17
17
  assert_equal({created: 1, updated: 0, deleted: 0, selections: []}, @result)
18
18
  end
19
19
 
20
20
  test "existing object update" do
21
- Apidae::Object.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
21
+ Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
22
22
  objects_json = File.read('test/data/structure.json')
23
23
  FileImport.add_or_update_objects(objects_json, @result)
24
- assert_equal 1, Apidae::Object.count
25
- updated_obj = Apidae::Object.first
24
+ assert_equal 1, Obj.count
25
+ updated_obj = Obj.first
26
26
  assert_equal 504, updated_obj.apidae_id
27
27
  assert_equal 'Société des accordéonistes aixois', updated_obj.title
28
28
  assert_equal({created: 0, updated: 1, deleted: 0, selections: []}, @result)
29
29
  end
30
30
 
31
31
  test "existing object deletion" do
32
- Apidae::Object.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
32
+ Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
33
33
  objects_json = File.read('test/data/deletion.json')
34
34
  FileImport.delete_objects(objects_json, @result)
35
- assert_equal 0, Apidae::Object.count
35
+ assert_equal 0, Obj.count
36
36
  assert_equal({created: 0, updated: 0, deleted: 1, selections: []}, @result)
37
37
  end
38
38
 
39
39
  test "new selection insertion" do
40
- Apidae::Object.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
40
+ Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
41
41
  objects_json = File.read('test/data/selections.json')
42
42
  FileImport.add_or_update_selections(objects_json, @result)
43
- assert_equal 1, Apidae::Selection.count
44
- new_sel = Apidae::Selection.first
43
+ assert_equal 1, Selection.count
44
+ new_sel = Selection.first
45
45
  assert_equal 49063, new_sel.apidae_id
46
46
  assert_equal 'Sélection 1', new_sel.label
47
47
  assert_equal 'selection-1', new_sel.reference
@@ -50,14 +50,14 @@ module Apidae
50
50
  end
51
51
 
52
52
  test "existing selection update" do
53
- obj = Apidae::Object.create(apidae_id: 503, title: 'Société des contrebassistes aixois')
54
- Apidae::Object.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
55
- sel = Apidae::Selection.create(apidae_id: 49063, label: 'Sélection 2', reference: 'selection-2')
53
+ obj = Obj.create(apidae_id: 503, title: 'Société des contrebassistes aixois')
54
+ Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
55
+ sel = Selection.create(apidae_id: 49063, label: 'Sélection 2', reference: 'selection-2')
56
56
  sel.objects << obj
57
57
  assert_equal 1, sel.objects.count
58
58
  objects_json = File.read('test/data/update_selections.json')
59
59
  FileImport.add_or_update_selections(objects_json, @result)
60
- assert_equal 1, Apidae::Selection.count
60
+ assert_equal 1, Selection.count
61
61
  assert_equal 49063, sel.apidae_id
62
62
  assert_equal 'Sélection 2', sel.label
63
63
  assert_equal 'selection-2', sel.reference
@@ -66,19 +66,19 @@ module Apidae
66
66
  end
67
67
 
68
68
  test "existing selection deletion" do
69
- Apidae::Selection.create(apidae_id: 49063, label: 'Sélection 3', reference: 'selection-3')
69
+ Selection.create(apidae_id: 49063, label: 'Sélection 3', reference: 'selection-3')
70
70
  objects_json = File.read('test/data/delete_selections.json')
71
- assert_equal 1, Apidae::Selection.count
71
+ assert_equal 1, Selection.count
72
72
  FileImport.add_or_update_selections(objects_json, @result)
73
- assert_equal 0, Apidae::Selection.count
73
+ assert_equal 0, Selection.count
74
74
  end
75
75
 
76
76
  test "full import process" do
77
- Apidae::Object.create(apidae_id: 123, title: 'Objet à supprimer')
78
- Apidae::Object.create(apidae_id: 4826186, title: 'Objet à mettre à jour')
77
+ Obj.create(apidae_id: 123, title: 'Objet à supprimer')
78
+ Obj.create(apidae_id: 4826186, title: 'Objet à mettre à jour')
79
79
  result = FileImport.import('test/data/json_export.zip')
80
- assert_equal 2, Apidae::Selection.all.count
81
- assert_equal 5, Apidae::Object.all.count
80
+ assert_equal 2, Selection.all.count
81
+ assert_equal 5, Obj.all.count
82
82
  assert_equal({created: 4, updated: 1, deleted: 1, selections: [
83
83
  {apidae_id: 49063, reference: 'selection-1', objects: 2},
84
84
  {apidae_id: 49073, reference: 'selection-2', objects: 3}
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.5
4
+ version: 0.5.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-05-27 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.4
19
+ version: '5.1'
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: 5.1.4
26
+ version: '5.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.20'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.20'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubyzip
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: '1.0'
55
55
  description: To be completed
56
56
  email:
57
57
  - jbvilain@gmail.com
@@ -70,17 +70,19 @@ files:
70
70
  - app/controllers/apidae/dashboard_controller.rb
71
71
  - app/controllers/apidae/import_controller.rb
72
72
  - app/controllers/apidae/objects_controller.rb
73
+ - app/controllers/apidae/references_controller.rb
73
74
  - app/controllers/apidae/selections_controller.rb
74
75
  - app/helpers/apidae/api_helper.rb
75
76
  - app/helpers/apidae/application_helper.rb
76
77
  - app/helpers/apidae/dashboard_helper.rb
77
78
  - app/helpers/apidae/import_helper.rb
78
79
  - app/helpers/apidae/objects_helper.rb
80
+ - app/helpers/apidae/references_helper.rb
79
81
  - app/helpers/apidae/selections_helper.rb
80
82
  - app/models/apidae/application_record.rb
81
83
  - app/models/apidae/export.rb
82
84
  - app/models/apidae/file_import.rb
83
- - app/models/apidae/object.rb
85
+ - app/models/apidae/obj.rb
84
86
  - app/models/apidae/reference.rb
85
87
  - app/models/apidae/selection.rb
86
88
  - app/models/apidae/selection_object.rb
@@ -92,6 +94,7 @@ files:
92
94
  - app/views/apidae/objects/index.html.erb
93
95
  - app/views/apidae/objects/new.html.erb
94
96
  - app/views/apidae/objects/show.html.erb
97
+ - app/views/apidae/references/index.html.erb
95
98
  - app/views/apidae/selections/_form.html.erb
96
99
  - app/views/apidae/selections/edit.html.erb
97
100
  - app/views/apidae/selections/index.html.erb
@@ -130,6 +133,7 @@ files:
130
133
  - db/migrate/20180424141656_add_meta_data_to_apidae_references.rb
131
134
  - db/migrate/20180519170210_remove_insee_code_unicity.rb
132
135
  - db/migrate/20180521211735_destroy_attached_files.rb
136
+ - db/migrate/20180625050400_rename_objects_to_obj.rb
133
137
  - lib/apidae.rb
134
138
  - lib/apidae/engine.rb
135
139
  - lib/apidae/version.rb
@@ -139,6 +143,7 @@ files:
139
143
  - test/controllers/apidae/dashboard_controller_test.rb
140
144
  - test/controllers/apidae/import_controller_test.rb
141
145
  - test/controllers/apidae/objects_controller_test.rb
146
+ - test/controllers/apidae/references_controller_test.rb
142
147
  - test/controllers/apidae/selections_controller_test.rb
143
148
  - test/data/delete_selections.json
144
149
  - test/data/deletion.json
@@ -165,6 +170,7 @@ files:
165
170
  - test/dummy/config/environments/development.rb
166
171
  - test/dummy/config/environments/production.rb
167
172
  - test/dummy/config/environments/test.rb
173
+ - test/dummy/config/initializers/apidae.rb
168
174
  - test/dummy/config/initializers/assets.rb
169
175
  - test/dummy/config/initializers/backtrace_silencers.rb
170
176
  - test/dummy/config/initializers/cookies_serializer.rb
@@ -251,6 +257,7 @@ test_files:
251
257
  - test/dummy/config/initializers/assets.rb
252
258
  - test/dummy/config/initializers/cookies_serializer.rb
253
259
  - test/dummy/config/initializers/to_time_preserves_timezone.rb
260
+ - test/dummy/config/initializers/apidae.rb
254
261
  - test/dummy/config/initializers/inflections.rb
255
262
  - test/dummy/config.ru
256
263
  - test/dummy/Rakefile
@@ -282,6 +289,7 @@ test_files:
282
289
  - test/controllers/apidae/api_controller_test.rb
283
290
  - test/controllers/apidae/objects_controller_test.rb
284
291
  - test/controllers/apidae/dashboard_controller_test.rb
292
+ - test/controllers/apidae/references_controller_test.rb
285
293
  - test/controllers/apidae/import_controller_test.rb
286
294
  - test/data/update_selections.json
287
295
  - test/data/json_export.zip