On ne peut plus saisir un événement dont la date de début est après la date de fin
This commit is contained in:
parent
d912542950
commit
ae7015da2d
@ -30,6 +30,13 @@ $(document).ready ->
|
|||||||
|
|
||||||
elt.select2 tags: tags, separator: [' '], tokenSeparators: [' ']
|
elt.select2 tags: tags, separator: [' '], tokenSeparators: [' ']
|
||||||
|
|
||||||
|
$('#event_start_time').change ->
|
||||||
|
if $('#event_start_time').val() >= $('#event_end_time').val()
|
||||||
|
$('#event_end_time').val($('#event_start_time').val())
|
||||||
|
$('#event_end_time').change ->
|
||||||
|
if $('#event_start_time').val() >= $('#event_end_time').val()
|
||||||
|
$('#event_start_time').val($('#event_end_time').val())
|
||||||
|
|
||||||
$(document).on 'page:receive', ->
|
$(document).on 'page:receive', ->
|
||||||
# Delete existing tinymce editors, very important in the turbolinks context!
|
# Delete existing tinymce editors, very important in the turbolinks context!
|
||||||
tinymce.remove()
|
tinymce.remove()
|
||||||
|
@ -5,27 +5,21 @@ div
|
|||||||
#notice
|
#notice
|
||||||
color: green
|
color: green
|
||||||
|
|
||||||
.field_with_errors
|
|
||||||
padding: 2px
|
|
||||||
background-color: red
|
|
||||||
display: table
|
|
||||||
|
|
||||||
#error_explanation
|
#error_explanation
|
||||||
width: 450px
|
width: 450px
|
||||||
border: 2px solid red
|
border: 2px solid red
|
||||||
padding: 7px
|
|
||||||
padding-bottom: 0
|
padding-bottom: 0
|
||||||
margin-bottom: 20px
|
margin-bottom: 20px
|
||||||
background-color: #f0f0f0
|
background-color: #f0f0f0
|
||||||
h2
|
h2
|
||||||
text-align: left
|
text-align: left
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
padding: 5px 5px 5px 15px
|
padding: 15px
|
||||||
font-size: 12px
|
font-size: 12px
|
||||||
margin: -7px
|
|
||||||
margin-bottom: 0px
|
|
||||||
background-color: #c00
|
background-color: #c00
|
||||||
color: #fff
|
color: #fff
|
||||||
ul li
|
p, ul
|
||||||
|
padding: 0 1em
|
||||||
|
li
|
||||||
font-size: 12px
|
font-size: 12px
|
||||||
list-style: square
|
list-style: square
|
||||||
|
@ -15,6 +15,7 @@ class Event < ActiveRecord::Base
|
|||||||
validates :contact, presence: true
|
validates :contact, presence: true
|
||||||
validates :contact, email: true
|
validates :contact, email: true
|
||||||
validates :submitter, email: true
|
validates :submitter, email: true
|
||||||
|
validate :end_after_start
|
||||||
|
|
||||||
geocoded_by :full_address, lookup: :nominatim
|
geocoded_by :full_address, lookup: :nominatim
|
||||||
# after_validation :geocode, if: -> (obj) { obj.address_changed? }
|
# after_validation :geocode, if: -> (obj) { obj.address_changed? }
|
||||||
@ -81,4 +82,12 @@ class Event < ActiveRecord::Base
|
|||||||
def full_address
|
def full_address
|
||||||
[address, city, related_region.name].compact.join ', '
|
[address, city, related_region.name].compact.join ', '
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def end_after_start
|
||||||
|
return if end_time.blank? || start_time.blank?
|
||||||
|
|
||||||
|
errors.add :end_time, :before_start if end_time <= start_time
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
= form_for @event, url: (@moderation ? moderation_path(@moderation) : @event.persisted? ? event_path(@event) : nil) do |f|
|
= form_for @event, url: (@moderation ? moderation_path(@moderation) : @event.persisted? ? event_path(@event) : nil) do |f|
|
||||||
- if @event.errors.any?
|
- if @event.errors.any?
|
||||||
#error_explanation.error.flash
|
#flash_messages
|
||||||
%h2= "#{pluralize(@event.errors.count, "error")} prohibited this event from being saved:"
|
|
||||||
- @event.errors.full_messages.each do |msg|
|
- @event.errors.full_messages.each do |msg|
|
||||||
%p= msg
|
%p.flash.alert= msg
|
||||||
|
|
||||||
- if @event.persisted?
|
- if @event.persisted?
|
||||||
- unless @moderation
|
- unless @moderation
|
||||||
|
@ -61,3 +61,9 @@ en:
|
|||||||
value: Value
|
value: Value
|
||||||
interpolations: Interpolations
|
interpolations: Interpolations
|
||||||
is_proc: Procedure?
|
is_proc: Procedure?
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
event:
|
||||||
|
attributes:
|
||||||
|
end_time:
|
||||||
|
before_start: can not be before beginning
|
||||||
|
@ -61,3 +61,9 @@ fr:
|
|||||||
value: Valeur
|
value: Valeur
|
||||||
interpolations: Interpolations
|
interpolations: Interpolations
|
||||||
is_proc: Procédure?
|
is_proc: Procédure?
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
event:
|
||||||
|
attributes:
|
||||||
|
end_time:
|
||||||
|
before_start: ne peut être avant le début
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
en:
|
en:
|
||||||
mail_prefix: "[AdL-en] "
|
mail_prefix: "[AdL] "
|
||||||
show: View
|
show: View
|
||||||
save: Save
|
save: Save
|
||||||
edit: Edit
|
edit: Edit
|
||||||
|
Loading…
Reference in New Issue
Block a user