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 ->
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
font-size: 12px
list-style: square
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
= 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
......
......@@ -35,5 +35,5 @@
=t '.ok'
%fieldset
%legend=Event.model_name.human
%legend= Event.model_name.human
= render file: '/events/show'
......@@ -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
en:
mail_prefix: "[AdL-en] "
mail_prefix: "[AdL] "
show: View
save: Save
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