Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
April 2012
- 5 participants
- 111 discussions
r3253 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 12 Apr '12
by fdesbois@users.chorem.org 12 Apr '12
12 Apr '12
Author: fdesbois
Date: 2012-04-12 18:27:37 +0200 (Thu, 12 Apr 2012)
New Revision: 3253
Url: http://chorem.org/repositories/revision/pollen/3253
Log:
validation for votingLists
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/webapp/WEB-INF/jsp/poll/displayPersonToList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayVotingList.jsp
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 16:27:32 UTC (rev 3252)
+++ 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:37 UTC (rev 3253)
@@ -29,6 +29,7 @@
import com.google.common.collect.Sets;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -226,15 +227,9 @@
@Override
public void validate() {
- informationsError = validateInformations();
+ validateInformations();
- optionsError = validateOptions();
-
- if (!informationsError && optionsError) {
-
- // trick to force to go back to form
- addFieldError("", "");
- }
+ validateOptions();
}
@Override
@@ -367,11 +362,12 @@
return result;
}
- protected boolean validateInformations() {
+ protected void validateInformations() {
// -- Title : required -- //
if (StringUtils.isBlank(poll.getTitle())) {
- addFieldError("poll.title", _("pollen.error.poll.required.title"));
+ addInformationsError("poll.title",
+ _("pollen.error.poll.required.title"));
}
if (isVoteStarted()) {
@@ -385,8 +381,8 @@
if (MapUtils.isEmpty(choices)) {
// poll must have at least one choice
- addFieldError("poll.choices",
- _("pollen.error.poll.required.one.choice"));
+ addInformationsError("poll.choices",
+ _("pollen.error.poll.required.one.choice"));
} else {
ChoiceType choiceType = poll.getChoiceType();
@@ -396,22 +392,16 @@
choiceType));
if (inputChoicesSize > choiceValues.size()) {
- addFieldError(
+ addInformationsError(
"poll.choices",
_("pollen.error.poll.detected.duplicate.choice.name"));
}
}
}
-
- boolean result = hasFieldErrors();
-
- return result;
}
- protected boolean validateOptions() {
+ protected void validateOptions() {
- boolean result = false;
-
if (isVoteStarted()) {
// no validation on votingLists if vote is started
@@ -431,56 +421,43 @@
Set<String> emails = Sets.newHashSet();
for (Map.Entry<Integer, VotingList> entry : votingLists.entrySet()) {
- result |= validateVotingList(entry.getKey(),
- entry.getValue(),
- groups,
- voters,
- emails);
+ validateVotingList(entry.getKey(),
+ entry.getValue(),
+ groups,
+ voters,
+ emails);
}
}
}
if (validateEndDate(poll.getBeginChoiceDate(), poll.getEndChoiceDate())) {
- addFieldError("poll.endChoiceDate",
+ addOptionsError("poll.endChoiceDate",
_("pollen.error.poll.endChoiceDate.before.beginChoiceDate"));
- result = true;
}
if (validateEndDate(poll.getBeginDate(), poll.getEndDate())) {
- addFieldError("poll.endDate",
+ addOptionsError("poll.endDate",
_("pollen.error.poll.endDate.before.beginDate"));
- result = true;
}
if (validateEndDate(poll.getEndChoiceDate(), poll.getEndDate())) {
- addFieldError("poll.endChoiceDate",
+ addOptionsError("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,
- Set<String> groups,
- Set<String> voters,
- Set<String> emails) {
+ protected void validateVotingList(int votingListNumber,
+ VotingList votingList,
+ Set<String> groups,
+ Set<String> voters,
+ Set<String> emails) {
+
+ PollType votingListType = poll.getPollType();
+ String fieldNamePrefix = "votingList" + votingListType + "_" + votingListNumber;
- boolean result = false;
- Map<String, String> errors = Maps.newHashMap();
-
- String votingListErrorPrefix = "poll.votingList_" + votingListNumber;
-
if (isGroupPoll()) {
// group poll
@@ -496,8 +473,9 @@
if (StringUtils.isEmpty(votingListName)) {
- errors.put(votingListErrorPrefix + ".name",
- _("pollen.error.poll.required.votingList.name"));
+ addOptionsError(
+ fieldNamePrefix + ".name",
+ _("pollen.error.poll.required.votingList.name"));
} else {
// check no votingList name doublon
@@ -505,8 +483,8 @@
if (!add) {
// name doublon
- errors.put(
- votingListErrorPrefix + ".name",
+ addOptionsError(
+ fieldNamePrefix + ".name",
_("pollen.error.poll.votingList.name.doublon"));
}
@@ -518,8 +496,8 @@
if (votingList.getWeight() == 0) {
// no weight filled (can be a bad conversion)
- errors.put(
- votingListErrorPrefix + ".weight",
+ addOptionsError(
+ fieldNamePrefix + ".weight",
_("pollen.error.poll.votingList.weight.not.valid"));
}
}
@@ -527,53 +505,38 @@
// check there is at least one voter
-// String persontoListToken = DisplayPersonToList.getPersonToListTokenId(
-// getVotingListTokenId(), votingListNumber);
-//
-// Map<Integer, PersonToList> personToLists =
-// getPollenSession().getDynamicData(persontoListToken);
-//
-// if (MapUtils.isEmpty(personToLists)) {
-//
-// // no personToList found for unique votingList 0
-// errors.put(votingListErrorPrefix,
-// _("pollen.error.poll.required.one.personToList"));
-// } else {
-//
-// // check no doublon on voter names
-// // check no doublon on voter emails
-//
-// for (Map.Entry<Integer, PersonToList> entry :
-// personToLists.entrySet()) {
-//
-// result |= validatePersonList(entry.getKey(), entry.getValue(),
-// voters, emails);
-// }
-// }
-//
-// if (MapUtils.isNotEmpty(errors)) {
-//
-// // keep errors to display them in correct action
-// String errorToken = DisplayVotingList.getVotingListErrorTokenId(
-// getVotingListTokenId(), votingListNumber);
-// if (log.isInfoEnabled()) {
-// log.info("Add " + errors.size() + " errors to " + errorToken);
-// }
-// getPollenSession().putDynamicData(errorToken, errors);
-// result = true;
-// }
- return result;
+ List<PersonToList> personToLists = votingList.getPollAccountPersonToList();
+
+ if (CollectionUtils.isEmpty(personToLists)) {
+
+ // no personToList found for unique votingList 0
+ addOptionsError(fieldNamePrefix,
+ _("pollen.error.poll.required.one.personToList"));
+ } else {
+
+ // check no doublon on voter names
+ // check no doublon on voter emails
+
+ for (int i = 0; i < personToLists.size(); i++) {
+
+ validatePersonList(i,
+ fieldNamePrefix,
+ personToLists.get(i),
+ voters,
+ emails);
+ }
+ }
}
- protected boolean validatePersonList(int personToListNumber,
- PersonToList personToList,
- Set<String> voters,
- Set<String> emails) {
+ protected void validatePersonList(int personToListNumber,
+ String votingListFieldNamePrefix,
+ PersonToList personToList,
+ Set<String> voters,
+ Set<String> emails) {
- boolean result = false;
- Map<String, String> errors = Maps.newHashMap();
- String fieldNamePrefix =
- "personToList_0_" + personToListNumber;
+ String fieldNamePrefix = votingListFieldNamePrefix +
+ "PersonToList_" + personToListNumber;
+
PollAccount pollAccount = personToList.getPollAccount();
{ // validate votingId
@@ -584,7 +547,7 @@
if (!add) {
// voter doublon
- errors.put(
+ addOptionsError(
fieldNamePrefix + ".votingId",
_("pollen.error.poll.personToList.votingId.doublon"));
}
@@ -593,7 +556,7 @@
String email = pollAccount.getEmail();
if (StringUtils.isEmpty(email)) {
- errors.put(
+ addOptionsError(
fieldNamePrefix + ".email",
_("pollen.error.poll.personToList.email.required"));
} else {
@@ -603,7 +566,7 @@
if (!validEmail) {
// not a valid email
- errors.put(
+ addOptionsError(
fieldNamePrefix + ".email",
_("pollen.error.poll.personToList.email.not.valid"));
} else {
@@ -613,7 +576,7 @@
if (!add) {
// email doublon
- errors.put(
+ addOptionsError(
fieldNamePrefix + ".email",
_("pollen.error.poll.personToList.email.doublon"));
}
@@ -624,25 +587,37 @@
if (personToList.getWeight() == 0) {
// no weight filled (can be a bad conversion)
- errors.put(
+ addOptionsError(
fieldNamePrefix + ".weight",
_("pollen.error.poll.personToList.weight.not.valid"));
}
}
+ }
- if (MapUtils.isNotEmpty(errors)) {
-// String errorToken =
-// DisplayPersonToList.getPersonToListErrorTokenId(
-// getVotingListTokenId(), 0, personToListNumber);
-// if (log.isInfoEnabled()) {
-// log.info("Add " + errors.size() + " errors to " + errorToken);
-// }
-// getPollenSession().putDynamicData(errorToken, errors);
- result = true;
+ protected boolean validateEndDate(Date begin, Date end) {
+ return begin != null
+ && end != null
+ && end.before(begin);
+ }
+
+ @Override
+ public void addFieldError(String fieldName, String errorMessage) {
+ super.addFieldError(fieldName, errorMessage);
+ if (log.isDebugEnabled()) {
+ log.debug("VALIDATION [" + fieldName + "] : " + errorMessage);
}
- return result;
}
+ protected void addInformationsError(String fieldName, String errorMessage) {
+ addFieldError(fieldName, errorMessage);
+ informationsError = true;
+ }
+
+ protected void addOptionsError(String fieldName, String errorMessage) {
+ addFieldError(fieldName, errorMessage);
+ optionsError = true;
+ }
+
protected Map<Integer, Choice> buildTextChoices() {
Map<Integer, Choice> result = Maps.newTreeMap();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayPersonToList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayPersonToList.jsp 2012-04-12 16:27:32 UTC (rev 3252)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayPersonToList.jsp 2012-04-12 16:27:37 UTC (rev 3253)
@@ -32,7 +32,6 @@
<s:text name="pollen.action.pollPersonToListDelete"/>
</s:set>
<s:div id='%{#personPrefix}' cssClass="personToList">
- <s:fielderror/>
<s:hidden key='%{#personPrefix}.topiaId' value='%{#personToList.topiaId}' label=''/>
<s:hidden key='%{#personPrefix}.accountId' value='%{#personToList.pollAccount.accountId}' label=''/>
<div class="fleft choiceName">
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayVotingList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayVotingList.jsp 2012-04-12 16:27:32 UTC (rev 3252)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayVotingList.jsp 2012-04-12 16:27:37 UTC (rev 3253)
@@ -36,7 +36,7 @@
<s:div id='%{#prefix}' cssClass="votingList">
<fieldset class="ui-widget-content ui-corner-all">
- <s:fielderror/>
+ <s:fielderror fieldName="%{#prefix}"/>
<s:if test='%{#votingListType == "GROUP"}'>
<%--<div>--%>
<div class="fleft choiceName">
1
0
r3252 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll resources/i18n
by fdesbois@users.chorem.org 12 Apr '12
by fdesbois@users.chorem.org 12 Apr '12
12 Apr '12
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
1
0
r3251 - in branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services: . impl
by fdesbois@users.chorem.org 12 Apr '12
by fdesbois@users.chorem.org 12 Apr '12
12 Apr '12
Author: fdesbois
Date: 2012-04-12 12:32:25 +0200 (Thu, 12 Apr 2012)
New Revision: 3251
Url: http://chorem.org/repositories/revision/pollen/3251
Log:
send email to person on restricted poll update (if email change)
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-04-12 10:32:21 UTC (rev 3250)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenServiceSupport.java 2012-04-12 10:32:25 UTC (rev 3251)
@@ -118,6 +118,14 @@
}
}
+ protected <T extends TopiaEntity, D extends TopiaDAO<? super T>> T update(D dao, T entity) {
+ try {
+ return (T) dao.update(entity);
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Could not update entity ", e);
+ }
+ }
+
protected TopiaContext getTransaction() {
return serviceContext.getTransaction();
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-04-12 10:32:21 UTC (rev 3250)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-04-12 10:32:25 UTC (rev 3251)
@@ -113,7 +113,6 @@
String pollTitle = poll.getTitle();
// Mail au créateur
-
if (StringUtils.isNotEmpty(poll.getCreator().getEmail())) {
String subject = l_(locale, "pollen.email.creatorEmail.subject",
pollTitle);
@@ -135,16 +134,10 @@
List<PollEmail> emails = Lists.newArrayList();
for (PollAccount account : votingPollAccounts) {
- String accountId = account.getAccountId();
- PollUrl accountVoteURL = PollUrl.newPollUrl(voteURL, accountId);
- String content =
- l_(locale, "pollen.email.votingEmail.content",
- pollTitle, accountId, accountVoteURL);
+ PollEmail pollEmail =
+ createVotingEmail(locale, pollTitle, account, voteURL);
- PollEmail pollEmail = createPollEmail(
- account.getEmail(), subject, content);
-
emails.add(pollEmail);
}
@@ -152,7 +145,45 @@
}
}
}
+
+ public void onRestrictedPersonAdded(Poll poll, PollAccount account, PollUrl voteURL) {
+ URL url = serviceContext.getApplicationURL();
+
+ if (url != null) {
+
+ Locale locale = getLocale();
+
+ String pollTitle = poll.getTitle();
+
+ PollEmail pollEmail =
+ createVotingEmail(locale, pollTitle, account, voteURL);
+
+ sendEmail(pollEmail);
+ }
+ }
+
+ private PollEmail createVotingEmail(Locale locale,
+ String pollTitle,
+ PollAccount account,
+ PollUrl voteURL) {
+
+ String subject = l_(locale, "pollen.email.votingEmail.subject",
+ pollTitle);
+
+ PollUrl accountVoteURL =
+ PollUrl.newPollUrl(voteURL, account.getAccountId());
+
+ String content =
+ l_(locale, "pollen.email.votingEmail.content",
+ pollTitle, account.getVotingId(), accountVoteURL);
+
+ PollEmail result = createPollEmail(
+ account.getEmail(), subject, content);
+
+ return result;
+ }
+
public void onPollReminder(Poll poll, PollUrl voteURL) {
URL url = serviceContext.getApplicationURL();
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-12 10:32:21 UTC (rev 3250)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-12 10:32:25 UTC (rev 3251)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.services.impl;
+import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import org.apache.commons.io.FileUtils;
@@ -291,7 +292,9 @@
// -- VotingList -- //
try {
for (VotingList votingList : poll.getVotingList()) {
- saveVotingList(result, votingList);
+ // Do not set emailService, all emails will be send during
+ // onPollCreated
+ saveVotingList(result, votingList, null);
}
} catch (TopiaException e) {
throw new PollenTechnicalException("Can't save votingLists", e);
@@ -353,10 +356,11 @@
// -- VotingLists -- //
if (!voteStarted) {
+ EmailService emailService = newService(EmailService.class);
pollToUpdate.clearVotingList();
try {
for (VotingList votingList : poll.getVotingList()) {
- saveVotingList(pollToUpdate, votingList);
+ saveVotingList(pollToUpdate, votingList, emailService);
}
} catch (TopiaException e) {
throw new PollenTechnicalException("Can't save votingLists", e);
@@ -926,7 +930,7 @@
return result;
}
- protected void saveVotingList(Poll poll, VotingList votingList) throws TopiaException {
+ protected void saveVotingList(Poll poll, VotingList votingList, EmailService emailService) throws TopiaException {
VotingListDAO votingListDAO = getDAO(VotingList.class);
PersonToListDAO personToListDAO = getDAO(PersonToList.class);
@@ -947,6 +951,8 @@
result.setName(votingList.getName());
result.setWeight(votingList.getWeight());
+
+ PollUrl voteURL = getPollVoteUrl(poll);
// Merge PersonToList
List<PersonToList> personToListsUpdated = Lists.newArrayList();
@@ -974,7 +980,6 @@
pollAccountLoaded = create(pollAccountDAO);
pollAccountLoaded.setAccountId(accountId);
}
- personToListLoaded.setPollAccount(pollAccountLoaded);
} else {
personToListLoaded = getEntityById(PersonToList.class, personToList.getTopiaId());
@@ -983,8 +988,22 @@
personToListsUpdated.add(personToListLoaded);
personToListLoaded.setWeight(personToList.getWeight());
+ pollAccountLoaded.setVotingId(pollAccount.getVotingId());
+
+ boolean emailChanged = !Objects.equal(pollAccountLoaded.getEmail(),
+ pollAccount.getEmail());
+
pollAccountLoaded.setEmail(pollAccount.getEmail());
- pollAccountLoaded.setVotingId(pollAccount.getVotingId());
+
+ // Send email to the person if service is defined and email has changed
+ if (emailService != null && emailChanged) {
+ emailService.onRestrictedPersonAdded(poll, pollAccountLoaded, voteURL);
+ }
+
+ // Update the account (otherwise a saving error will occurs if
+ // already exists on delete cascade)
+ PollAccount pollAccountUpdated = update(pollAccountDAO, pollAccountLoaded);
+ personToListLoaded.setPollAccount(pollAccountUpdated);
}
result.setPollAccountPersonToList(personToListsUpdated);
}
1
0
r3250 - in branches/pollen-1.2.6-struts2: pollen-services/src/main/java/org/chorem/pollen/bean pollen-services/src/main/java/org/chorem/pollen/services pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by fdesbois@users.chorem.org 12 Apr '12
by fdesbois@users.chorem.org 12 Apr '12
12 Apr '12
Author: fdesbois
Date: 2012-04-12 12:32:21 +0200 (Thu, 12 Apr 2012)
New Revision: 3250
Url: http://chorem.org/repositories/revision/pollen/3250
Log:
- create new object PollUrl that use PollUri to avoid floating String for email urls
- missing reset for limitChoice
- ensure keeping existing account on update poll for restricted votingLists
Added:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUrl.java
Modified:
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
Added: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUrl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUrl.java (rev 0)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUrl.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -0,0 +1,63 @@
+package org.chorem.pollen.bean;
+
+/**
+ * Created: 12/04/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class PollUrl {
+
+ private String baseUrl;
+
+ private PollUri pollUri;
+
+ /**
+ * Create a new PollUrl with {@code baseUrl} which is the application url
+ * for this url, and the {@code pollUri} to identify the poll.
+ *
+ * @param baseUrl Base url from the application for this url
+ * @param pollUri Uri that identify the poll and the account
+ * @return a new PollUrl
+ */
+ public static PollUrl newPollUrl(String baseUrl, PollUri pollUri) {
+ PollUrl result = new PollUrl();
+ result.baseUrl = baseUrl;
+ result.pollUri = pollUri;
+ return result;
+ }
+
+ /**
+ * Create a new PollUrl which is a copy of the given {@code pollUrl} with
+ * an other {@code accountId} for {@link PollUri}.
+ *
+ * @param pollUrl PollUrl to copy
+ * @param accountId New accountId to use for copy
+ * @return the new PollUrl
+ */
+ public static PollUrl newPollUrl(PollUrl pollUrl, String accountId) {
+ PollUrl result = new PollUrl();
+ result.baseUrl = pollUrl.getBaseUrl();
+ String pollId = pollUrl.getPollUri().getPollId();
+ result.pollUri = PollUri.newPollUri(pollId, accountId);
+ return result;
+ }
+
+ private PollUrl() { }
+
+ public String getBaseUrl() {
+ return baseUrl;
+ }
+
+ public PollUri getPollUri() {
+ return pollUri;
+ }
+
+ public String getUrl() {
+ return getBaseUrl() + getPollUri().getUri();
+ }
+
+ @Override
+ public String toString() {
+ return getUrl();
+ }
+}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/PollenNotifierWorker.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -25,6 +25,7 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.services.impl.PollService;
@@ -89,7 +90,7 @@
for (Poll poll : polls) {
- String pollVoteUrl = pollService.getPollVoteUrl(poll);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll);
preventRuleService.onPollToRemind(poll, pollVoteUrl);
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -33,10 +33,10 @@
import org.apache.commons.mail.SimpleEmail;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceSupport;
import org.nuiton.util.StringUtil;
@@ -72,7 +72,7 @@
}
}
- public void onVoteAdded(Poll poll, String voteURL, String modifURL) {
+ public void onVoteAdded(Poll poll, PollUrl voteURL, PollUrl modifURL) {
URL url = serviceContext.getApplicationURL();
@@ -102,7 +102,7 @@
}
}
- public void onPollCreated(Poll poll, String voteURL, String modifURL) {
+ public void onPollCreated(Poll poll, PollUrl voteURL, PollUrl modifURL) {
URL url = serviceContext.getApplicationURL();
@@ -115,14 +115,10 @@
// Mail au créateur
if (StringUtils.isNotEmpty(poll.getCreator().getEmail())) {
- String voteURL2 = voteURL;
- if (poll.getPollType() != PollType.FREE) {
- voteURL2 += ":" + poll.getCreator().getAccountId();
- }
String subject = l_(locale, "pollen.email.creatorEmail.subject",
pollTitle);
String content = l_(locale, "pollen.email.creatorEmail.content",
- pollTitle, voteURL2, modifURL);
+ pollTitle, voteURL, modifURL);
PollEmail pollEmail = createPollEmail(
poll.getCreator().getEmail(), subject, content);
@@ -140,8 +136,7 @@
List<PollEmail> emails = Lists.newArrayList();
for (PollAccount account : votingPollAccounts) {
String accountId = account.getAccountId();
- String accountVoteURL =
- voteURL + ":" + accountId;
+ PollUrl accountVoteURL = PollUrl.newPollUrl(voteURL, accountId);
String content =
l_(locale, "pollen.email.votingEmail.content",
@@ -158,7 +153,7 @@
}
}
- public void onPollReminder(Poll poll, String voteURL) {
+ public void onPollReminder(Poll poll, PollUrl voteURL) {
URL url = serviceContext.getApplicationURL();
@@ -177,8 +172,8 @@
List<PollEmail> emails = Lists.newArrayList();
for (PollAccount account : votingPollAccounts) {
- String accountVoteURL =
- voteURL + ":" + account.getAccountId();
+ PollUrl accountVoteURL =
+ PollUrl.newPollUrl(voteURL, account.getAccountId());
String content =
l_(locale, "pollen.email.reminderEmail.content",
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollCommentService.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -25,6 +25,7 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.CommentDAO;
import org.chorem.pollen.business.persistence.Poll;
@@ -91,7 +92,7 @@
PollService pollService = newService(PollService.class);
- String pollVoteUrl = pollService.getPollVoteUrl(poll);
+ PollUrl pollVoteUrl = pollService.getPollVoteUrl(poll);
PollFeedService pollFeedService = newService(PollFeedService.class);
pollFeedService.onAddComment(commentCreated, pollVoteUrl);
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -36,6 +36,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenTechnicalException;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.Comment;
import org.chorem.pollen.business.persistence.Poll;
@@ -81,7 +82,7 @@
return result;
}
- public void onPollCreated(Poll poll, String pollVoteUrl) {
+ public void onPollCreated(Poll poll, PollUrl pollVoteUrl) {
File file = getFeedLocation(poll);
String title = l_(getLocale(), "pollen.feed.pollTitle", poll.getTitle());
@@ -91,7 +92,7 @@
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle(title);
- feed.setLink(pollVoteUrl);
+ feed.setLink(pollVoteUrl.getUrl());
feed.setDescription(description);
Writer writer = new FileWriter(file);
@@ -115,7 +116,7 @@
}
}
- public void onAddComment(Comment comment, String pollVoteUrl) {
+ public void onAddComment(Comment comment, PollUrl pollVoteUrl) {
String title = _("pollen.feed.addCommentTitle",
comment.getAuthor());
@@ -128,8 +129,8 @@
public void onAddVote(Vote vote,
boolean anonymousVote,
- String pollResult
- , String pollVoteUrl) {
+ String pollResult,
+ PollUrl pollVoteUrl) {
String userId;
if (anonymousVote) {
@@ -145,7 +146,7 @@
addFeedEntry(vote.getPoll(), title, content, pollVoteUrl);
}
- public void onAddChoice(Choice choice, String pollVoteUrl) {
+ public void onAddChoice(Choice choice, PollUrl pollVoteUrl) {
String title = _("pollen.feed.addChoiceTitle", choice.getName());
@@ -185,7 +186,7 @@
protected void addFeedEntry(Poll poll,
String title,
String content,
- String pollVoteUrl) {
+ PollUrl pollVoteUrl) {
//TODO tchemitshould remove this, may migrates when going to version 2.0
//TODO pass on all polls from database and creates the feed if not found.
@@ -205,7 +206,7 @@
SyndContent description;
entry = new SyndEntryImpl();
entry.setTitle(title);
- entry.setLink(pollVoteUrl);
+ entry.setLink(pollVoteUrl.getUrl());
entry.setPublishedDate(new Date());
description = new SyndContentImpl();
description.setType("text/plain");
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -34,6 +34,7 @@
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Choice;
import org.chorem.pollen.business.persistence.ChoiceDAO;
import org.chorem.pollen.business.persistence.PersonToList;
@@ -241,10 +242,13 @@
Poll result = create(pollDAO);
// check max number choice authorized (can not be more than
- if (poll.getMaxChoiceNb() < 1
- || poll.getMaxChoiceNb() > poll.sizeChoice()) {
- poll.setMaxChoiceNb(poll.sizeChoice());
- }
+ // XXX-fdesbois-2012-04-11 : don't know why the maxNbChoice must be
+ // forced to the choice size, it seems useless. The case maxNbChoice = 0
+ // must be available (equivalent to undefined)
+// if (poll.getMaxChoiceNb() < 1
+// || poll.getMaxChoiceNb() > poll.sizeChoice()) {
+// poll.setMaxChoiceNb(poll.sizeChoice());
+// }
result.setAnonymous(poll.isAnonymous());
result.setAnonymousVoteAllowed(poll.isAnonymousVoteAllowed());
@@ -285,20 +289,26 @@
}
// -- VotingList -- //
- for (VotingList votingList : poll.getVotingList()) {
- saveVotingList(result, votingList);
+ try {
+ for (VotingList votingList : poll.getVotingList()) {
+ saveVotingList(result, votingList);
+ }
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Can't save votingLists", e);
}
commitTransaction("Could not create poll " + poll.getTitle());
- String pollVoteUrl = getPollVoteUrl(poll);
- String pollEditUrl = getPollEditUrl(poll);
+ PollUrl pollVoteUrl = getPollVoteUrl(poll);
+ PollUrl pollEditUrl = getPollEditUrl(poll);
// email notification
EmailService emailService = newService(EmailService.class);
emailService.onPollCreated(result, pollVoteUrl, pollEditUrl);
// feed notification
+ // XXX-fdesbois-2012-04-12 : if the feed is the same for everybody maybe
+ // not publish restricted poll that can't be accessed by everybody
PollFeedService pollFeedService = newService(PollFeedService.class);
pollFeedService.onPollCreated(result, pollVoteUrl);
@@ -344,35 +354,41 @@
if (!voteStarted) {
pollToUpdate.clearVotingList();
- for (VotingList votingList : poll.getVotingList()) {
- saveVotingList(pollToUpdate, votingList);
+ try {
+ for (VotingList votingList : poll.getVotingList()) {
+ saveVotingList(pollToUpdate, votingList);
+ }
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException("Can't save votingLists", e);
}
}
commitTransaction("Could not update poll [" + poll.getTopiaId() + "]");
}
- public String getPollVoteUrl(Poll poll) {
+ public PollUrl getPollVoteUrl(Poll poll) {
URL applicationUrl = serviceContext.getApplicationURL();
- StringBuilder url = new StringBuilder(applicationUrl.toString());
- url.append("/poll/votefor/");
-
- if (PollType.FREE == poll.getPollType()) {
- url.append(poll.getPollId());
-
- } else {
- // Restricted poll is secure, the creator could access to it when
- // using the adminId
- url.append(poll.getAdminId());
+ String baseUrl = applicationUrl + "/poll/votefor/";
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId());
+
+ if (poll.getPollType() != PollType.FREE) {
+ String creatorId = poll.getCreator().getAccountId();
+ pollUri.setAccountId(creatorId);
}
- return url.toString();
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
}
- public String getPollEditUrl(Poll poll) {
+ public PollUrl getPollEditUrl(Poll poll) {
URL applicationUrl = serviceContext.getApplicationURL();
- StringBuilder url = new StringBuilder(applicationUrl.toString());
- url.append("/poll/modification/").append(poll.getAdminId());
- return url.toString();
+ String baseUrl = applicationUrl + "/poll/modification/";
+
+ String creatorId = poll.getCreator().getAccountId();
+ PollUri pollUri = PollUri.newPollUri(poll.getPollId(), creatorId);
+
+ PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
+ return result;
}
public List<Poll> getPolls(TopiaFilterPagerUtil.FilterPagerBean pager) {
@@ -889,8 +905,8 @@
// Send notification if necessary
PreventRuleService preventRuleService = newService(PreventRuleService.class);
- String pollVoteUrl = getPollVoteUrl(pollToUpdate);
- String modifUrl = getPollEditUrl(pollToUpdate);
+ PollUrl pollVoteUrl = getPollVoteUrl(pollToUpdate);
+ PollUrl modifUrl = getPollEditUrl(pollToUpdate);
preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
}
@@ -910,7 +926,7 @@
return result;
}
- protected void saveVotingList(Poll poll, VotingList votingList) {
+ protected void saveVotingList(Poll poll, VotingList votingList) throws TopiaException {
VotingListDAO votingListDAO = getDAO(VotingList.class);
PersonToListDAO personToListDAO = getDAO(PersonToList.class);
@@ -946,9 +962,18 @@
// The model doesn't have any composition for this relation,
// the link must be set in both objects
personToListLoaded.setVotingList(result);
-
- pollAccountLoaded = create(pollAccountDAO);
- pollAccountLoaded.setAccountId(pollAccount.getAccountId());
+
+ // FIXME-fdesbois-2012-04-12 : find a better way to ensure accountId
+ String accountId = pollAccount.getAccountId();
+ if (accountId == null) {
+ accountId = serviceContext.createPollenUrlId();
+ }
+
+ pollAccountLoaded = pollAccountDAO.findByAccountId(accountId);
+ if (pollAccountLoaded == null) {
+ pollAccountLoaded = create(pollAccountDAO);
+ pollAccountLoaded.setAccountId(accountId);
+ }
personToListLoaded.setPollAccount(pollAccountLoaded);
} else {
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.bean.PollUrl;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.services.PollenServiceSupport;
@@ -63,7 +64,7 @@
return rule;
}
- public void onVoteAdded(Poll poll, String pollVoteUrl, String modifURL) {
+ public void onVoteAdded(Poll poll, PollUrl pollVoteUrl, PollUrl modifURL) {
if (poll.getEndDate() != null) {
@@ -77,7 +78,7 @@
}
}
- public void onPollToRemind(Poll poll, String pollVoteUrl) {
+ public void onPollToRemind(Poll poll, PollUrl pollVoteUrl) {
// Parcours des preventRules de chaque sondage
// envoi d'un email si endDate-nowDate <= preventRuleSensibility
@@ -109,8 +110,8 @@
protected void onVoteAdded(Poll poll,
PreventRule preventRule,
- String pollVoteUrl,
- String modifURL) {
+ PollUrl pollVoteUrl,
+ PollUrl modifURL) {
// send to creator a email to say hey a new vote was added!
@@ -130,7 +131,7 @@
protected void onPollToRemind(Poll poll,
PreventRule preventRule,
- String pollVoteUrl,
+ PollUrl pollVoteUrl,
int timeValue) {
// send to all voting a email to say hey we need to vote
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -203,11 +203,11 @@
}
public String getPollVoteUrl() {
- return getPollService().getPollVoteUrl(poll);
+ return getPollService().getPollVoteUrl(poll).getUrl();
}
public String getPollEditUrl() {
- return getPollService().getPollEditUrl(poll);
+ return getPollService().getPollEditUrl(poll).getUrl();
}
public int getSelectedTab() {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-04-12 07:54:38 UTC (rev 3249)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-04-12 10:32:21 UTC (rev 3250)
@@ -85,6 +85,8 @@
private PollAccount pollAccount;
private boolean alreadyVoted;
+
+ private boolean voteAllowed;
private List<Vote> votes;
@@ -285,8 +287,10 @@
// TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
votes = poll.getVote();
+ voteAllowed = getVoteService().isVoteAllowed(poll, pollAccount);
+
// Current vote
- if (isVoteAllowed()) {
+ if (voteAllowed) {
vote = getVoteService().getVoteEditable(poll, pollAccount);
}
@@ -370,7 +374,7 @@
}
public boolean isVoteAllowed() {
- return getVoteService().isVoteAllowed(getPoll(), getPollAccount());
+ return voteAllowed;
}
public boolean isDeleteCommentAllowed(Comment comment) {
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 07:54:38 UTC (rev 3249)
+++ 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:21 UTC (rev 3250)
@@ -263,6 +263,11 @@
}
}
}
+
+ // Reset maxChoiceNb if limitChoice is unchecked
+ if (!isLimitChoice()) {
+ poll.setMaxChoiceNb(0);
+ }
poll.clearPreventRule();
1
0
r3249 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp: WEB-INF/jsp/poll js
by tchemit@users.chorem.org 12 Apr '12
by tchemit@users.chorem.org 12 Apr '12
12 Apr '12
Author: tchemit
Date: 2012-04-12 09:54:38 +0200 (Thu, 12 Apr 2012)
New Revision: 3249
Url: http://chorem.org/repositories/revision/pollen/3249
Log:
import group from voting list
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToAddToVotingList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToCreateNewVotingList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-04-12 06:54:09 UTC (rev 3248)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-04-12 07:54:38 UTC (rev 3249)
@@ -41,6 +41,7 @@
displayVotingListUrl:'<s:url namespace="/poll" action="displayVotingList"/>',
displayPersonToListUrl:'<s:url namespace="/poll" action="displayPersonToList"/>',
importPersonListToVotingListUrl:'<s:url namespace="/poll" action="importPersonListToVotingList"/>',
+ importPersonListToNewVotingListUrl:'<s:url namespace="/poll" action="importPersonListToNewVotingList"/>',
displayImageChoiceUrl:'<s:url namespace="/poll" action="displayImageChoice"/>',
displayDateChoiceUrl:'<s:url namespace="/poll" action="displayDateChoice"/>',
displayTextChoiceUrl:'<s:url namespace="/poll" action="displayTextChoice"/>',
@@ -211,7 +212,7 @@
<s:if test="userLoggued">
<s:submit key="pollen.action.addVotingListFromPersonList"
theme="simple"
- onclick="return selectPersonListToCreateNewVotingList();"
+ onclick='return selectPersonListToCreateNewVotingList();'
disabled="%{voteStarted}"/>
</s:if>
</div>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToAddToVotingList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToAddToVotingList.jsp 2012-04-12 06:54:09 UTC (rev 3248)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToAddToVotingList.jsp 2012-04-12 07:54:38 UTC (rev 3249)
@@ -47,7 +47,7 @@
<s:submit onclick="return cancel();" theme="simple"
key="pollen.action.cancel"/>
<s:submit
- onclick="return addPersonListToVotingList('%{votingListType}', '%{containerId}', '%{votingListNumber}', cancel);"
+ onclick="return addPersonListToVotingList('%{votingListType}', '%{containerId}', '%{votingListNumber}',$('#personList').val(), cancel);"
theme="simple" disabled='true' id='add'
key="pollen.action.importPersonListToExistingVotingList"/>
</div>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToCreateNewVotingList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToCreateNewVotingList.jsp 2012-04-12 06:54:09 UTC (rev 3248)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/selectPersonListToCreateNewVotingList.jsp 2012-04-12 07:54:38 UTC (rev 3249)
@@ -31,22 +31,6 @@
return false;
}
- function importPersonListToNewVotingList(personListId) {
- // add a new votingList
- addNewVotingList();
- // get his number
- var votingListNumber = getLastVotingList("votingLists");
-
- var containerId = "personToList_" + votingListNumber;
- // remove all personToList of this votingList
- var numbers = getAllPersonToListNumbers(containerId);
- for (n in numbers) {
- deletePersonToList(containerId + "_" + n);
- }
- // add personList to this votingList at position 0
- loadPersonListToVotingList(votingListNumber, 0, personListId);
- return cancel();
- }
jQuery(document).ready(function () {
$('#personList').change(function (event) {
var val = $(this).val();
@@ -59,15 +43,12 @@
<s:select id="personList" listValue="value.name" list="personList"
key='pollen.common.personList' headerKey="" headerValue=""/>
- <s:hidden key="votingListType" label=""/>
- <s:hidden key="votingListNumber" label=""/>
-
<hr/>
<div align="right">
<s:submit onclick="return cancel();" theme="simple"
key="pollen.action.cancel"/>
<s:submit id='import' disabled="true" theme="simple"
- onclick="return importPersonListToNewVotingList($('#personList').val());"
+ onclick="return importPersonListToNewVotingList($('#personList').val(), cancel);"
key="pollen.action.importPersonListToNewVotingList"/>
</div>
</fieldset>
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-04-12 06:54:09 UTC (rev 3248)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-04-12 07:54:38 UTC (rev 3249)
@@ -49,17 +49,6 @@
//-- Voting List methods
//----------------------------------------------------------------------------
-/*function getFirstVotingList(containerId) {
- var result = 65535;
- getAllVotingLists(containerId).each(function () {
- var current = $(this).data('votingListNumber');
- if (current < result) {
- result = current;
- }
- });
- return result;
- }*/
-
function getLastVotingList(containerId) {
var result = 0;
getAllVotingLists(containerId).each(function () {
@@ -84,12 +73,22 @@
votingList.data('votingListNumber', index);
votingList.data('votingListContainerId', containerId);
- preparePersonToLists(index, votingListId + 'PersonToList');
+ preparePersonToLists(votingListId + 'PersonToList', index);
});
updateUpdownVotingListActions(containerId);
}
+function prepareVotingList(containerId, votingListNumber) {
+
+ var votingListId = containerId + "_" + votingListNumber;
+ var votingList = $("#" + votingListId);
+ votingList.data('votingListNumber', votingListNumber);
+ votingList.data('votingListContainerId', containerId);
+ preparePersonToLists(votingListId + 'PersonToList', votingListNumber);
+ updateUpdownVotingListActions(containerId);
+}
+
function updateUpdownVotingListActions(containerId) {
getAllVotingLists(containerId).each(function (index) {
var currentVotingListNumber = $(this).data('votingListNumber');
@@ -114,18 +113,41 @@
success:function (data) {
var container = $("#" + containerId);
container.append(data);
- // store votingListNumber
- var votingListId = containerId + "_" + votingListNumber;
- var votingList = $("#" + votingListId);
- votingList.data('votingListNumber', votingListNumber);
- votingList.data('votingListContainerId', containerId);
- preparePersonToLists(votingListNumber, votingListId + 'PersonToList');
- updateUpdownVotingListActions(containerId);
+ // store votingListNumber and updates personToLists
+ prepareVotingList(containerId, votingListNumber);
}
});
return false;
}
+function importPersonListToNewVotingList(personListId, cancelCallBack) {
+
+ var containerId = 'votingListGROUP';
+
+ // get new voting list number
+ var votingListNumber = 1 + getLastVotingList(containerId);
+
+ $.ajax(
+ {
+ url:datas['importPersonListToNewVotingListUrl'],
+ data:{
+ votingListType:"GROUP",
+ votingListNumber:votingListNumber,
+ personListId:personListId
+ },
+ async:false,
+ dataType:"html",
+ success:function (data) {
+ console.info("My fucking containerId : " + containerId);
+ var container = $("#" + containerId);
+ container.append(data);
+ prepareVotingList(containerId, votingListNumber);
+ }
+ }
+ );
+ return cancelCallBack();
+}
+
function deleteVotingList(votingListId) {
var votingList = $('#' + votingListId);
var containerId = votingList.data('votingListContainerId');
@@ -139,17 +161,6 @@
//-- PersonToList methods
//----------------------------------------------------------------------------
-/*function getFirstPersonToList(containerId) {
- var result = 65535;
- getAllPersonToLists(containerId).each(function () {
- var current = $(this).data('personToListNumber');
- if (current < result) {
- result = current;
- }
- });
- return result;
- }*/
-
function getLastPersonToList(containerId) {
var result = 0;
getAllPersonToLists(containerId).each(function () {
@@ -177,7 +188,7 @@
function getFirstEmptyPersonToList(containerId) {
var result = -1;
var numbers = getAllPersonToListNumbers(containerId);
- $.each(numbers, function (index) {
+ $.each(numbers, function () {
var n = $(this)[0];
if (result == -1) {
var nameInput = $('[name="' + containerId + '_' + n + '.votingId"]');
@@ -190,40 +201,30 @@
}
}
});
- console.info("getFirstEmptyPersonToList = "+result);
return result;
}
-function preparePersonToLists(votingListNumber, containerId) {
- getAllPersonToLists(containerId).each(function (index) {
+function preparePersonToList(containerId, votingListNumber, personToListNumber) {
+ var personToList = $("#" + containerId + "_" + personToListNumber);
- var personToListId = containerId + "_" + index;
- var personToList = $("#" + personToListId);
+ personToList.data('votingListNumber', votingListNumber);
+ personToList.data('personToListNumber', personToListNumber);
+ personToList.data('personToListContainerId', containerId);
+ updateUpdownPersonToListActions(containerId);
+}
- console.info("preparePersonToLists : containerId = " + containerId +
- ", votingListNumber = " + votingListNumber +
- ", personToListId = " + personToListId +
- ", index " + index);
+function preparePersonToLists(containerId, votingListNumber) {
+ getAllPersonToLists(containerId).each(function (index) {
- personToList.data('votingListNumber', votingListNumber);
- personToList.data('personToListNumber', index);
- personToList.data('personToListContainerId', containerId);
+ preparePersonToList(containerId, votingListNumber, index);
});
- updateUpdownPersonToListActions(containerId);
}
+
function updateUpdownPersonToListActions(containerId) {
- console.info("updateUpdownPersonToListActions : containerId = " +
- containerId);
getAllPersonToLists(containerId).each(function (index) {
var currentPersonToListNumber = $(this).data('personToListNumber');
-
- console.info("updateUpdownPersonToListActions : containerId = " +
- containerId + ", index " + index +
- ", currentPersonToListNumber : " +
- currentPersonToListNumber);
-
var labelWidget = $('#' + containerId + "_" + currentPersonToListNumber + "_label");
labelWidget.html(datas['personToListText'] + ' ' + (index + 1));
});
@@ -245,55 +246,12 @@
var container = $("#" + containerId);
container.append(data);
// store personToListNumber
- var personToList = $("#" + containerId + "_" + personToListNumber);
- personToList.data('votingListNumber', votingListNumber);
- personToList.data('personToListNumber', personToListNumber);
- personToList.data('personToListContainerId', containerId);
- updateUpdownPersonToListActions(containerId);
+ preparePersonToList(containerId, votingListNumber, personToListNumber);
}
});
return false;
}
-function addPersonToList(votingListType, containerId, votingListNumber, personToListNumber, nbPersonToLists, tokenId) {
- loadPersonToList(
- votingListType,
- containerId,
- votingListNumber, personToListNumber, nbPersonToLists, tokenId
- );
-}
-
-function loadPersonToList(votingListType, containerId, votingListNumber, personToListNumber, nbPersonToLists, tokenId) {
- if (personToListNumber == -1) {
- // to add a new personToList, get the new available personToListNumber
- personToListNumber = 1 + getLastPersonToList(containerId);
- }
- $.ajax(
- {
- url:datas['displayPersonToListUrl'],
- data:{
- tokenId:tokenId,
- votingListNumber:votingListNumber,
- votingListType:votingListType,
- personToListNumber:personToListNumber
- },
- async:false,
- dataType:"html",
- success:function (data) {
- var container = $("#" + containerId);
- container.append(data);
- // store personToListNumber
- var personToList = $("#" + containerId + "_" + personToListNumber);
- personToList.data('votingListNumber', votingListNumber);
- personToList.data('personToListNumber', personToListNumber);
- personToList.data('personToListContainerId', containerId);
- if (personToListNumber == nbPersonToLists || !tokenId) {
- updateUpdownPersonToListActions(containerId);
- }
- }
- });
-}
-
function deletePersonToList(personToListId) {
var personToList = $('#' + personToListId);
var containerId = personToList.data('personToListContainerId');
@@ -302,45 +260,8 @@
return false;
}
-function loadPersonListToVotingList(votingListNumber, personToListNumber, personListId) {
+function addPersonListToVotingList(votingListType, containerId, votingListNumber, personListId, cancelCallBack) {
- $.ajax(
- {
- url:datas['importPersonListToVotingListUrl'],
- data:{
- votingListNumber:votingListNumber,
- personToListNumber:personToListNumber,
- personListId:personListId },
- async:false,
- dataType:"json",
- success:function (data) {
- var token = data.tokenId;
- var nbPersonToLists = parseInt(data['nbPersonToLists']);
- var personToListNumber = parseInt(data.personToListNumber);
- var maxPersonToListNumber = parseInt(personToListNumber) + nbPersonToLists - 1;
- console.info(">> token = " + token);
- console.info(">> personListId = " + personListId);
- console.info(">> incoming votingListNumber = " + votingListNumber);
- console.info(">> nb personToList to import = " + nbPersonToLists);
- console.info(">> first personToListNumber = " + personToListNumber);
- console.info(">> last PersonToListNumber = " + maxPersonToListNumber);
-
- var index = personToListNumber;
- while (index <= maxPersonToListNumber) {
- console.info("Will load personToList = " + index + " / " + maxPersonToListNumber);
- addPersonToList(votingListNumber,
- index,
- maxPersonToListNumber,
- token
- );
- index += 1;
- }
- }
- });
-}
-
-function addPersonListToVotingList(votingListType, containerId, votingListNumber, cancelCallBack) {
-
// get first personToList available position
var firstNumber = getFirstEmptyPersonToList(containerId);
if (firstNumber == -1) {
@@ -363,23 +284,21 @@
data:{
votingListType:votingListType,
votingListNumber:votingListNumber,
- personListId:$('#personList').val(),
+ personListId:personListId,
startNumber:firstNumber
},
async:false,
dataType:"html",
success:function (data) {
- console.info("My fucking containerId : " + containerId);
var container = $("#" + containerId);
container.append(data);
- preparePersonToLists(votingListNumber, containerId);
+ preparePersonToLists(containerId, votingListNumber);
}
}
);
return cancelCallBack();
}
-
//----------------------------------------------------------------------------
//-- Choice methods
//----------------------------------------------------------------------------
1
0
Author: fdesbois
Date: 2012-04-11 16:23:26 +0200 (Wed, 11 Apr 2012)
New Revision: 3247
Url: http://chorem.org/repositories/revision/pollen/3247
Log:
- manage preventRules (problem with vote email and manage update case)
- manage voteStarted case that disabled some part of the poll form
Modified:
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java
branches/pollen-1.2.6-struts2/pollen-persistence/src/main/xmi/pollen.zargo
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java
branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java
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/VoteForPoll.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.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
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -139,10 +139,13 @@
public boolean isAddChoiceFinished(Date currentDate) {
return !choiceAddAllowed || (endChoiceDate != null && endChoiceDate.after(currentDate));
}
-
+
+ @Override
public PreventRule getPreventRuleByScope(String scope) {
Preconditions.checkNotNull(scope);
+
for (PreventRule value : getPreventRule()) {
+
if (scope.equals(value.getScope())) {
return value;
}
@@ -150,4 +153,46 @@
return null;
}
+ @Override
+ public PersonToList getPersonToListByVote(Vote vote) {
+ Preconditions.checkNotNull(vote);
+
+ PersonToList result;
+ for (VotingList votingList : getVotingList()) {
+
+ result = votingList.getPollAccountPersonToList(vote.getPollAccount());
+
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public List<PollAccount> getPollAccounts(boolean withNoVote) {
+
+ List<PollAccount> result = Lists.newLinkedList();
+
+ for (VotingList votingList : getVotingList()) {
+
+ for (PersonToList personToList :
+ votingList.getPollAccountPersonToList()) {
+
+ // ignore those with existing vote
+ if (withNoVote && personToList.isHasVoted()) {
+ continue;
+ }
+
+ result.add(personToList.getPollAccount());
+//
+// if (!withNoVote || !personToList.isHasVoted()) {
+//
+// result.add(personToList.getPollAccount());
+// }
+ }
+ }
+ return result;
+ }
+
} //PollImpl
Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -33,11 +33,9 @@
import org.apache.commons.mail.SimpleEmail;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.PollenTechnicalException;
-import org.chorem.pollen.business.persistence.PersonToList;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.UserAccount;
-import org.chorem.pollen.business.persistence.VotingList;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceSupport;
import org.nuiton.util.StringUtil;
@@ -88,10 +86,12 @@
if (StringUtils.isNotEmpty(poll.getCreator().getEmail())) {
- String subject = l_(locale, "pollen.email.creatorEmail.subject",
+ int nbVotes = poll.sizeVote();
+
+ String subject = l_(locale, "pollen.email.voteEmail.subject",
pollTitle);
- String content = l_(locale, "pollen.email.creatorEmail.content",
- pollTitle, voteURL, modifURL);
+ String content = l_(locale, "pollen.email.voteEmail.content",
+ pollTitle, nbVotes, voteURL, modifURL);
PollEmail pollEmail = createPollEmail(
poll.getCreator().getEmail(), subject, content);
@@ -131,8 +131,7 @@
}
// Mails à tous les votants
- List<PollAccount> votingPollAccounts =
- getVotingPollAccounts(poll, false);
+ List<PollAccount> votingPollAccounts = poll.getPollAccounts(false);
if (CollectionUtils.isNotEmpty(votingPollAccounts)) {
String subject = l_(locale, "pollen.email.votingEmail.subject",
@@ -170,7 +169,7 @@
String pollTitle = poll.getTitle();
// Mails aux votants qui n'ont toujours pas voté
- List<PollAccount> votingPollAccounts = getVotingPollAccounts(poll, true);
+ List<PollAccount> votingPollAccounts = poll.getPollAccounts(true);
if (CollectionUtils.isNotEmpty(votingPollAccounts)) {
String subject = l_(locale, "pollen.email.reminderEmail.subject",
@@ -195,34 +194,6 @@
}
}
- //TODO Move this to Poll
- protected List<PollAccount> getVotingPollAccounts(Poll poll,
- boolean keepOnlyIfNotHasVoted) {
- List<PollAccount> result = Lists.newLinkedList();
-
- if (!poll.isVotingListEmpty()) {
-
- for (VotingList votingList : poll.getVotingList()) {
-
- if (!votingList.isPollAccountPersonToListEmpty()) {
-
- for (PersonToList personToList :
- votingList.getPollAccountPersonToList()) {
-
- if (!keepOnlyIfNotHasVoted || !personToList.isHasVoted()) {
-
- PollAccount account = personToList.getPollAccount();
- result.add(account);
- }
-
-
- }
- }
- }
- }
- return result;
- }
-
protected void sendEmail(Iterable<PollEmail> pollEmails) {
//TODO tchemit If two much mails then use SendEmail thread...
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -228,6 +228,9 @@
preventRuleLoaded, preventRuleEditable, !clone);
result.addPreventRule(preventRuleEditable);
}
+
+ // Load votes to have the correct size used to check if vote is started
+ result.setVote(source.getVote());
return result;
}
@@ -352,7 +355,16 @@
public String getPollVoteUrl(Poll poll) {
URL applicationUrl = serviceContext.getApplicationURL();
StringBuilder url = new StringBuilder(applicationUrl.toString());
- url.append("/poll/votefor/").append(poll.getPollId());
+ url.append("/poll/votefor/");
+
+ if (PollType.FREE == poll.getPollType()) {
+ url.append(poll.getPollId());
+
+ } else {
+ // Restricted poll is secure, the creator could access to it when
+ // using the adminId
+ url.append(poll.getAdminId());
+ }
return url.toString();
}
@@ -865,8 +877,21 @@
Vote voteToAdd = getEntityById(Vote.class, voteId);
pollToUpdate.addVote(voteToAdd);
+
+ // Update hasVoted flag for RESTRICTED/GROUP poll
+ if (PollType.FREE != poll.getPollType()) {
+ PersonToList personToList = pollToUpdate.getPersonToListByVote(voteToAdd);
+ personToList.setHasVoted(true);
+ }
+
commitTransaction("Can't add the vote [" + voteId + "] to the poll [" + pollId + "]");
+
+ // Send notification if necessary
+ PreventRuleService preventRuleService = newService(PreventRuleService.class);
+ String pollVoteUrl = getPollVoteUrl(pollToUpdate);
+ String modifUrl = getPollEditUrl(pollToUpdate);
+ preventRuleService.onVoteAdded(poll, pollVoteUrl, modifUrl);
}
public PersonToList getNewPersonToList(PollAccount pollAccount) {
@@ -943,19 +968,19 @@
PreventRuleDAO preventRuleDAO = getDAO(PreventRule.class);
- PreventRule preventRuleLoaded;
- if (preventRule.getTopiaId() == null) {
+ // For the moment only one rule by scope
+ PreventRule preventRuleLoaded = poll.getPreventRuleByScope(preventRule.getScope());
+
+ if (preventRuleLoaded == null) {
preventRuleLoaded = create(preventRuleDAO);
poll.addPreventRule(preventRuleLoaded);
+ preventRuleLoaded.setScope(preventRule.getScope());
+ preventRuleLoaded.setActive(true);
+ }
- } else {
- preventRuleLoaded = poll.getPreventRuleByTopiaId(preventRule.getTopiaId());
- }
- preventRuleLoaded.setActive(preventRule.isActive());
preventRuleLoaded.setMethod(preventRule.getMethod());
preventRuleLoaded.setOneTime(preventRule.isOneTime());
preventRuleLoaded.setRepeated(preventRule.isRepeated());
- preventRuleLoaded.setScope(preventRule.getScope());
preventRuleLoaded.setSensibility(preventRule.getSensibility());
}
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/PreventRuleService.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -39,13 +39,17 @@
* @since 1.2.6
*/
public class PreventRuleService extends PollenServiceSupport {
+
+ public static final String SCOPE_VOTE = "vote";
+
+ public static final String SCOPE_REMINDER = "rappel";
/** Logger. */
private static final Log log = LogFactory.getLog(PreventRuleService.class);
public PreventRule createAddVotePreventRule() {
PreventRule rule = newInstance(getDAO(PreventRule.class));
- rule.setScope("vote");
+ rule.setScope(SCOPE_VOTE);
rule.setSensibility(1);
rule.setRepeated(true);
return rule;
@@ -53,7 +57,7 @@
public PreventRule createRemindPreventRule(int sensibility) {
PreventRule rule = newInstance(getDAO(PreventRule.class));
- rule.setScope("rappel");
+ rule.setScope(SCOPE_REMINDER);
rule.setSensibility(sensibility);
rule.setRepeated(false);
return rule;
@@ -110,7 +114,7 @@
// send to creator a email to say hey a new vote was added!
- if (execute("vote", preventRule, 1)) {
+ if (execute(SCOPE_VOTE, preventRule, 1)) {
// ok can execute this task
@@ -131,7 +135,7 @@
// send to all voting a email to say hey we need to vote
- if (execute("rappel", preventRule, timeValue)) {
+ if (execute(SCOPE_REMINDER, preventRule, timeValue)) {
// ok can execute this task
Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/services/impl/VoteService.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -315,12 +315,21 @@
delete(voteToChoiceDao, voteToChoice);
}
- // Delete vote PollAccount if the Poll is free and account is not the creator
- Poll poll = entityToDelete.getPoll();
- PollAccount voteAccount = entityToDelete.getPollAccount();
- if (PollType.FREE.equals(poll.getPollType()) && !voteAccount.equals(poll.getCreator())) {
- PollAccountDAO accountDAO = getDAO(PollAccount.class);
- delete(accountDAO, voteAccount);
+ Poll poll = entityToDelete.getPoll();
+
+ if (PollType.FREE == poll.getPollType()) {
+
+ // Delete vote PollAccount if the Poll is free and account is not the creator
+ PollAccount voteAccount = entityToDelete.getPollAccount();
+ if (!voteAccount.equals(poll.getCreator())) {
+ PollAccountDAO accountDAO = getDAO(PollAccount.class);
+ delete(accountDAO, voteAccount);
+ }
+
+ // Update pollAccount hasVoted flag
+ } else {
+ PersonToList personToList = poll.getPersonToListByVote(entityToDelete);
+ personToList.setHasVoted(false);
}
poll.removeVote(entityToDelete);
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -228,6 +228,18 @@
public boolean isVoteStarted() {
return isEdit() && poll.sizeVote() > 0;
}
+
+// public boolean isPersonEditable(PersonToList personToList) {
+// boolean result;
+// // If vote is started, the person is editable if he hasn't vote yet
+// if (isVoteStarted()) {
+// result = !personToList.isHasVoted();
+//
+// } else {
+// result = true;
+// }
+// return result;
+// }
public boolean isCreatorUserAccountDefined() {
PollAccount creator = poll.getCreator();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -286,7 +286,9 @@
votes = poll.getVote();
// Current vote
- vote = getVoteService().getVoteEditable(poll, pollAccount);
+ if (isVoteAllowed()) {
+ vote = getVoteService().getVoteEditable(poll, pollAccount);
+ }
loadPollResults();
loadPollComments();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -25,8 +25,10 @@
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Choice;
+import org.chorem.pollen.business.persistence.PreventRule;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.business.persistence.VotingList;
+import org.chorem.pollen.services.impl.PreventRuleService;
import java.util.List;
@@ -72,6 +74,27 @@
pollVotingLists,
!isVoteStarted());
+ if (poll.getMaxChoiceNb() > 0) {
+ setLimitChoice(true);
+ }
+
+ PreventRule reminder = poll.getPreventRuleByScope(
+ PreventRuleService.SCOPE_REMINDER);
+ if (reminder != null) {
+ setReminder(true);
+ setReminderHourCountdown(reminder.getSensibility());
+ }
+
+ PreventRule notification = poll.getPreventRuleByScope(
+ PreventRuleService.SCOPE_VOTE);
+ if (notification != null) {
+ setNotification(true);
+ }
+
+ if (isVoteStarted()) {
+ addActionMessage(_("pollen.information.poll.form.voteStarted"));
+ }
+
return SUCCESS;
}
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-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -49,7 +49,6 @@
import org.chorem.pollen.business.persistence.VotingListImpl;
import org.chorem.pollen.common.ChoiceType;
import org.chorem.pollen.common.PollType;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.PreventRuleService;
import org.chorem.pollen.ui.actions.FileUploadAware;
import org.nuiton.util.StringUtil;
@@ -120,6 +119,20 @@
*/
private Map<Integer, VotingList> votingLists;
+ /**
+ * This message is used in {@code resume.jsp} to display text before vote
+ * page url. For a restricted poll, the message is different because the
+ * url contains the creator accountId.
+ *
+ * @return the message to display to explain vote page url depends on
+ * {@code pollType}.
+ */
+ public String getMessagePollVotePage() {
+ String result = isFreePoll() ? _("pollen.label.pollVotePage") :
+ _("pollen.label.pollVotePage.restricted");
+ return result;
+ }
+
@Override
public void prepare() throws Exception {
@@ -140,55 +153,67 @@
poll = getPollService().getPollEditable(pollUid, userAccount, false);
- // Retrieve choiceType from parameters, the poll object will be updated after prepare
- String choiceTypeParam = getNonEmptyParameterValue("poll.choiceType");
- ChoiceType pollChoiceType = ChoiceType.valueOf(choiceTypeParam);
- poll.setChoiceType(pollChoiceType);
-
- // build poll choices
-
- switch (pollChoiceType) {
-
- case TEXT:
- choices = buildTextChoices();
- break;
- case DATE:
- choices = buildDateChoices();
- break;
- case IMAGE:
- choices = buildImageChoices();
- break;
+ // If vote is started, prepare choices and votingLists is useless
+ // because they can't be updated.
+ if (!isVoteStarted()) {
+
+ // Retrieve choiceType from parameters, the poll object will be updated after prepare
+ String choiceTypeParam = getNonEmptyParameterValue("poll.choiceType");
+ ChoiceType pollChoiceType = ChoiceType.valueOf(choiceTypeParam);
+ poll.setChoiceType(pollChoiceType);
+
+ // build poll choices
+
+ switch (pollChoiceType) {
+
+ case TEXT:
+ choices = buildTextChoices();
+ break;
+ case DATE:
+ choices = buildDateChoices();
+ break;
+ case IMAGE:
+ choices = buildImageChoices();
+ break;
+ }
+
+ PollType pollType;
+ String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
+ if (pollTypeParam == null) {
+ pollType = poll.getPollType();
+
+ } else {
+ pollType = PollType.valueOf(pollTypeParam);
+ }
+
+ switch (pollType) {
+
+ case FREE:
+
+ // empty voting list
+ votingLists = Maps.newTreeMap();
+ break;
+ case RESTRICTED:
+
+ // restricted voting list
+ votingLists = buildVotingLists(pollType);
+ break;
+ case GROUP:
+
+ // group voting lists
+ votingLists = buildVotingLists(pollType);
+ break;
+ }
}
-
- String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
- PollType pollType = PollType.valueOf(pollTypeParam);
- poll.setPollType(pollType);
-
- switch (pollType) {
-
- case FREE:
-
- // empty voting list
- votingLists = Maps.newTreeMap();
- break;
- case RESTRICTED:
-
- // restricted voting list
- votingLists = buildVotingLists(pollType);
- break;
- case GROUP:
-
- // group voting lists
- votingLists = buildVotingLists(pollType);
- break;
- }
}
@Override
public String input() {
- Collection<Choice> pollChoices = choices.values();
- Collection<VotingList> pollVotingLists = votingLists.values();
+ Collection<Choice> pollChoices =
+ isVoteStarted() ? poll.getChoice() : choices.values();
+ Collection<VotingList> pollVotingLists =
+ isVoteStarted() ? poll.getVotingList() : votingLists.values();
loadChoicesAndvotingLists(poll,
pollChoices,
@@ -201,60 +226,10 @@
@Override
public void validate() {
- informationsError = false;
+ informationsError = validateInformations();
- // poll must have a title
- if (StringUtils.isEmpty(poll.getTitle())) {
- addFieldError("poll.title", _("pollen.error.poll.required.title"));
- }
+ optionsError = validateOptions();
- // validate choices
-
- if (MapUtils.isEmpty(choices)) {
-
- // poll must have at least one choice
- addFieldError("poll.choices",
- _("pollen.error.poll.required.one.choice"));
- } else {
-
- ChoiceType choiceType = poll.getChoiceType();
- int inputChoicesSize = choices.size();
- Set<Object> choiceValues =
- Sets.newHashSet(ChoiceHelper.toValues(choices.values(),
- choiceType));
-
- if (inputChoicesSize > choiceValues.size()) {
- addFieldError(
- "poll.choices",
- _("pollen.error.poll.detected.duplicate.choice.name"));
- }
- }
-
- optionsError = false;
-
- // validate security stuff
-
- if (isFreePoll()) {
-
- // nothing to validate
-
- } else {
-
- Set<String> groups = Sets.newHashSet();
- Set<String> voters = Sets.newHashSet();
- Set<String> emails = Sets.newHashSet();
-
- for (Map.Entry<Integer, VotingList> entry : votingLists.entrySet()) {
- optionsError |= validateVotingList(entry.getKey(),
- entry.getValue(),
- groups,
- voters,
- emails);
- }
- }
-
- informationsError = hasFieldErrors();
-
if (!informationsError && optionsError) {
// trick to force to go back to form
@@ -266,28 +241,31 @@
@InputConfig(methodName = "input")
public String execute() throws Exception {
- // Clear previous collections to save those from the form
- poll.clearChoice();
- poll.clearPreventRule();
- poll.clearVotingList();
+ // Save choices and votingLists only if vote is not started
+ if (!isVoteStarted()) {
- Map<Integer, Choice> orderedChoices = choices;
+ // Clear previous collections to save those from the form
+ poll.clearChoice();
+ poll.clearVotingList();
- for (Integer index : orderedChoices.keySet()) {
- Choice choice = orderedChoices.get(index);
- poll.addChoice(choice);
- }
+ Map<Integer, Choice> orderedChoices = choices;
- if (!isFreePoll()) {
+ for (Integer index : orderedChoices.keySet()) {
+ Choice choice = orderedChoices.get(index);
+ poll.addChoice(choice);
+ }
- for (Integer index : votingLists.keySet()) {
- VotingList votingList = votingLists.get(index);
- poll.addVotingList(votingList);
+ if (!isFreePoll()) {
+
+ for (Integer index : votingLists.keySet()) {
+ VotingList votingList = votingLists.get(index);
+ poll.addVotingList(votingList);
+ }
}
}
+
+ poll.clearPreventRule();
- PollService service = getPollService();
-
PreventRuleService preventRuleService =
newService(PreventRuleService.class);
if (isNotification()) {
@@ -310,11 +288,11 @@
}
if (isEdit()) {
- service.updatePoll(poll);
+ getPollService().updatePoll(poll);
addActionMessage(_("pollen.information.poll.updated"));
} else {
- service.createPoll(poll);
+ getPollService().createPoll(poll);
addActionMessage(_("pollen.information.poll.created"));
}
@@ -384,6 +362,82 @@
return result;
}
+ protected boolean validateInformations() {
+
+ // -- Title : required -- //
+ if (StringUtils.isBlank(poll.getTitle())) {
+ addFieldError("poll.title", _("pollen.error.poll.required.title"));
+ }
+
+ if (isVoteStarted()) {
+
+ // no validation on choices if vote is started
+
+ } else {
+
+ // -- Choice -- //
+
+ if (MapUtils.isEmpty(choices)) {
+
+ // poll must have at least one choice
+ addFieldError("poll.choices",
+ _("pollen.error.poll.required.one.choice"));
+ } else {
+
+ ChoiceType choiceType = poll.getChoiceType();
+ int inputChoicesSize = choices.size();
+ Set<Object> choiceValues =
+ Sets.newHashSet(ChoiceHelper.toValues(choices.values(),
+ choiceType));
+
+ if (inputChoicesSize > choiceValues.size()) {
+ addFieldError(
+ "poll.choices",
+ _("pollen.error.poll.detected.duplicate.choice.name"));
+ }
+ }
+ }
+
+ boolean result = hasFieldErrors();
+
+ return result;
+ }
+
+ protected boolean validateOptions() {
+
+ boolean result = false;
+
+ if (isVoteStarted()) {
+
+ // no validation on votingLists if vote is started
+
+ } else {
+
+ // -- VotingList -- //
+
+ if (isFreePoll()) {
+
+ // nothing to validate
+
+ } else {
+
+ Set<String> groups = Sets.newHashSet();
+ Set<String> voters = Sets.newHashSet();
+ Set<String> emails = Sets.newHashSet();
+
+ for (Map.Entry<Integer, VotingList> entry : votingLists.entrySet()) {
+ result |= validateVotingList(entry.getKey(),
+ entry.getValue(),
+ groups,
+ voters,
+ emails);
+ }
+ }
+ }
+
+ return result;
+ }
+
protected boolean validateVotingList(int votingListNumber,
VotingList votingList,
Set<String> groups,
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -33,6 +33,7 @@
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.business.persistence.VoteToChoice;
+import org.chorem.pollen.common.PollType;
/**
* Votes to a poll.
@@ -83,6 +84,7 @@
for (VoteToChoice voteToChoice : vote.getChoiceVoteToChoice()) {
Integer value = voteToChoice.getVoteValue();
+ // XXX-fdesbois-2012-04-11 : for a VoteCountingType#NUMBER the difference between 0 and null value could be important
if (value != null && value != 0) {
nbVotes++;
totalValues += value;
@@ -121,8 +123,8 @@
clearMessages();
- // Display updateUrl if user is not logged
- if (!isUserLoggued()) {
+ // For free Poll, display the update Url (useless if user is logged)
+ if (PollType.FREE == getPoll().getPollType() && !isUserLoggued()) {
String pollId = getPoll().getPollId();
String accountId = getPollAccount().getAccountId();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollAccessRequired.java 2012-04-11 14:23:26 UTC (rev 3247)
@@ -41,8 +41,11 @@
protected final AdminUserRequired adminFilter;
+ protected final PollCreatorRequired pollCreatorFilter;
+
public PollAccessRequired() {
adminFilter = new AdminUserRequired();
+ pollCreatorFilter = new PollCreatorRequired();
}
@Override
@@ -57,6 +60,11 @@
// user is connected ans admin, so
isAccessAllowed = true;
+ } else if (pollCreatorFilter.isAccessAllowed(request, response, mappedValue)) {
+
+ // user is connected ans admin, so
+ isAccessAllowed = true;
+
} else {
PollUri pollUri = getPollUri(request);
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-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-11 14:23:26 UTC (rev 3247)
@@ -191,6 +191,7 @@
pollen.information.irreversible.operation=Be ware, this operation is irreversible.
pollen.information.need.login=You must be logged to access this page. Please fill the form below.
pollen.information.poll.created=Poll created
+pollen.information.poll.form.voteStarted=Votes are started, some options can't be updated.
pollen.information.poll.updated=Poll modified
pollen.information.pollAccount.addedTofavoriteList=Member '%s was added to favorite list.
pollen.information.pollAccount.removedFromFavoriteList=Member %s was removed from favorite list.
@@ -209,6 +210,7 @@
pollen.label.pollEditPage=The link below leads to the page to modify your poll. Save it to be able to modify your poll later if you need it or to close it \:
pollen.label.pollRegisterPage=If you are a logged user, you can find these links on the page
pollen.label.pollVotePage=The link below leads to the page to vote for your poll. Save it and send it to the people that you want to vote \:
+pollen.label.pollVotePage.restricted=
pollen.legend.login=Login
pollen.legend.select.favoriteList.to.add=Sélectionner la liste de favoris à ajouter
pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des votant à importer dans le nouveau groupe
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-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-11 14:23:26 UTC (rev 3247)
@@ -199,6 +199,7 @@
pollen.information.irreversible.operation=Attention, Cette opération est irréversible.
pollen.information.need.login=Vous devez être identifié pour pouvoir accéder à cette page. Veuillez remplir le formulaire ci-dessous.
pollen.information.poll.created=Sondage créé
+pollen.information.poll.form.voteStarted=Les votes ont commencé, certaines options ne sont pas modifiables.
pollen.information.poll.updated=Sondage mise à jour
pollen.information.pollAccount.addedTofavoriteList=Le membre %s a été ajoutée à la liste des favoris.
pollen.information.pollAccount.removedFromFavoriteList=Le membre %s a été supprimé de la liste des favoris.
@@ -217,6 +218,7 @@
pollen.label.pollEditPage=Le lien ci-dessous mène à la page de modification du sondage. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore \:
pollen.label.pollRegisterPage=Si vous êtes un utilisateur identifié, vous pouvez retrouver ces liens dans la page
pollen.label.pollVotePage=Le lien ci-dessous mène à la page de vote. Enregistrez-le et envoyez-le à ceux que vous voulez voir voter \:
+pollen.label.pollVotePage.restricted=Le lien ci-dessous mène à la page de vote. Cet accès n'est valable que pour vous en tant que créateur du sondage \:
pollen.legend.login=Login
pollen.legend.select.favoriteList.to.add=Sélectionner la liste de favoris à ajouter
pollen.legend.select.personList.to.create.votingList=Sélectionner la liste des votant à importer dans le nouveau groupe
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/PersonToList.jsp 2012-04-11 14:23:26 UTC (rev 3247)
@@ -40,24 +40,29 @@
value=''/>
<s:textfield cssClass="nameField" id='%{#personPrefix}.votingId'
key="%{#personPrefix}.votingId" label='' theme="simple"
- value="%{#personToList.pollAccount.votingId}"/>
+ value="%{#personToList.pollAccount.votingId}"
+ disabled="%{voteStarted}"/>
-
<s:label for="%{#personPrefix}.email" key="pollen.common.email" theme="simple"/>
<s:textfield cols="30" id="%{#personPrefix}.email" key="%{#personPrefix}.email"
label='' theme="simple" size="30"
- value="%{#personToList.pollAccount.email}"/>
+ value="%{#personToList.pollAccount.email}"
+ disabled="%{voteStarted}"/>
-
<s:label for="%{#personPrefix}.weight" key="pollen.common.weight" theme="simple"/>
<s:textfield id="%{#personPrefix}.weight" key="%{#personPrefix}.weight" size="1"
- label='' theme="simple" value="%{#personToList.weight}"/>
+ label='' theme="simple" value="%{#personToList.weight}"
+ disabled="%{voteStarted}"/>
</div>
- <div class="fright">
- <s:a href='#' onclick="return deletePersonToList('%{#personPrefix}')">
- <image alt='<s:property value="%{#deletePersonTitle}"/>'
- title='<s:property value="%{#deletePersonTitle}"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a href='#' onclick="return deletePersonToList('%{#personPrefix}')">
+ <image alt='<s:property value="%{#deletePersonTitle}"/>'
+ title='<s:property value="%{#deletePersonTitle}"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ </div>
+ </s:if>
<div class="cleanBoth"></div>
</s:div>
\ No newline at end of file
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/VotingList.jsp 2012-04-11 14:23:26 UTC (rev 3247)
@@ -125,12 +125,14 @@
<s:submit id='%{#prefix}_addPersonToList'
name='%{#prefix}_addPersonToList'
key="pollen.action.addPersonToList" theme="simple"
- onclick='return addNewPersonToList("%{votingListType}","%{#prefix}PersonToList","%{votingListNumber}");'/>
+ onclick='return addNewPersonToList("%{votingListType}","%{#prefix}PersonToList","%{votingListNumber}");'
+ disabled="%{voteStarted}"/>
<s:if test="userLoggued">
<s:submit id='%{#prefix}_addPersonToList' theme="simple"
name='%{#prefix}_addPersonToList'
key="pollen.action.addPersonListFromVotingList"
- onclick='return selectPersonListToAddToVotingList("%{votingListNumber}");'/>
+ onclick='return selectPersonListToAddToVotingList("%{votingListNumber}");'
+ disabled="%{voteStarted}"/>
</s:if>
</div>
</fieldset>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-04-11 14:23:26 UTC (rev 3247)
@@ -47,6 +47,9 @@
selectPersonListToAddToVotingListUrl:'<s:url action="selectPersonListToAddToVotingList" namespace="/poll"/>',
selectPersonListToCreateNewVotingListUrl:'<s:url action="selectPersonListToCreateNewVotingList" namespace="/poll"/>',
+ choiceAddAllowed:'<s:property value="%{poll.choiceAddAllowed}"/>',
+ limitChoice:'<s:property value="%{limitChoice}"/>',
+ reminder:'<s:property value="%{reminder}"/>',
voteCountingType:'<s:property value="%{poll.voteCountingType.name()}"/>',
choiceType:'<s:property value="%{poll.choiceType.name()}"/>',
pollType:'<s:property value="%{poll.pollType.name()}"/>'
@@ -134,17 +137,20 @@
<div id='addChoiceAddAllowedPanel' class="hidden">
<sj:datepicker key="poll.beginChoiceDate"
label="%{getText('pollen.common.beginChoiceDate')}"
- displayFormat="dd/mm/yy"/>
+ displayFormat="dd/mm/yy" timepicker="true"
+ disabled="%{voteStarted}"/>
<sj:datepicker key="poll.endChoiceDate"
label="%{getText('pollen.common.endChoiceDate')}"
- displayFormat="dd/mm/yy"/>
+ displayFormat="dd/mm/yy" timepicker="true"
+ disabled="%{voteStarted}"/>
</div>
<s:checkbox key="limitChoice"
label="%{getText('pollen.common.pollOption.limitChoice')}"
disabled="%{voteStarted}"/>
<div id='maxChoiceNbPanel' class="hidden">
<s:textfield key="poll.maxChoiceNb"
- label="%{getText('pollen.common.pollOption.maxChoiceNb')}"/>
+ label="%{getText('pollen.common.pollOption.maxChoiceNb')}"
+ disabled="%{voteStarted}"/>
</div>
<s:checkbox key="notification"
label="%{getText('pollen.common.pollOption.notification')}"/>
@@ -162,8 +168,10 @@
<sj:datepicker key="poll.beginDate" displayFormat="dd/mm/yy"
label="%{getText('pollen.common.beginDate')}"
+ timepicker="true"
disabled="%{voteStarted}"/>
<sj:datepicker key="poll.endDate" displayFormat="dd/mm/yy"
+ timepicker="true"
label="%{getText('pollen.common.endDate')}"/>
</fieldset>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-04-11 14:23:26 UTC (rev 3247)
@@ -45,35 +45,39 @@
<s:label for="%{#prefix}.name" id="choicesTEXT_label_%{#choiceNumber}"
theme="simple" value=''/>
<s:textfield cssClass="nameField" id='%{#prefix}.name' key="%{#prefix}.name"
- label='' theme="simple" value="%{#choice.name}"/>
+ label='' theme="simple" value="%{#choice.name}"
+ disabled="%{voteStarted}"/>
-
<s:label for="%{#prefix}.description" key="pollen.common.description"
theme="simple"/>
<%--/div>
<div class="fleft"--%>
<s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{#choice.description}"/>
+ key="%{#prefix}.description" value="%{#choice.description}"
+ disabled="%{voteStarted}"/>
</div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{#choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesTEXT_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{#choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
</s:a>
- <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
+ <%--s:a id='choicesTEXT_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ </s:if>
<div class="cleanBoth"></div>
</div>
</s:iterator>
@@ -90,7 +94,8 @@
theme="simple" value=''/>
<sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" changeMonth="true"
changeYear="true" labelSeparator="" theme="simple" label=""
- timepicker="true" value="%{choice.date}" displayFormat="dd/mm/yy"/>
+ timepicker="true" value="%{choice.date}" displayFormat="dd/mm/yy"
+ disabled="%{voteStarted}"/>
-
<s:label for="%{#prefix}.description" key="pollen.common.description"
theme="simple"/>
@@ -98,28 +103,31 @@
<div class="fleft">
<s:textarea cols="30" id="%{#prefix}.description"
key="%{#prefix}.description" label='' theme="simple"
- value="%{choice.description}"/>
+ value="%{choice.description}"
+ disabled="%{voteStarted}"/>
</div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesDATE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
</s:a>
- <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
+ <%--s:a id='choicesDATE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ </s:if>
<div class="cleanBoth"></div>
</div>
</s:iterator>
@@ -147,7 +155,8 @@
</s:if>
<s:else>
<%--New image--%>
- <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>
+ <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"
+ disabled="%{voteStarted}"/>
</s:else>
-
<s:label for="%{#prefix}.description" key="pollen.common.description"
@@ -155,28 +164,31 @@
</div>
<div class="fleft">
<s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{choice.description}"/>
+ key="%{#prefix}.description" value="%{choice.description}"
+ disabled="%{voteStarted}"/>
</div>
- <div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
</s:a>
- <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
- </div>
+ <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a--%>
+ </div>
+ </s:if>
<div class="cleanBoth"></div>
</div>
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/resume.jsp 2012-04-11 14:23:26 UTC (rev 3247)
@@ -32,7 +32,7 @@
<img src="<s:url value='/img/vote.png'/>"
alt="<s:text name='pollen.common.voteAction'/>"
style="margin-right: 18px;"/>
- <s:text name='pollen.label.pollVotePage'/>
+ <s:property value="%{messagePollVotePage}"/>
<br/>
<s:set name="voteUrl" value="%{pollVoteUrl}"/>
<s:a href="%{voteUrl}" cssStyle="margin-left:50px;">
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-04-11 14:23:09 UTC (rev 3246)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-04-11 14:23:26 UTC (rev 3247)
@@ -508,6 +508,30 @@
jQuery(document).ready(function () {
+ function changeChoiceAddAllowed(val) {
+ if (val) {
+ $('#addChoiceAddAllowedPanel').show();
+ } else {
+ $('#addChoiceAddAllowedPanel').hide();
+ }
+ }
+
+ function changeLimitChoice(val) {
+ if (val) {
+ $('#maxChoiceNbPanel').show();
+ } else {
+ $('#maxChoiceNbPanel').hide();
+ }
+ }
+
+ function changeReminder(val) {
+ if (val) {
+ $('#reminderPanel').show();
+ } else {
+ $('#reminderPanel').hide();
+ }
+ }
+
function changePollType(type) {
$('.pollType').addClass('hidden');
@@ -528,31 +552,16 @@
$('[name="poll.choiceType"][value="' + type + '"]').attr('checked', 'checked');
}
- $('[name="poll.choiceAddAllowed"]').change(function () {
- var val = $(this).prop('checked');
- if (val) {
- $('#addChoiceAddAllowedPanel').show();
- } else {
- $('#addChoiceAddAllowedPanel').hide();
- }
+ $('[name="poll.choiceAddAllowed"]').change(function() {
+ changeChoiceAddAllowed($(this).prop('checked'));
});
$('[name="limitChoice"]').change(function () {
- var val = $(this).prop('checked');
- if (val) {
- $('#maxChoiceNbPanel').show();
- } else {
- $('#maxChoiceNbPanel').hide();
- }
+ changeLimitChoice($(this).prop('checked'));
});
$('[name="reminder"]').change(function () {
- var val = $(this).prop('checked');
- if (val) {
- $('#reminderPanel').show();
- } else {
- $('#reminderPanel').hide();
- }
+ changeReminder($(this).prop('checked'));
});
$('[name="poll.anonymous"]').change(function () {
@@ -583,9 +592,11 @@
prepareVotingLists('votingListRESTRICTED');
prepareVotingLists('votingListGROUP');
+ changeChoiceAddAllowed(datas['choiceAddAllowed'] == 'true');
+ changeLimitChoice(datas['limitChoice'] == 'true');
+ changeReminder(datas['reminder'] == 'true');
+
changeChoiceType(datas['choiceType']);
-
changePollType(datas['pollType']);
-
});
\ No newline at end of file
1
0
r3246 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions java/org/chorem/pollen/ui/actions/poll resources/i18n webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 11 Apr '12
by fdesbois@users.chorem.org 11 Apr '12
11 Apr '12
Author: fdesbois
Date: 2012-04-11 16:23:09 +0200 (Wed, 11 Apr 2012)
New Revision: 3246
Url: http://chorem.org/repositories/revision/pollen/3246
Log:
clean some messages and translations
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.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
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-04-11 14:23:02 UTC (rev 3245)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-04-11 14:23:09 UTC (rev 3246)
@@ -288,4 +288,20 @@
List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
return CollectionUtils.isNotEmpty(result);
}
+
+ @Override
+ public void clearMessages() {
+ List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
+ if (result != null) {
+ result.clear();
+ }
+ }
+
+ @Override
+ public void clearActionErrors() {
+ List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+ if (result != null) {
+ result.clear();
+ }
+ }
}
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-04-11 14:23:02 UTC (rev 3245)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-04-11 14:23:09 UTC (rev 3246)
@@ -201,7 +201,7 @@
}
public String getVoteSizeMessage() {
- return voteSizeMessage;
+ return _("pollen.common.voteNbVotes", getPoll().sizeVote());
}
public boolean isDescNull(Choice choice) {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-04-11 14:23:02 UTC (rev 3245)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-04-11 14:23:09 UTC (rev 3246)
@@ -119,6 +119,8 @@
getPollService().addVoteToPoll(getPoll(), voteCreated);
}
+ clearMessages();
+
// Display updateUrl if user is not logged
if (!isUserLoggued()) {
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-11 14:23:02 UTC (rev 3245)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-11 14:23:09 UTC (rev 3246)
@@ -202,8 +202,8 @@
pollen.information.user.created=User %s created.
pollen.information.user.deleted=User %s deleted.
pollen.information.user.updated=User %s updated.
-pollen.information.vote.created=
-pollen.information.vote.createdWithUpdateUrl=
+pollen.information.vote.created=Vote saved
+pollen.information.vote.createdWithUpdateUrl=Vote saved, you can modify it using this address \: <br/> <a href\="%1$s">%1$s</a>
pollen.information.your.are.loggued=You are logged.
pollen.label.contact.administrator=Send an email to an administrator
pollen.label.pollEditPage=The link below leads to the page to modify your poll. Save it to be able to modify your poll later if you need it or to close it \:
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-11 14:23:02 UTC (rev 3245)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-11 14:23:09 UTC (rev 3246)
@@ -211,7 +211,7 @@
pollen.information.user.deleted=L'utilisateur %s a été supprimé.
pollen.information.user.updated=L'utilisateur %s a été mis à jour.
pollen.information.vote.created=Vote enregistré
-pollen.information.vote.createdWithUpdateUrl=Vote enregistré, vous pourrez le modifier à l'adresse suivante <a href\="%1$s">%1$s</a>
+pollen.information.vote.createdWithUpdateUrl=Vote enregistré, vous pourrez le modifier à l'adresse suivante \: <br/> <a href\="%1$s">%1$s</a>
pollen.information.your.are.loggued=Vous êtes connecté.
pollen.label.contact.administrator=Contacter un administrateur
pollen.label.pollEditPage=Le lien ci-dessous mène à la page de modification du sondage. Enregistrez-le pour pouvoir modifier votre sondage au besoin ou le clore \:
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-04-11 14:23:02 UTC (rev 3245)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-04-11 14:23:09 UTC (rev 3246)
@@ -153,12 +153,10 @@
<%--<t:feedback t:id="voteFeedback"/>--%>
</s:if>
<s:else>
- <%--TODO Do me!--%>
<div class="p-pager">
- <s:text name="pollen.common.voteNbVotes">
- <s:param><s:property value="%{poll.sizeVote()}"/></s:param>
- </s:text>
+ <s:property value="%{voteSizeMessage}"/>
</div>
+ <%--TODO Do me pager !--%>
<%--<t:pager t:nbRowsPerPage="nbVotesPerPage" t:nbTotalRows="poll.nbVotes"--%>
<%--t:currentPage="page" t:noPagerText="prop:noPagerText"/>--%>
</s:else>
1
0
r3245 - branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by fdesbois@users.chorem.org 11 Apr '12
by fdesbois@users.chorem.org 11 Apr '12
11 Apr '12
Author: fdesbois
Date: 2012-04-11 16:23:02 +0200 (Wed, 11 Apr 2012)
New Revision: 3245
Url: http://chorem.org/repositories/revision/pollen/3245
Log:
fixes #204 : add style for break spaces
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-04-10 14:00:58 UTC (rev 3244)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-04-11 14:23:02 UTC (rev 3245)
@@ -67,7 +67,9 @@
<!-- Informations sur le sondage -->
<div id="resultTop">
- <s:property value="poll.description"/>
+ <div style="white-space:pre-wrap; text-align: start;">
+ <s:property value="poll.description"/>
+ </div>
<fieldset>
<legend><s:text name="pollen.common.aboutPoll"/></legend>
<div style="float: right">
1
0
r3244 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui: . security
by tchemit@users.chorem.org 10 Apr '12
by tchemit@users.chorem.org 10 Apr '12
10 Apr '12
Author: tchemit
Date: 2012-04-10 16:00:58 +0200 (Tue, 10 Apr 2012)
New Revision: 3244
Url: http://chorem.org/repositories/revision/pollen/3244
Log:
fix shiro filter init
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-04-06 17:36:59 UTC (rev 3243)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenApplicationListener.java 2012-04-10 14:00:58 UTC (rev 3244)
@@ -71,6 +71,10 @@
log.info("Application starting at " + new Date() + "...");
}
+ // keep the servlet context to init shiro filters
+ //FIXME tchemit 2012-04-10 change this when shiro will be properly init :(
+ PollenUIUtils.setServletContext(sce.getServletContext());
+
// init I18n
DefaultI18nInitializer i18nInitializer =
new DefaultI18nInitializer("pollen-i18n");
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java 2012-04-06 17:36:59 UTC (rev 3243)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenUIUtils.java 2012-04-10 14:00:58 UTC (rev 3244)
@@ -26,6 +26,7 @@
import org.apache.struts2.ServletActionContext;
import org.chorem.pollen.PollenTechnicalException;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.MalformedURLException;
@@ -39,6 +40,19 @@
*/
public class PollenUIUtils {
+ /**
+ * Keep the servlet context
+ */
+ private static ServletContext servletContext;
+
+ public static ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public static void setServletContext(ServletContext servletContext) {
+ PollenUIUtils.servletContext = servletContext;
+ }
+
public static void redirect(String url) throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-04-06 17:36:59 UTC (rev 3243)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-04-10 14:00:58 UTC (rev 3244)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.ui.security;
+import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.util.StringUtils;
@@ -35,9 +36,11 @@
import org.chorem.pollen.services.PollenServiceFactory;
import org.chorem.pollen.ui.PollenApplicationContext;
import org.chorem.pollen.ui.PollenSession;
+import org.chorem.pollen.ui.PollenUIUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.web.filter.TopiaTransactionFilter;
+import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@@ -58,10 +61,22 @@
protected AbstractPollenAuthorization() {
if (log.isInfoEnabled()) {
- log.info("Init - "+this);
+ log.info("Init - " + this);
}
}
+ @Override
+ public ServletContext getServletContext() {
+ ServletContext servletContext = super.getServletContext();
+ if (servletContext == null) {
+ servletContext = PollenUIUtils.getServletContext();
+ Preconditions.checkNotNull(servletContext);
+ // store it back
+ setServletContext(servletContext);
+ }
+ return servletContext;
+ }
+
protected PollUri getPollUri(ServletRequest request) {
String servletPath = ((HttpServletRequest) request).getServletPath();
Matcher m = URI_PATTERN.matcher(servletPath);
1
0
r3243 - in branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui: . security
by tchemit@users.chorem.org 06 Apr '12
by tchemit@users.chorem.org 06 Apr '12
06 Apr '12
Author: tchemit
Date: 2012-04-06 19:36:59 +0200 (Fri, 06 Apr 2012)
New Revision: 3243
Url: http://chorem.org/repositories/revision/pollen/3243
Log:
make pollen works without the jetty-runner servlet api (no method ServletRequest#getServletContext())
Modified:
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java
branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-04-06 16:46:00 UTC (rev 3242)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenTopiaTransactionFilter.java 2012-04-06 17:36:59 UTC (rev 3243)
@@ -30,6 +30,9 @@
import org.nuiton.topia.TopiaRuntimeException;
import org.nuiton.web.filter.TopiaTransactionFilter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
/**
@@ -44,10 +47,20 @@
private static final Log log =
LogFactory.getLog(PollenTopiaTransactionFilter.class);
+ private ServletContext servletContext;
+
@Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ servletContext = filterConfig.getServletContext();
+ super.init(filterConfig);
+ }
+
+ @Override
protected TopiaContext beginTransaction(ServletRequest request) throws TopiaRuntimeException {
+
PollenApplicationContext applicationContext =
- PollenApplicationContext.get(request.getServletContext());
+ PollenApplicationContext.get(servletContext);
TopiaContext rootContext = applicationContext.getRootContext();
try {
Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
===================================================================
--- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-04-06 16:46:00 UTC (rev 3242)
+++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-04-06 17:36:59 UTC (rev 3243)
@@ -84,7 +84,7 @@
protected PollenServiceContext getServiceContext(ServletRequest request) {
PollenApplicationContext applicationContext =
- PollenApplicationContext.get(request.getServletContext());
+ PollenApplicationContext.get(getServletContext());
PollenServiceFactory serviceFactory = new PollenServiceFactory();
1
0