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 :city, 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 :submitter, email: true

View File

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

View File

@ -82,7 +82,7 @@
:markdown
#{t '.url_helper'}
= 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
.helper
:markdown

View File

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

View File

@ -10,7 +10,8 @@
#{Event.human_attribute_name(:city).concat(':').ljust 12 } #{@event.city}
#{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(:url).concat(':').ljust 12 } #{@event.url}
- if @event.url.present?
#{Event.human_attribute_name(:url).concat(':').ljust 12 } #{@event.url}
#{Event.human_attribute_name(:contact).concat(':').ljust 12 } #{@event.contact}
#{Event.human_attribute_name(:submitter).concat(':').ljust 12 } #{@event.submitter}
#{Event.human_attribute_name(:tags).concat(':').ljust 12 } #{@event.tag_list}

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.
ActiveRecord::Schema.define(version: 20161210154558) do
ActiveRecord::Schema.define(version: 20170422083422) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255
@ -66,7 +66,7 @@ ActiveRecord::Schema.define(version: 20161210154558) do
t.string "city", limit: 255, default: ""
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 "url", limit: 255, default: ""
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