aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/referentials_controller.rb9
-rw-r--r--app/models/referential.rb22
-rw-r--r--app/views/referentials/show.html.slim17
-rw-r--r--config/locales/referentials.en.yml5
-rw-r--r--config/locales/referentials.fr.yml5
-rw-r--r--config/routes.rb8
6 files changed, 52 insertions, 14 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 09d990752..28a95c784 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -27,6 +27,15 @@ class ReferentialsController < BreadcrumbController
end
end
+ def archive
+ referential.archive!
+ redirect_to referential_path, notice: t('notice.referential.archived')
+ end
+ def unarchive
+ referential.unarchive!
+ redirect_to referential_path, notice: t('notice.referential.unarchived')
+ end
+
protected
alias_method :referential, :resource
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 51168a55f..d4bdc8374 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -208,20 +208,18 @@ class Referential < ActiveRecord::Base
GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope
end
+ # Archive
def archived?
- true if !archived_at.nil?
+ archived_at != nil
end
- alias_method :archived, :archived?
- def archived=(state)
- state = [true, "1"].include?(state)
- self.archived_at = (state ? Time.now : nil)
+ def archive!
+ # self.archived = true
+ touch :archived_at
end
-
- def archive
- self.archived = true
- end
- def unarchive
- self.archived = false
+ def unarchive!
+ # self.archived = false
+ update_column :archived_at, nil
end
-end
+
+end \ No newline at end of file
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 1405d4dd2..d5fed0344 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -1,4 +1,6 @@
-= title_tag @referential.name
+h2
+ = @referential.name
+ em.small = " (archivé)" if @referential.archived?
.summary
p
@@ -49,6 +51,19 @@
- content_for :sidebar do
ul.actions
li = link_to t('referentials.actions.edit'), edit_referential_path(@referential), class: 'edit'
+
+ li
+ - if @referential.archived?
+ = link_to unarchive_referential_path(@referential), method: :put do
+ span.fa-stack
+ span.fa.fa-archive.fa-stack-1x
+ span.fa.fa-ban.fa-stack-2x
+ = " Désarchiver cet espace de données"
+ - else
+ = link_to archive_referential_path(@referential), method: :put do
+ span.fa.fa-archive
+ = " Archiver cet espace de données"
+
li = link_to t('referentials.actions.destroy'), referential_path(@referential), method: :delete, data: {:confirm => t('referentials.actions.destroy_confirm')}, class: "remove"
li = link_to t('api_keys.actions.new'), new_referential_api_key_path(@referential), class: 'add'
br
diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml
index 74342e9e0..3691a8227 100644
--- a/config/locales/referentials.en.yml
+++ b/config/locales/referentials.en.yml
@@ -77,3 +77,8 @@ en:
prefix: "only alphanumerical or underscore characters"
upper_corner: "latitude,longitude in WGS84 referential, dot for decimal separator"
lower_corner: "latitude,longitude in WGS84 referential, dot for decimal separator"
+
+ notice:
+ referential:
+ archived: "The data space has been successfully archived"
+ unarchived: "The data space has been successfully unarchived" \ No newline at end of file
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index d8b72d3e3..cada9c3a0 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -77,3 +77,8 @@ fr:
prefix: "caractères autorisés : alphanumériques et 'souligné'"
upper_corner: "latitude,longitude dans le référentiel WGS84, le séparateur de décimales est 'point'"
lower_corner: "latitude,longitude dans le référentiel WGS84, le séparateur de décimales est 'point'"
+
+ notice:
+ referential:
+ archived: "L'espace de données a été correctement archivé"
+ unarchived: "L'espace de données a été correctement désarchivé"
diff --git a/config/routes.rb b/config/routes.rb
index f83f4771c..af466f640 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -72,6 +72,12 @@ ChouetteIhm::Application.routes.draw do
end
end
+ # Archive/unarchive
+ member do
+ put :archive
+ put :unarchive
+ end
+
resources :networks
match 'lines' => 'lines#destroy_all', :via => :delete
@@ -200,4 +206,4 @@ ChouetteIhm::Application.routes.draw do
get '/422', :to => 'errors#server_error'
get '/500', :to => 'errors#server_error'
-end
+end \ No newline at end of file