Event's url is no longer required

This commit is contained in:
echarp 2017-04-22 11:35:37 +02:00
parent baf6652040
commit 83f1e9dbc9
7 changed files with 19 additions and 10 deletions

View File

@ -22,7 +22,7 @@ class Event < ActiveRecord::Base
validates :description, presence: true validates :description, presence: true
validates :city, presence: true validates :city, presence: true
validates :region, presence: true validates :region, presence: true
validates :url, presence: true, format: %r{\Ahttps?:\/\/.*\..*\z} validates :url, allow_nil: true, format: %r{\Ahttps?:\/\/.*\..*\z}
validates :contact, email: true validates :contact, email: true
validates :submitter, email: true validates :submitter, email: true

View File

@ -22,6 +22,7 @@
= p = p
\ \
* #{[event.place_name, event.full_address].compact.join ', '} * #{[event.place_name, event.full_address].compact.join ', '}
- if event.url.present?
* #{Event.human_attribute_name :url}: #{link_to event.url, event.url} * #{Event.human_attribute_name :url}: #{link_to event.url, event.url}
* #{Event.human_attribute_name :tags}: * #{Event.human_attribute_name :tags}:
#{event.tags.collect { |tag| "[#{tag}](#{tag_url tag.name})" }.join ', '} #{event.tags.collect { |tag| "[#{tag}](#{tag_url tag.name})" }.join ', '}

View File

@ -82,7 +82,7 @@
:markdown :markdown
#{t '.url_helper'} #{t '.url_helper'}
= f.label :url = f.label :url
= f.url_field :url, required: true, placeholder: 'Ex: http://april.org' = f.url_field :url, placeholder: 'Ex: http://april.org'
.field.contact .field.contact
.helper .helper
:markdown :markdown

View File

@ -97,6 +97,7 @@
%h3 %h3
%em.fa.fa-info-circle %em.fa.fa-info-circle
= t '.infos' = t '.infos'
- if @event.url.present?
%p %p
%em.fa.fa-external-link %em.fa.fa-external-link
%span.label= Event.human_attribute_name :url %span.label= Event.human_attribute_name :url

View File

@ -10,6 +10,7 @@
#{Event.human_attribute_name(:city).concat(':').ljust 12 } #{@event.city} #{Event.human_attribute_name(:city).concat(':').ljust 12 } #{@event.city}
#{Event.human_attribute_name(:region).concat(':').ljust 12 } #{@event.region} #{Event.human_attribute_name(:region).concat(':').ljust 12 } #{@event.region}
#{Event.human_attribute_name(:locality).concat(':').ljust 12 } #{t "attributes.locality_#{@event.locality}"} #{Event.human_attribute_name(:locality).concat(':').ljust 12 } #{t "attributes.locality_#{@event.locality}"}
- if @event.url.present?
#{Event.human_attribute_name(:url).concat(':').ljust 12 } #{@event.url} #{Event.human_attribute_name(:url).concat(':').ljust 12 } #{@event.url}
#{Event.human_attribute_name(:contact).concat(':').ljust 12 } #{@event.contact} #{Event.human_attribute_name(:contact).concat(':').ljust 12 } #{@event.contact}
#{Event.human_attribute_name(:submitter).concat(':').ljust 12 } #{@event.submitter} #{Event.human_attribute_name(:submitter).concat(':').ljust 12 } #{@event.submitter}

View File

@ -0,0 +1,6 @@
# Event url are now optional
class ChangeEventsNullUrl < ActiveRecord::Migration
def change
change_column :events, :url, :string, default: '', null: true
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161210154558) do ActiveRecord::Schema.define(version: 20170422083422) do
create_table "active_admin_comments", force: :cascade do |t| create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255 t.string "namespace", limit: 255
@ -66,7 +66,7 @@ ActiveRecord::Schema.define(version: 20161210154558) do
t.string "city", limit: 255, default: "" t.string "city", limit: 255, default: ""
t.integer "region_id", limit: 4, default: 0, null: false t.integer "region_id", limit: 4, default: 0, null: false
t.integer "locality", 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 "url", limit: 255, default: ""
t.string "contact", limit: 255, default: "", null: false t.string "contact", limit: 255, default: "", null: false
t.string "submitter", limit: 255, default: "", null: false t.string "submitter", limit: 255, default: "", null: false
t.integer "moderated", limit: 4, default: 0, null: false t.integer "moderated", limit: 4, default: 0, null: false