Skip to content
Extraits de code Groupes Projets
Valider ae7015da rédigé par echarp's avatar echarp
Parcourir les fichiers

On ne peut plus saisir un événement dont la date de début est après la date de fin

parent d9125429
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -30,6 +30,13 @@ $(document).ready -> ...@@ -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 ...@@ -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
font-size: 12px padding: 0 1em
list-style: square li
font-size: 12px
list-style: square
...@@ -15,6 +15,7 @@ class Event < ActiveRecord::Base ...@@ -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 ...@@ -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
= 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
......
...@@ -35,5 +35,5 @@ ...@@ -35,5 +35,5 @@
=t '.ok' =t '.ok'
%fieldset %fieldset
%legend=Event.model_name.human %legend= Event.model_name.human
= render file: '/events/show' = render file: '/events/show'
...@@ -61,3 +61,9 @@ en: ...@@ -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: ...@@ -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
en: en:
mail_prefix: "[AdL-en] " mail_prefix: "[AdL] "
show: View show: View
save: Save save: Save
edit: Edit edit: Edit
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter