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