This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit 6cab4670047ef55b651ce8cf7c47d8c78a8e84ce Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 19 15:59:42 2014 +0200 check valid email for poll creator --- .../pollen/services/service/PollService.java | 4 ++ .../i18n/pollen-services_en_GB.properties | 1 + .../i18n/pollen-services_fr_FR.properties | 1 + .../src/main/webapp/js/controllers/pollCtrl.js | 52 +++++++++++++--------- .../src/main/webapp/partials/poll.html | 12 ++--- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index 8cd8baf..3159bc8 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -440,6 +440,10 @@ public class PollService extends PollenServiceSupport { } } + if (!poll.getCreatorEmail().isEmpty()) { + checkValidEmail(errors, Poll.PROPERTY_CREATOR+"."+PollenPrincipal.PROPERTY_EMAIL,poll.getCreatorEmail(), l(getLocale(), "pollen.error.poll.creator.email.invalid")); + } + return errors; } diff --git a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties index d308101..b67777a 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties @@ -34,6 +34,7 @@ pollen.error.favoriteListMember.name.empty=member name can not be empty pollen.error.poll.beginChoiceDate.afterEndDate=the begin date of adding choice is after the end of poll pollen.error.poll.choice.mandatory=At least a choice is mandatory pollen.error.poll.commentVisibility.mandatory=comment visiblity is mandatory +pollen.error.poll.creator.email.invalid=email is not valid pollen.error.poll.endChoiceDate.beforeBeginChoiceDate=The end date of adding choice is before the begin date pollen.error.poll.endDate.beforeBeginDate=The end date of vote is before the begin date pollen.error.poll.mismatch.freePoll=cant' have a voter list for a free poll diff --git a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties index 5d2c9c8..dc1adcb 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties @@ -34,6 +34,7 @@ pollen.error.favoriteListMember.name.empty=Le nom du membre est obligatoire pollen.error.poll.beginChoiceDate.afterEndDate=La date de début d'ajout de choix est après la date de fin du sondage pollen.error.poll.choice.mandatory=Au moins un choix est nécessaire pollen.error.poll.commentVisibility.mandatory=la visibilité des commentaires est obligatoire +pollen.error.poll.creator.email.invalid=Courriel est invalide pollen.error.poll.endChoiceDate.beforeBeginChoiceDate=La date de fin d'ajout de choix est avant la date de début pollen.error.poll.endDate.beforeBeginDate=La date de fin des votes est avant la date de début pollen.error.poll.pollType.mandatory=le type de sondage est obligatoire diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index 818e8a2..a40b281 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -653,8 +653,8 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr // Admin poll controller // ////////////////////////////////// -.controller('PollAdminCtrl', ['$scope', '$rootScope', '$controller', '$timeout', '$routeParams', 'Poll', - function ($scope, $rootScope, $controller, $timeout, $routeParams, Poll) { +.controller('PollAdminCtrl', ['$scope', '$rootScope', '$controller', '$timeout', '$routeParams', 'Poll', '$filter', + function ($scope, $rootScope, $controller, $timeout, $routeParams, Poll, $filter) { $controller('PollAdminChoiceCtrl', {$scope:$scope}); @@ -665,6 +665,28 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr $scope.globalVariables.editMode = true; $scope.restError = {}; + $scope.tabError = function (error) { + if (error.hasOwnProperty('title') || error.hasOwnProperty('choice')) { + $scope.globalVariables.pollError = $filter('translate')('error.form'); + } + + if (error.hasOwnProperty('creator.email') || + error.hasOwnProperty('endDate') || + error.hasOwnProperty('beginChoiceDate') || + error.hasOwnProperty('endChoiceDate') || + error.hasOwnProperty('commentVisibility') || + error.hasOwnProperty('resultVisibility') || + error.hasOwnProperty('voteVisibility') || + error.hasOwnProperty('voteCountingType')) { + + $scope.globalVariables.configError = $filter('translate')('error.form'); + } + + if (error.hasOwnProperty('pollType')) { + $scope.globalVariables.participantError = $filter('translate')('error.form'); + } + } + //////////////////////////////// //// VOTER LIST ///// //////////////////////////////// @@ -825,31 +847,14 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr $location.url('/poll/edit/'+data.id+'/'+data.permission); } }, function (error) { - console.log(error) - if (error.data.hasOwnProperty('title') || error.data.hasOwnProperty('choice')) { - $scope.globalVariables.pollError = true; - } - if (error.data.hasOwnProperty('endDate') || - error.data.hasOwnProperty('beginChoiceDate') || - error.data.hasOwnProperty('endChoiceDate') || - error.data.hasOwnProperty('commentVisibility') || - error.data.hasOwnProperty('resultVisibility') || - error.data.hasOwnProperty('voteVisibility') || - error.data.hasOwnProperty('voteCountingType')) { - - $scope.globalVariables.configError = true; - } - - if (error.data.hasOwnProperty('pollType')) { - $scope.globalVariables.participantError = true; - } + $scope.tabError(error.data); $scope.restError = error.data; angular.forEach($scope.data.choices, function (choice, index) { if (angular.isDefined(error.data['choice['+index+'].choiceValue'])) { choice.restError = {choiceValue:error.data['choice['+index+'].choiceValue']}; - $scope.globalVariables.pollError = true; + $scope.globalVariables.pollError = $filter('translate')('error.form'); } else { delete choice.restError; @@ -1160,8 +1165,13 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr } Poll.update({permission:$scope.globalVariables.pollToken}, savePoll, function () { + $scope.globalVariables.pollError = false; + $scope.globalVariables.configError = false; + $scope.globalVariables.participantError = false; + $rootScope.$broadcast('newSuccess', 'poll.saved'); }, function (error) { + $scope.tabError(error.data); angular.extend($scope.restError, error.data); }); } diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index 876170b..84b8645 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -24,13 +24,13 @@ <li ng-class="{active: tab == 'vote'}" ng-show="data.poll.id"><a href="{{globalVariables.linkVote}}" ng-click="tab = 'vote'"><span class="fa fa-thumbs-o-up fa-flip-horizontal"></span> {{ 'poll.tab.vote' | translate }}</a></li> <li ng-class="{active: tab == 'comment'}" ng-show="data.poll.commentIsVisible"><a href="{{globalVariables.linkComment}}" ng-click="tab = 'comment'"><span class="fa fa-comments-o"></span> {{ 'poll.tab.comment' | translate }}</a></li> <li ng-class="{active: tab == 'result'}" ng-show="data.poll.resultIsVisible"><a href="{{globalVariables.linkResult}}" ng-click="tab = 'result'"><span class="fa fa-bar-chart-o"></span> {{ 'poll.tab.result' | translate }}</a></li> - <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}" ng-click="tab = 'edit'"><span class="fa fa-pencil-square-o"></span> {{ 'poll.tab.edit' | translate }} <info-error error="'error.form'" ng-if="pollError"></info-error></a></li> - <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkConf}}" ng-click="tab = 'conf'"><span class="fa fa-wrench"></span> {{ 'poll.tab.conf' | translate }} <info-error error="'error.form'" ng-if="configError"></info-error></a></li> - <li ng-class="{active: tab == 'participant'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkParticipant}}" ng-click="tab = 'participant'"><span class="fa fa-users"></span> {{ 'poll.tab.participant' | translate }} <info-error error="'error.form'" ng-if="participantError"></info-error></a></li> + <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}" ng-click="tab = 'edit'"><span class="fa fa-pencil-square-o"></span> {{ 'poll.tab.edit' | translate }} <info-error error="globalVariables.pollError"></info-error></a></li> + <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkConf}}" ng-click="tab = 'conf'"><span class="fa fa-wrench"></span> {{ 'poll.tab.conf' | translate }} <info-error error="globalVariables.configError"></info-error></a></li> + <li ng-class="{active: tab == 'participant'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkParticipant}}" ng-click="tab = 'participant'"><span class="fa fa-users"></span> {{ 'poll.tab.participant' | translate }} <info-error error="globalVariables.participantError"></info-error></a></li> - <li ng-class="{active: tab == 'create'}" ng-show="globalVariables.create"><a href="#/poll/create" ng-click="tab = 'create'"><span class="fa fa-pencil-square-o"></span> {{ 'poll.tab.create' | translate }} <info-error error="'error.form'" ng-if="globalVariables.pollError"></info-error></a></li> - <li ng-class="{active: tab == 'conf'}" ng-show="globalVariables.create"><a href="#/poll/create/conf" ng-click="tab = 'conf'"><span class="fa fa-wrench"></span> {{ 'poll.tab.conf' | translate }} <info-error error="'error.form'" ng-if="globalVariables.configError"></info-error></a></li> - <li ng-class="{active: tab == 'participant'}" ng-show="globalVariables.create"><a href="#/poll/create/participant" ng-click="tab = 'participant'"><span class="fa fa-users"></span> {{ 'poll.tab.participant' | translate }} <info-error error="'error.form'" ng-if="globalVariables.participantError"></info-error></a></li> + <li ng-class="{active: tab == 'create'}" ng-show="globalVariables.create"><a href="#/poll/create" ng-click="tab = 'create'"><span class="fa fa-pencil-square-o"></span> {{ 'poll.tab.create' | translate }} <info-error error="globalVariables.pollError"></info-error></a></li> + <li ng-class="{active: tab == 'conf'}" ng-show="globalVariables.create"><a href="#/poll/create/conf" ng-click="tab = 'conf'"><span class="fa fa-wrench"></span> {{ 'poll.tab.conf' | translate }} <info-error error="globalVariables.configError"></info-error></a></li> + <li ng-class="{active: tab == 'participant'}" ng-show="globalVariables.create"><a href="#/poll/create/participant" ng-click="tab = 'participant'"><span class="fa fa-users"></span> {{ 'poll.tab.participant' | translate }} <info-error error="globalVariables.participantError"></info-error></a></li> </ul> <div ng-include="'./partials/poll-info.html'" ng-controller="PollInfoCtrl" class="poll-info"></div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.