From 4d0c2ec72558091fc4602eec58206da3b691ef7e Mon Sep 17 00:00:00 2001 From: echarp Date: Sun, 8 Mar 2015 23:41:52 +0100 Subject: [PATCH] =?UTF-8?q?Les=20=C3=A9v=C3=A9nements=20peuvent=20maintena?= =?UTF-8?q?nt=20avoir=20un=20nom=20de=20lieu=20associ=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/form.css.sass | 2 + app/controllers/events_controller.rb | 4 +- app/controllers/moderations_controller.rb | 4 +- app/views/events/_form.html.haml | 3 + app/views/events/index.xml.builder | 1 + app/views/events/show.html.haml | 3 + app/views/events/show.json.jbuilder | 4 +- app/views/events/show.text.haml | 1 + config/locales/models/en.yml | 1 + config/locales/models/fr.yml | 1 + ...20150301223829_add_place_name_to_events.rb | 6 + db/schema.rb | 138 ++++++++---------- test/fixtures/events.yml | 1 + 13 files changed, 83 insertions(+), 86 deletions(-) create mode 100644 db/migrate/20150301223829_add_place_name_to_events.rb diff --git a/app/assets/stylesheets/form.css.sass b/app/assets/stylesheets/form.css.sass index bf3c3739..bb67408a 100644 --- a/app/assets/stylesheets/form.css.sass +++ b/app/assets/stylesheets/form.css.sass @@ -54,6 +54,8 @@ content: $fa-var-toggle-off .field.description label:before content: $fa-var-pencil-square-o + .field.place_name label:before + content: $fa-var-flag .field.address label:before content: $fa-var-map-marker .field.city label:before diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 6531c97d..d224cbfc 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -109,8 +109,8 @@ class EventsController < ApplicationController def event_params params.require(:event) .permit :lock_version, :title, :start_time, :end_time, :description, - :address, :city, :region_id, :locality, :url, :contact, - :submitter, :tags + :place_name, :address, :city, :region_id, :locality, :url, + :contact, :submitter, :tags end # Check that you can only edit an existing event if you know its secret diff --git a/app/controllers/moderations_controller.rb b/app/controllers/moderations_controller.rb index d4a94129..592f5c1a 100644 --- a/app/controllers/moderations_controller.rb +++ b/app/controllers/moderations_controller.rb @@ -69,8 +69,8 @@ class ModerationsController < ApplicationController def moderation_params params.require(:event) .permit :lock_version, :title, :start_time, :end_time, :description, - :address, :city, :region_id, :locality, :url, :contact, - :submitter, :tags + :place_name, :address, :city, :region_id, :locality, :url, + :contact, :submitter, :tags end # Useful to manage absolute url in mails diff --git a/app/views/events/_form.html.haml b/app/views/events/_form.html.haml index ed3e6303..7dc1f0a2 100644 --- a/app/views/events/_form.html.haml +++ b/app/views/events/_form.html.haml @@ -26,6 +26,9 @@ = f.label :description = f.text_area :description, rows: 25 + .field.place_name + = f.label :place_name + = f.text_field :place_name .field.address .helper :markdown diff --git a/app/views/events/index.xml.builder b/app/views/events/index.xml.builder index 1167a0b2..b241ca60 100644 --- a/app/views/events/index.xml.builder +++ b/app/views/events/index.xml.builder @@ -6,6 +6,7 @@ xml.events do xml.title event.title xml.tag! 'start-time', event.start_time.strftime('%Y/%m/%d %T') xml.tag! 'end-time', event.end_time.strftime('%Y/%m/%d %T') + xml.place_name event.place_name xml.address event.address xml.city event.city xml.region event.region diff --git a/app/views/events/show.html.haml b/app/views/events/show.html.haml index bc1136e3..c5cf85a4 100644 --- a/app/views/events/show.html.haml +++ b/app/views/events/show.html.haml @@ -38,6 +38,7 @@ start_time: @event.start_time + 1.month, end_time: @event.end_time + 1.month, description: @event.description, + place_name: @event.place_name, address: @event.address, city: @event.city, region: @event.region, @@ -62,6 +63,8 @@ %p= display_date %p.full_address + - if @event.place_name.present? + %span= @event.place_name - if @event.address.present? %span= @event.address %span= link_to @event.city, diff --git a/app/views/events/show.json.jbuilder b/app/views/events/show.json.jbuilder index d07eac2a..f2c86ba1 100644 --- a/app/views/events/show.json.jbuilder +++ b/app/views/events/show.json.jbuilder @@ -1,4 +1,4 @@ json.extract! @event, :id, :title, :description, :start_time, :end_time, - :address, :city, :region, :locality, :url, :contact, :contact, - :submitter, :moderated, :tags, :secret, :decision_time, + :place_name, :address, :city, :region, :locality, :url, :contact, + :contact, :submitter, :moderated, :tags, :secret, :decision_time, :submission_time, :moderator_mail_id, :submitter_mail_id diff --git a/app/views/events/show.text.haml b/app/views/events/show.text.haml index 79c01858..69e06f47 100644 --- a/app/views/events/show.text.haml +++ b/app/views/events/show.text.haml @@ -2,6 +2,7 @@ #{Event.human_attribute_name(:title).concat(':').ljust 12 } #{@event.title} #{Event.human_attribute_name(:start_time).concat(':').ljust 12 } #{l @event.start_time, format: :at} #{Event.human_attribute_name(:end_time).concat(':').ljust 12 } #{l @event.end_time, format: :at} +#{Event.human_attribute_name(:place_name).concat(':').ljust 12 } #{@event.place_name} #{Event.human_attribute_name(:address).concat(':').ljust 12 } #{@event.address} #{Event.human_attribute_name(:city).concat(':').ljust 12 } #{@event.city} #{Event.human_attribute_name(:region).concat(':').ljust 12 } #{@event.region} diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index 83056a75..c0bf2c41 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -54,6 +54,7 @@ en: start_time: Start end_time: End description: Description + place_name: Place name address: Address city: City region: Region diff --git a/config/locales/models/fr.yml b/config/locales/models/fr.yml index c932ebc6..b24ed3be 100644 --- a/config/locales/models/fr.yml +++ b/config/locales/models/fr.yml @@ -55,6 +55,7 @@ fr: start_time: Début end_time: Fin description: Description + place_name: Nom du lieu address: Adresse city: Ville region: Région diff --git a/db/migrate/20150301223829_add_place_name_to_events.rb b/db/migrate/20150301223829_add_place_name_to_events.rb new file mode 100644 index 00000000..9f388adc --- /dev/null +++ b/db/migrate/20150301223829_add_place_name_to_events.rb @@ -0,0 +1,6 @@ +# Add more data to events, with an optionnal place name +class AddPlaceNameToEvents < ActiveRecord::Migration + def change + add_column :events, :place_name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 05231776..beaf0b73 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,5 @@ # encoding: UTF-8 +# rubocop:disable all # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -11,22 +12,22 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150215172739) do +ActiveRecord::Schema.define(version: 20150301223829) do create_table "active_admin_comments", force: :cascade do |t| t.string "namespace", limit: 255 - t.text "body" - t.string "resource_id", limit: 255, null: false - t.string "resource_type", limit: 255, null: false - t.integer "author_id" + t.text "body", limit: 65535 + t.string "resource_id", limit: 255, null: false + t.string "resource_type", limit: 255, null: false + t.integer "author_id", limit: 4 t.string "author_type", limit: 255 t.datetime "created_at" t.datetime "updated_at" end - add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id" - add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace" - add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id" + add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id", using: :btree + add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace", using: :btree + add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id", using: :btree create_table "admin_users", force: :cascade do |t| t.string "email", limit: 255, default: "", null: false @@ -34,7 +35,7 @@ ActiveRecord::Schema.define(version: 20150215172739) do t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", limit: 4, default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip", limit: 255 @@ -43,114 +44,91 @@ ActiveRecord::Schema.define(version: 20150215172739) do t.datetime "updated_at" end - add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true - add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true + add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true, using: :btree + add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true, using: :btree create_table "cities", force: :cascade do |t| t.string "name", limit: 255, default: "", null: false t.string "majname", limit: 255, default: "", null: false - t.integer "postalcode" - t.integer "inseecode" - t.integer "regioncode" + t.integer "postalcode", limit: 4 + t.integer "inseecode", limit: 4 + t.integer "regioncode", limit: 4 t.float "latitude", limit: 24 t.float "longitude", limit: 24 end - add_index "cities", ["name"], name: "cities_name" + add_index "cities", ["name"], name: "cities_name", using: :btree create_table "events", force: :cascade do |t| - t.string "title", limit: 255, default: "", null: false - t.text "description", null: false - t.datetime "start_time", null: false - t.datetime "end_time", null: false - t.string "city", limit: 255, default: "", null: false - t.integer "region_id", default: 0, null: false - t.integer "locality", default: 0, null: false - t.string "url", limit: 255, default: "", null: false - t.string "contact", limit: 255, default: "", null: false - t.string "submitter", limit: 255, default: "", null: false - t.integer "moderated", default: 0, null: false - t.string "tags", limit: 255, default: "", null: false - t.string "secret", limit: 255, default: "", null: false - t.datetime "decision_time", null: false - t.datetime "submission_time", null: false + t.string "title", limit: 255, default: "", null: false + t.text "description", limit: 65535, null: false + t.datetime "start_time", null: false + t.datetime "end_time", null: false + t.string "city", limit: 255, default: "", null: false + t.integer "region_id", limit: 4, default: 0, null: false + t.integer "locality", limit: 4, default: 0, null: false + t.string "url", limit: 255, default: "", null: false + t.string "contact", limit: 255, default: "", null: false + t.string "submitter", limit: 255, default: "", null: false + t.integer "moderated", limit: 4, default: 0, null: false + t.string "tags", limit: 255, default: "", null: false + t.string "secret", limit: 255, default: "", null: false + t.datetime "decision_time" + t.datetime "submission_time" t.string "moderator_mail_id", limit: 32 t.string "submitter_mail_id", limit: 32 - t.text "address" - t.float "latitude" - t.float "longitude" - t.integer "lock_version", default: 0, null: false + t.text "address", limit: 65535 + t.float "latitude", limit: 24 + t.float "longitude", limit: 24 + t.integer "lock_version", limit: 4, default: 0, null: false + t.string "place_name", limit: 255 end - add_index "events", ["start_time", "end_time"], name: "events_date" + add_index "events", ["start_time", "end_time"], name: "events_date", using: :btree create_table "kinds", force: :cascade do |t| - t.string "name", null: false - t.string "icon" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "name", limit: 255, null: false + t.string "icon", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "notes", force: :cascade do |t| - t.text "contents", null: false - t.datetime "date", null: false - t.integer "event_id" - t.integer "author_id" + t.text "contents", limit: 65535, null: false + t.datetime "date", null: false + t.integer "event_id", limit: 4 + t.integer "author_id", limit: 4 end create_table "orgas", force: :cascade do |t| - t.integer "region_id", default: 0, null: false - t.integer "department", default: 0, null: false + t.integer "region_id", limit: 4, default: 0, null: false + t.integer "department", limit: 4, default: 0, null: false t.string "name", limit: 255, default: "", null: false t.string "url", limit: 255, default: "", null: false t.string "city", limit: 255, default: "", null: false - t.string "place" - t.string "address" - t.integer "orga_kind_id" - t.integer "kind_id" - t.string "feed" - t.string "contact" - t.string "submitter" - t.boolean "moderated", default: false + t.integer "kind_id", limit: 4 + t.string "feed", limit: 255 + t.string "contact", limit: 255 + t.string "submitter", limit: 255 + t.boolean "moderated", limit: 1, default: false t.datetime "submission_time" t.datetime "decision_time" - t.string "secret" - t.boolean "deleted", default: false, null: false + t.string "secret", limit: 255 + t.boolean "deleted", limit: 1, default: false, null: false end - add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id" - add_index "orgas", ["orga_kind_id"], name: "index_orgas_on_orga_kind_id" + add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id", using: :btree create_table "regions", force: :cascade do |t| t.string "name", limit: 255, default: "", null: false end - create_table "taggings", force: :cascade do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type", limit: 255 - t.integer "tagger_id" - t.string "tagger_type", limit: 255 - t.string "context", limit: 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true - add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" - - create_table "tags", force: :cascade do |t| - t.string "name", limit: 255 - t.integer "taggings_count", default: 0 - end - - add_index "tags", ["name"], name: "index_tags_on_name", unique: true - create_table "translations", force: :cascade do |t| t.string "locale", limit: 255 t.string "key", limit: 255 - t.text "value" - t.text "interpolations" - t.boolean "is_proc", default: false + t.text "value", limit: 65535 + t.text "interpolations", limit: 65535 + t.boolean "is_proc", limit: 1, default: false end create_table "users", force: :cascade do |t| diff --git a/test/fixtures/events.yml b/test/fixtures/events.yml index 56486a30..b5f70d02 100644 --- a/test/fixtures/events.yml +++ b/test/fixtures/events.yml @@ -5,6 +5,7 @@ one: description: MyText start_time: <%= 2.hours.from_now %> end_time: <%= 3.hours.from_now %> + place_name: Here and there city: city_one.name region: region_one locality: 1