From 1c8d362f11bcaa35963f098f837697bc7a23cc95 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 11 Oct 2017 14:58:38 +0200 Subject: [PATCH] ability to disable space --- app/assets/templates/spaces/_form.html | 19 +++++++++++++++++++ app/controllers/api/spaces_controller.rb | 2 +- app/views/api/spaces/index.json.jbuilder | 2 +- app/views/api/spaces/show.json.jbuilder | 2 +- config/locales/app.shared.en.yml | 1 + config/locales/app.shared.fr.yml | 1 + config/locales/app.shared.pt.yml | 1 + .../20171011125217_add_disabled_to_space.rb | 5 +++++ db/schema.rb | 3 ++- 9 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20171011125217_add_disabled_to_space.rb diff --git a/app/assets/templates/spaces/_form.html b/app/assets/templates/spaces/_form.html index c82a8d040..ee19adf49 100644 --- a/app/assets/templates/spaces/_form.html +++ b/app/assets/templates/spaces/_form.html @@ -107,3 +107,22 @@ {{ 'space.add_an_attachment' | translate }} + + +
+ +
+ + +
+
diff --git a/app/controllers/api/spaces_controller.rb b/app/controllers/api/spaces_controller.rb index 37be2d33b..5c0c79bc1 100644 --- a/app/controllers/api/spaces_controller.rb +++ b/app/controllers/api/spaces_controller.rb @@ -43,7 +43,7 @@ class API::SpacesController < API::ApiController end def space_params - params.require(:space).permit(:name, :description, :characteristics, :default_places, space_image_attributes: [:attachment], + params.require(:space).permit(:name, :description, :characteristics, :default_places, :disabled, space_image_attributes: [:attachment], space_files_attributes: [:id, :attachment, :_destroy]) end end diff --git a/app/views/api/spaces/index.json.jbuilder b/app/views/api/spaces/index.json.jbuilder index 737e70dec..e0dc6c7d7 100644 --- a/app/views/api/spaces/index.json.jbuilder +++ b/app/views/api/spaces/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@spaces) do |space| - json.extract! space, :id, :name, :description, :slug, :default_places + json.extract! space, :id, :name, :description, :slug, :default_places, :disabled json.space_image space.space_image.attachment.medium.url if space.space_image end diff --git a/app/views/api/spaces/show.json.jbuilder b/app/views/api/spaces/show.json.jbuilder index 0722a73fe..6ce0b7843 100644 --- a/app/views/api/spaces/show.json.jbuilder +++ b/app/views/api/spaces/show.json.jbuilder @@ -1,4 +1,4 @@ -json.extract! @space, :id, :name, :description, :characteristics, :created_at, :updated_at, :slug, :default_places +json.extract! @space, :id, :name, :description, :characteristics, :created_at, :updated_at, :slug, :default_places, :disabled json.space_image @space.space_image.attachment.large.url if @space.space_image json.space_files_attributes @space.space_files do |f| json.id f.id diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 24a4258dd..6f2f961a3 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -415,6 +415,7 @@ en: add_an_attachment: "Add an attachment" default_places: "Default maximum tickets" default_places_is_required: "Default maximum tickets is required." + disable_space: "Disable space" cart: # module de panier d'achat de réservations diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index 58fbe2f6e..ceee826ec 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -424,6 +424,7 @@ fr: add_an_attachment: "Ajouter une pièce jointe" default_places: "Maximum de places par défaut" default_places_is_required: "Le nombre de places maximum par défaut est requis." + disable_space: "Désactiver l'espace" cart: # module de panier d'achat de réservations diff --git a/config/locales/app.shared.pt.yml b/config/locales/app.shared.pt.yml index 40beef4e0..937950dfe 100755 --- a/config/locales/app.shared.pt.yml +++ b/config/locales/app.shared.pt.yml @@ -415,6 +415,7 @@ pt: add_an_attachment: "Adicionar um anexo" default_places: "Tickets máximo padrão" default_places_is_required: "Tickets máximo padrão é obrigatório." + disable_space: "Disable space" # TODO cart: # module de panier d'achat de réservations diff --git a/db/migrate/20171011125217_add_disabled_to_space.rb b/db/migrate/20171011125217_add_disabled_to_space.rb new file mode 100644 index 000000000..3353af7c6 --- /dev/null +++ b/db/migrate/20171011125217_add_disabled_to_space.rb @@ -0,0 +1,5 @@ +class AddDisabledToSpace < ActiveRecord::Migration + def change + add_column :spaces, :disabled, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 70205b2a5..f93bf99c1 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: 20171011100640) do +ActiveRecord::Schema.define(version: 20171011125217) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -571,6 +571,7 @@ ActiveRecord::Schema.define(version: 20171011100640) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "characteristics" + t.boolean "disabled" end create_table "spaces_availabilities", force: :cascade do |t|