aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2016-08-31 12:14:35 +0200
committerjpl2016-08-31 12:14:35 +0200
commitcd6c8e675e6fa28b5655cbe8d6dc4167b6125915 (patch)
treeecf0a13ffa35a7e22dcd47158b6ecef61e928df0
parent094f691e0dd4305070fcb97eff619dd19aa02086 (diff)
downloadchouette-core-cd6c8e675e6fa28b5655cbe8d6dc4167b6125915.tar.bz2
Refs #1523: adding archived_at and (un)archive actions
-rw-r--r--app/controllers/referentials_controller.rb16
-rw-r--r--app/models/referential.rb17
-rw-r--r--db/migrate/20160831094427_add_archived_at_to_referentials.rb5
-rw-r--r--db/schema.rb6
4 files changed, 40 insertions, 4 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 34ba37380..09d990752 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -53,7 +53,19 @@ class ReferentialsController < BreadcrumbController
private
def referential_params
- params.require(:referential).permit( :id, :name, :slug, :prefix, :time_zone, :upper_corner, :lower_corner, :organisation_id, :projection_type, :data_format )
+ params.require(:referential).permit(
+ :id,
+ :name,
+ :slug,
+ :prefix,
+ :time_zone,
+ :upper_corner,
+ :lower_corner,
+ :organisation_id,
+ :projection_type,
+ :data_format,
+ :archived_at
+ )
end
-end
+end \ No newline at end of file
diff --git a/app/models/referential.rb b/app/models/referential.rb
index b41a7a434..51168a55f 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -207,4 +207,21 @@ class Referential < ActiveRecord::Base
bounds = read_attribute(:bounds)
GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope
end
+
+ def archived?
+ true if !archived_at.nil?
+ end
+ alias_method :archived, :archived?
+
+ def archived=(state)
+ state = [true, "1"].include?(state)
+ self.archived_at = (state ? Time.now : nil)
+ end
+
+ def archive
+ self.archived = true
+ end
+ def unarchive
+ self.archived = false
+ end
end
diff --git a/db/migrate/20160831094427_add_archived_at_to_referentials.rb b/db/migrate/20160831094427_add_archived_at_to_referentials.rb
new file mode 100644
index 000000000..be6b01c5a
--- /dev/null
+++ b/db/migrate/20160831094427_add_archived_at_to_referentials.rb
@@ -0,0 +1,5 @@
+class AddArchivedAtToReferentials < ActiveRecord::Migration
+ def change
+ add_column :referentials, :archived_at, :datetime
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0de1ce9f1..2aaecbf63 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160804134627) do
+ActiveRecord::Schema.define(version: 20160831094427) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -291,6 +291,7 @@ ActiveRecord::Schema.define(version: 20160804134627) do
t.integer "line_referential_sync_id"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "message"
end
add_index "line_sync_operations", ["line_referential_sync_id"], :name => "index_line_sync_operations_on_line_referential_sync_id"
@@ -393,6 +394,7 @@ ActiveRecord::Schema.define(version: 20160804134627) do
t.integer "line_referential_id"
t.integer "stop_area_referential_id"
t.integer "offer_workbench_id"
+ t.datetime "archived_at"
end
create_table "route_sections", force: true do |t|
@@ -603,7 +605,7 @@ ActiveRecord::Schema.define(version: 20160804134627) do
t.integer "invited_by_id"
t.string "invited_by_type"
t.datetime "invitation_created_at"
- t.string "username", null: false
+ t.string "username"
t.datetime "synced_at"
end