r3252 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll resources/i18n
Author: fdesbois Date: 2012-04-12 18:27:32 +0200 (Thu, 12 Apr 2012) New Revision: 3252 Url: http://chorem.org/repositories/revision/pollen/3252 Log: validation for poll dates Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-04-12 10:32:25 UTC (rev 3251) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-04-12 16:27:32 UTC (rev 3252) @@ -439,9 +439,36 @@ } } } + + if (validateEndDate(poll.getBeginChoiceDate(), poll.getEndChoiceDate())) { + + addFieldError("poll.endChoiceDate", + _("pollen.error.poll.endChoiceDate.before.beginChoiceDate")); + result = true; + } + if (validateEndDate(poll.getBeginDate(), poll.getEndDate())) { + + addFieldError("poll.endDate", + _("pollen.error.poll.endDate.before.beginDate")); + result = true; + } + + if (validateEndDate(poll.getEndChoiceDate(), poll.getEndDate())) { + + addFieldError("poll.endChoiceDate", + _("pollen.error.poll.endChoiceDate.after.endDate")); + result = true; + } + return result; } + + protected boolean validateEndDate(Date begin, Date end) { + return begin != null + && end != null + && end.before(begin); + } protected boolean validateVotingList(int votingListNumber, VotingList votingList, Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-12 10:32:25 UTC (rev 3251) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-12 16:27:32 UTC (rev 3252) @@ -136,6 +136,9 @@ pollen.error.password2.required=You must repeat your password for confirmation pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques pollen.error.poll.detected.duplicate.choice.name=Choices must be unique. +pollen.error.poll.endChoiceDate.after.endDate=The choice end date must be sooner than the poll end date. +pollen.error.poll.endChoiceDate.before.beginChoiceDate=The choice end date must be later than the begin date. +pollen.error.poll.endDate.before.beginDate=The poll end date must be later than the begin date. pollen.error.poll.notfound=No such poll exists. Please make sure that you are using the correct link and copy it completely into your browser's address field. pollen.error.poll.personToList.email.doublon= pollen.error.poll.personToList.email.not.valid= Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-12 10:32:25 UTC (rev 3251) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-12 16:27:32 UTC (rev 3252) @@ -143,6 +143,9 @@ pollen.error.password2.required=Mot de passe répété obligatoire pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques pollen.error.poll.detected.duplicate.choice.name=Les choix doivent être uniques. +pollen.error.poll.endChoiceDate.after.endDate=La date de fin d'ajout de choix doit-être antérieure à la date de fin du sondage. +pollen.error.poll.endChoiceDate.before.beginChoiceDate=La date de fin d'ajout de choix doit-être postérieure à la date de début. +pollen.error.poll.endDate.before.beginDate=La date de fin du sondage doit-être postérieure à la date de début. pollen.error.poll.notfound=Il n'y a pas de sondage à cette adresse. Veuillez verifier que vous utilisez le lien correcte et copiez-le complètement dans le champ d'adresse de votre navigateur. pollen.error.poll.personToList.email.doublon=Les emails doivent être uniques. pollen.error.poll.personToList.email.not.valid=Email non valide
participants (1)
-
fdesbois@users.chorem.org