r3668 - in trunk/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll/vote resources resources/i18n
Author: tchemit Date: 2012-08-29 18:03:56 +0200 (Wed, 29 Aug 2012) New Revision: 3668 Url: http://chorem.org/repositories/revision/pollen/3668 Log: fixes #798: Errorneous submit makes 'number' poll submission fail Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/VoteForPoll.java trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties trunk/pollen-ui-struts2/src/main/resources/shiro.ini Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/VoteForPoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/VoteForPoll.java 2012-08-29 15:28:07 UTC (rev 3667) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/vote/VoteForPoll.java 2012-08-29 16:03:56 UTC (rev 3668) @@ -112,10 +112,28 @@ VoteCountingStrategy strategy = getVoteCountingStrategy(getPoll()); boolean voteValid = true; + int voteNumber = 0; for (VoteToChoice voteToChoice : vote.getChoiceVoteToChoice()) { Integer value = voteToChoice.getVoteValue(); + if (value==null) { + + // check value if same as the one return by request + // otherwise it means there is a conversion error + String[] values = getParameters().get("vote.choiceVoteToChoice[" + voteNumber + "].voteValue"); + String paramValue = values==null || values.length<1?null:values[0]; + + if (StringUtils.isNotBlank(paramValue)) { + + // vote value changed + String validMessage = + _("pollen.error.vote.invalidFormat", paramValue); + addFieldError("vote.choices", validMessage); + voteValid = false; + break; + } + } // check if vote is null ? boolean voteNull = strategy.isVoteValueNull(value); Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-08-29 15:28:07 UTC (rev 3667) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-08-29 16:03:56 UTC (rev 3668) @@ -232,6 +232,7 @@ pollen.error.user.restrictedListsForbidden=The poll is restricted and you are not allowed to vote. Check if you have correctly used the link sent to you by email. pollen.error.userNotAllowed=You are not allowed to count the votes for this poll. pollen.error.vote.invalidCondorcetVoteValue=Invalid position\: in a condorcet vote, you can let empty values, or put values greater than zero. +pollen.error.vote.invalidFormat=Vote value invalid (must be a integer number) pollen.error.vote.maxChoiceNb=The maximal number of choices is %d. pollen.error.vote.percentage=The sum of the values must be equals to 100. pollen.fieldset.choice.options=Choices Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-08-29 15:28:07 UTC (rev 3667) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-08-29 16:03:56 UTC (rev 3668) @@ -233,6 +233,7 @@ pollen.error.user.restrictedListsForbidden=Le sondage est restreint et vous n'êtes pas autorisé à voter. Vérifiez que vous avez bien utiliser le lien qui vous a été envoyé. pollen.error.userNotAllowed=Vous n'êtes pas autorisé à dépouiller ce sondage. pollen.error.vote.invalidCondorcetVoteValue=Position invalide \: dans un vote condorcet, vous pouvez soit laisser laisser vide un choix, soit mettre une valeur strictement positive. +pollen.error.vote.invalidFormat=Valeur de vote %s invalide (doit être un nombre entier) pollen.error.vote.maxChoiceNb=Le nombre de choix maximal est de %d. pollen.error.vote.percentage=La somme des valeurs doit être égale à 100. pollen.fieldset.choice.options=Les choix Modified: trunk/pollen-ui-struts2/src/main/resources/shiro.ini =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-08-29 15:28:07 UTC (rev 3667) +++ trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-08-29 16:03:56 UTC (rev 3668) @@ -65,6 +65,7 @@ /json/getPolls=connected,admin # is poll exists and user can vote to it +/poll/vote/**=pollVoteAccess /poll/votefor/**=pollVoteAccess /poll/VoteFor/**=pollVoteAccess /poll/addChoice/**=pollVoteAccess
participants (1)
-
tchemit@users.chorem.org