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
- 3196 discussions
r3506 - trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 10:22:04 +0200 (Mon, 18 Jun 2012)
New Revision: 3506
Url: http://chorem.org/repositories/revision/pollen/3506
Log:
refs #606: fix create form submit action
Modified:
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java
Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java 2012-06-18 07:58:19 UTC (rev 3505)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java 2012-06-18 08:22:04 UTC (rev 3506)
@@ -90,7 +90,7 @@
choiceTwoElement.sendKeys("Choix numero deux");
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// All good, should be on summary page !
@@ -124,7 +124,7 @@
choiceTwoElement.sendKeys(choiceTwoValue);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// Title is missing, should stay on create poll page
@@ -166,7 +166,7 @@
titleElement.sendKeys(pollTitle);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -224,7 +224,7 @@
endDateElement.sendKeys(formatMonthAgo);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -301,7 +301,7 @@
endDateElement.sendKeys(formatOneMonthAgo);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -361,7 +361,7 @@
emailElement.sendKeys("i@minvalid");
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -431,7 +431,7 @@
maxChoiceElement.sendKeys("-1");
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -467,7 +467,7 @@
maxChoiceElement.sendKeys("0");
// Submit form
- submit = findElement(By.name("action:save"));
+ submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
1
0
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:58:19 +0200 (Mon, 18 Jun 2012)
New Revision: 3505
Url: http://chorem.org/repositories/revision/pollen/3505
Log:
continue security stuff
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -29,8 +29,6 @@
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Comment;
-import org.chorem.pollen.business.persistence.PersonToList;
-import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountDAO;
@@ -38,8 +36,6 @@
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceSupport;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException;
import org.nuiton.topia.TopiaException;
import java.util.Date;
@@ -55,9 +51,8 @@
*/
public class SecurityService extends PollenServiceSupport {
- public boolean isCreator(Poll poll,
- PollUri uriId,
- UserAccount pollenUserAccount) {
+ public boolean isPollCreator(Poll poll, PollUri uriId,
+ UserAccount pollenUserAccount) {
PollAccount creator = poll.getCreator();
@@ -71,6 +66,7 @@
return result;
}
+
/**
* To define meaning of a accountId.
*
@@ -102,114 +98,83 @@
AccountIdRole.CREATOR
);
- public void checkPoll(PollUri uri) throws PollNotFoundException {
+// public void checkPoll(PollUri uri) throws PollNotFoundException {
+//
+// getExistingPoll(uri);
+// }
- getExistingPoll(uri);
- }
+// public void checkPollResult(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+//
+// Poll poll = getExistingPoll(uri);
+//
+// if (!poll.isPublicResults()) {
+// throw new UnauthorizedPollAccessException();
+// }
+// }
- public void checkPollResult(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+// public void checkPollAccount(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+//
+//
+// String accountId = uri.getAccountId();
+//
+// Poll poll = getExistingPoll(uri);
+//
+// PollAccountDAO dao = getDAO(PollAccount.class);
+//
+// String pollId = uri.getPollId();
+//
+// if (poll.getPollType() == PollType.FREE) {
+//
+// // free poll
+// if (accountId != null) {
+//
+// // account Id is given check there is a such vote for this account
+//
+// try {
+//
+// if (!dao.existsByPollVoteAccountId(pollId, accountId)) {
+// throw new UnauthorizedPollAccessException();
+// }
+// } catch (TopiaException e) {
+// throw new PollenTechnicalException(
+// "Could not check pollAccount existence from poll '" +
+// pollId + "' and account '" + accountId + "'", e);
+// }
+// }
+// } else {
+//
+// // check that uri contains a correct poll account for this
+//
+// // Use PersonToList association entity to find coherence between
+// // the poll and votingId
+//
+// try {
+// PollAccount result =
+// dao.getRestrictedPollAccount(pollId, accountId);
+//
+// if (result == null) {
+// throw new UnauthorizedPollAccessException();
+// }
+// } catch (TopiaException e) {
+// throw new PollenTechnicalException(
+// "Could not obtain restricted pollAccount", e);
+// }
+// }
+// }
- Poll poll = getExistingPoll(uri);
+// public void checkPollCreator(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+//
+// String accountId = uri.getAccountId();
+//
+// Poll poll = getExistingPoll(uri);
+//
+// String creatorId = poll.getCreator().getAccountId();
+//
+// if (!creatorId.equals(accountId)) {
+// throw new UnauthorizedPollAccessException();
+// }
+// }
- if (!poll.isPublicResults()) {
- throw new UnauthorizedPollAccessException();
- }
- }
-
- public void checkPollAccount(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
-
-
- String accountId = uri.getAccountId();
-
- Poll poll = getExistingPoll(uri);
-
- PollAccountDAO dao = getDAO(PollAccount.class);
-
- String pollId = uri.getPollId();
-
- if (poll.getPollType() == PollType.FREE) {
-
- // free poll
- if (accountId != null) {
-
- // account Id is given check there is a such vote for this account
-
- try {
-
- if (!dao.existsByPollVoteAccountId(pollId, accountId)) {
- throw new UnauthorizedPollAccessException();
- }
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not check pollAccount existence from poll '" +
- pollId + "' and account '" + accountId + "'", e);
- }
- }
- } else {
-
- // check that uri contains a correct poll account for this
-
- // Use PersonToList association entity to find coherence between
- // the poll and votingId
-
- try {
- PollAccount result =
- dao.getRestrictedPollAccount(pollId, accountId);
-
- if (result == null) {
- throw new UnauthorizedPollAccessException();
- }
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not obtain restricted pollAccount", e);
- }
- }
- }
-
- public void checkPollCreator(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
-
- String accountId = uri.getAccountId();
-
- Poll poll = getExistingPoll(uri);
-
- String creatorId = poll.getCreator().getAccountId();
-
- if (!creatorId.equals(accountId)) {
- throw new UnauthorizedPollAccessException();
- }
- }
-
- private boolean isVoterAccountId(PollAccountDAO dao, PollUri uri) {
- try {
-
- return dao.existsByPollVoteAccountId(uri.getPollId(), uri.getAccountId());
-
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not check pollAccount existence from poll '" +
- uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
- }
- }
-
- private boolean isRestrictPollAccountId(PollAccountDAO dao, PollUri uri) {
- try {
-
- PollAccount result =
- dao.getRestrictedPollAccount(uri.getPollId(), uri.getAccountId());
-
- return result != null;
-
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not check pollAccount existence from poll '" +
- uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
- }
- }
-
- protected Poll getExistingPoll(PollUri uri) throws PollNotFoundException {
- return newService(PollService.class).getExistingPollByPollId(uri.getPollId());
- }
-
public AccountIdRole getAccountIdRole(Poll poll, String accountId) {
Preconditions.checkNotNull(poll);
@@ -249,8 +214,8 @@
return result;
}
- public String isCanShowResult(Poll poll,
- SecurityService.AccountIdRole accountIdRole) {
+ public String isCanAccessResult(Poll poll,
+ SecurityService.AccountIdRole accountIdRole) {
// check now poll results can be displayed
@@ -282,104 +247,316 @@
return null;
}
- /**
- * Vote is allowed if {@code poll} is running and {@code pollAccount} is
- * defined in the {@code poll} restricted list if it's not a {@link PollType#FREE}
- * poll. The account must be defined previously using
- * {@link PollService#getPollAccountEditable(String, UserAccount, Poll)} to
- * have a proper link between userAccount and pollAccount even if not already
- * created in dabase. The poll creator can't vote. The token is just use
- * for moderate purpose.
- *
- * @param poll Poll
- * @param accountEditable Account to check
- * @return true if vote is allowed, false otherwise
- */
- public boolean isVoteAllowed(Poll poll, PollAccount accountEditable) {
+ public String isCanAccessVote(Poll poll, String accountId, AccountIdRole accountIdRole) {
- Preconditions.checkNotNull(poll);
- Preconditions.checkNotNull(accountEditable);
+ if (AccountIdRole.CREATOR == accountIdRole) {
+ // poll admin can alwyas access vote page
+ return null;
+ }
+
+ boolean pollIsFree = PollType.FREE == poll.getPollType();
+
+ if (pollIsFree && poll.getCreator().getAccountId().equals(accountId)) {
+
+ // on free poll, only the creator (using his creatorId as accountId) can not vote
+ return n_("pollen.security.error.poll.free.creatorId.can.not.vote");
+ }
+ if (!pollIsFree && AccountIdRole.RESTRICTED_VOTER != accountIdRole) {
+
+ // on none free poll, only restricted user can vote
+ return n_("pollen.security.error.poll.not.free.and.access.not.granted");
+ }
+ return null;
+ }
+
+ public boolean isCanVote(Poll poll,
+ String accountId,
+ AccountIdRole accountIdRole) {
+
+
Date now = serviceContext.getCurrentTime();
- boolean result;
- if (poll.getCreator().equals(accountEditable)) {
+ if (!poll.isRunning(now)) {
- // The creator user can't vote
- result = false;
- } else {
+ // poll is not running, can not vote
+ return false;
+ }
- // The poll must be running and account allowed for restricted poll
- result = poll.isRunning(now);
- if (poll.getPollType() != PollType.FREE) {
+ boolean pollIsFree = PollType.FREE == poll.getPollType();
- PersonToListDAO dao = getDAO(PersonToList.class);
- PersonToList personToList =
- dao.findByPollAndAccount(poll, accountEditable);
+ if (pollIsFree && poll.getCreator().getAccountId().equals(accountId)) {
- result &= personToList != null;
- }
+ // on free poll, only the creator (using his creatorId as accountId) can not vote
+ return false;
}
- return result;
+ if (!pollIsFree && AccountIdRole.RESTRICTED_VOTER != accountIdRole) {
+
+ // on none free poll, only restricted user can vote
+ return false;
+ }
+
+ // ok can vote
+ return true;
}
- public boolean isUpdateAllowed(Poll poll, String voteId,
- String accountId, UserAccount userConnected) {
+ public boolean isCanModifyVote(Poll poll, String voteId,
+ String accountId,
+ UserAccount userConnected) {
Date now = serviceContext.getCurrentTime();
- boolean result = false;
+ if (!poll.isRunning(now)) {
+ // poll is not running can not modify anything
+ return false;
+ }
+
+ if (poll.isAnonymous()) {
+
+ // poll is anonymous, no vote can be modify
+ return false;
+ }
+
Vote vote = poll.getVoteByTopiaId(voteId);
- // can only modify a vote if poll is running.
- if (vote != null && poll.isRunning(now)) {
- PollAccount votePollAccount = vote.getPollAccount();
+ if (vote == null) {
- // si le votant du vote correspond au votant actuel (pollAccountId)
- if (accountId != null
- && accountId.equals(votePollAccount.getAccountId())) {
- result = true;
+ // vote not found, can not modify it
+ return false;
+ }
+
+ PollAccount votePollAccount = vote.getPollAccount();
+
+ if (votePollAccount.getAccountId().equals(accountId)) {
+
+ // accountId is voteAccountId, can modifiy the vote
+ return true;
+ }
+
+ if (userConnected != null) {
+
+ if (userConnected.equals(votePollAccount.getUserAccount())) {
+
+ // user conntected is the voter
+ return true;
}
+ }
- // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
- if (userConnected != null) {
- UserAccount voteUserAccount = votePollAccount.getUserAccount();
- result = userConnected.equals(voteUserAccount);
+ // can not modify vote in other cases
+ return false;
+ }
+
+ public boolean isCanDeleteVote(Poll poll,
+ String voteId,
+ String accountId,
+ AccountIdRole accountIdRole,
+ UserAccount userConnected) {
+
+ Date now = serviceContext.getCurrentTime();
+
+ if (!poll.isRunning(now)) {
+
+ // poll is not running can not remove anything
+ return false;
+ }
+
+ if (poll.isAnonymous()) {
+
+ // poll is anonymous, no vote can be delete (?) FIXME Check this
+ return false;
+ }
+
+
+ Vote vote = poll.getVoteByTopiaId(voteId);
+
+ if (vote == null) {
+
+ // vote not found, can not delete it
+ return false;
+ }
+
+ if (accountIdRole == AccountIdRole.CREATOR) {
+
+ // poll admin can delete any vote
+ return true;
+ }
+
+ PollAccount votePollAccount = vote.getPollAccount();
+
+ if (votePollAccount.getAccountId().equals(accountId)) {
+
+ // owner of vote (linked by accountId) can delete his own vote
+ return true;
+ }
+
+ if (userConnected != null) {
+
+ if (userConnected.equals(votePollAccount.getUserAccount())) {
+
+ // owner of vote (linked by userAccount) can delete his own vote
+ return true;
}
}
- return result;
+
+ // can not modify vote in other cases
+ return false;
}
public boolean isCanDeleteComment(Comment comment,
- PollAccount pollAccount,
- UserAccount userAccount,
- boolean isPollCreator) {
+ String accountId,
+ AccountIdRole accountIdRole,
+ UserAccount userAccount) {
- boolean result = false;
+ if (accountIdRole == AccountIdRole.CREATOR) {
+ // poll admin can always delete comments
+ return true;
+ }
+
PollAccount commentAccount = comment.getPollAccount();
- if (isPollCreator) {
+ if (commentAccount.getAccountId().equals(accountId)) {
- // poll creator has admin rights on his poll
- result = true;
- } else if (userAccount != null) {
+ // owner of comment (linked by accountId) can delete his comment
+ return true;
+ }
- // loggued
- boolean isAdmin = userAccount.isAdministrator();
-// boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
+ if (userAccount != null) {
- // pollen admin or comment owner (linked by user account)
- result = isAdmin ||
- userAccount.equals(commentAccount.getUserAccount());
+ if (userAccount.equals(commentAccount.getUserAccount())) {
+ // owner of comment (linked by userAccount) can delete his comment
+ return true;
+ }
+ }
+ return false;
+ }
- } else if (pollAccount != null) {
+ private boolean isVoterAccountId(PollAccountDAO dao, PollUri uri) {
+ try {
- // comment owner (linked by poll account)
- result = pollAccount.equals(commentAccount);
+ return dao.existsByPollVoteAccountId(uri.getPollId(), uri.getAccountId());
+
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not check pollAccount existence from poll '" +
+ uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
}
- return result;
}
+ private boolean isRestrictPollAccountId(PollAccountDAO dao, PollUri uri) {
+ try {
+
+ PollAccount result =
+ dao.getRestrictedPollAccount(uri.getPollId(), uri.getAccountId());
+
+ return result != null;
+
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not check pollAccount existence from poll '" +
+ uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
+ }
+ }
+
+// /**
+// * Vote is allowed if {@code poll} is running and {@code pollAccount} is
+// * defined in the {@code poll} restricted list if it's not a {@link PollType#FREE}
+// * poll. The account must be defined previously using
+// * {@link PollService#getPollAccountEditable(String, UserAccount, Poll)} to
+// * have a proper link between userAccount and pollAccount even if not already
+// * created in dabase. The poll creator can't vote. The token is just use
+// * for moderate purpose.
+// *
+// * @param poll Poll
+// * @param accountEditable Account to check
+// * @return true if vote is allowed, false otherwise
+// */
+// public boolean isVoteAllowed(Poll poll, PollAccount accountEditable) {
+//
+// Preconditions.checkNotNull(poll);
+// Preconditions.checkNotNull(accountEditable);
+//
+// Date now = serviceContext.getCurrentTime();
+//
+// boolean result;
+// if (poll.getCreator().equals(accountEditable)) {
+//
+// // The creator user can't vote
+// result = false;
+// } else {
+//
+// // The poll must be running and account allowed for restricted poll
+// result = poll.isRunning(now);
+// if (poll.getPollType() != PollType.FREE) {
+//
+// PersonToListDAO dao = getDAO(PersonToList.class);
+// PersonToList personToList =
+// dao.findByPollAndAccount(poll, accountEditable);
+//
+// result &= personToList != null;
+// }
+// }
+// return result;
+// }
+
+// public boolean isUpdateAllowed(Poll poll, String voteId,
+// String accountId, UserAccount userConnected) {
+//
+// Date now = serviceContext.getCurrentTime();
+//
+// boolean result = false;
+//
+// Vote vote = poll.getVoteByTopiaId(voteId);
+//
+// // can only modify a vote if poll is running.
+// if (vote != null && poll.isRunning(now)) {
+// PollAccount votePollAccount = vote.getPollAccount();
+//
+// // si le votant du vote correspond au votant actuel (pollAccountId)
+// if (accountId != null
+// && accountId.equals(votePollAccount.getAccountId())) {
+// result = true;
+// }
+//
+// // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
+// if (userConnected != null) {
+// UserAccount voteUserAccount = votePollAccount.getUserAccount();
+// result = userConnected.equals(voteUserAccount);
+// }
+// }
+// return result;
+// }
+
+// public boolean isCanDeleteComment(Comment comment,
+// PollAccount pollAccount,
+// UserAccount userAccount,
+// boolean isPollCreator) {
+//
+// boolean result = false;
+//
+// PollAccount commentAccount = comment.getPollAccount();
+//
+// if (isPollCreator) {
+//
+// // poll creator has admin rights on his poll
+// result = true;
+// } else if (userAccount != null) {
+//
+// // loggued
+// boolean isAdmin = userAccount.isAdministrator();
+//// boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
+//
+// // pollen admin or comment owner (linked by user account)
+// result = isAdmin ||
+// userAccount.equals(commentAccount.getUserAccount());
+//
+// } else if (pollAccount != null) {
+//
+// // comment owner (linked by poll account)
+// result = pollAccount.equals(commentAccount);
+// }
+// return result;
+// }
+
}
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-18 07:58:19 UTC (rev 3505)
@@ -44,6 +44,8 @@
pollen.feed.updateVoteTitle=Vote modified for '%s'
pollen.info.admin.created=Super admin was created with login %1$s
pollen.info.admin.exists=Super admin already exists
+pollen.security.error.poll.free.creatorId.can.not.vote=Using a creator Id does not allow you to vote.
pollen.security.error.poll.not.closed.and.results.not.continuous=The poll is not closed and results are not continuous
pollen.security.error.poll.not.free.and.access.not.granted=You can not access to this non free poll
+pollen.security.error.poll.not.running.can.not.vote=You can not vote (poll is finished or not began).
pollen.security.error.poll.result.private.and.access.not.granted=Results of the poll are private and you do not have credentials to see them
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-18 07:58:19 UTC (rev 3505)
@@ -44,6 +44,8 @@
pollen.feed.updateVoteTitle=Vote modifié de '%s'
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
pollen.info.admin.exists=Le super admin existe déjà
+pollen.security.error.poll.free.creatorId.can.not.vote=L'utlisation du creatorId ne permet de voter.
pollen.security.error.poll.not.closed.and.results.not.continuous=Vous n'avez pas accès aux résultats de ce sondage (résultats non continus et sondage non fermé)
pollen.security.error.poll.not.free.and.access.not.granted=Vous n'avez pas accès à ce sondage restreint
+pollen.security.error.poll.not.running.can.not.vote=Vous n'êtes pas autorisé à voter (sondage terminé ou pas encore commencé).
pollen.security.error.poll.result.private.and.access.not.granted=Vous n'avez pas accès aux résultats privés de ce sondage
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -112,7 +112,7 @@
Set<String> result = Sets.newHashSet();
//TODO-tchemit-2012-06-03 Should use also pollAccountId (if specified in url)...
boolean canDelete = getSecurityService().isCanDeleteComment(
- comment, null, userAccount, false);
+ comment, null, null, userAccount);
if (canDelete) {
result.add("delete");
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ParameterAware;
+import org.apache.struts2.interceptor.ServletRequestAware;
import org.chorem.pollen.bean.PollResult;
import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Choice;
@@ -41,8 +42,11 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.impl.SecurityService;
import org.chorem.pollen.ui.actions.PageSkin;
+import org.chorem.pollen.ui.security.PollVoteAccessRequired;
+import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -54,7 +58,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.3
*/
-public abstract class AbstractVoteAction extends AbstractPollUriIdAction implements ParameterAware {
+public abstract class AbstractVoteAction extends AbstractPollUriIdAction implements ParameterAware, ServletRequestAware {
private static final long serialVersionUID = 1L;
@@ -141,6 +145,21 @@
*/
private Map<String, String[]> parameters;
+ /**
+ * The accountId role on this page.
+ *
+ * @since 1.4
+ */
+ private SecurityService.AccountIdRole accountIdRole;
+
+ /**
+ * The incoming request (some stuff are store in it from security filters).
+ *
+ * @since 1.4
+ */
+ private transient HttpServletRequest request;
+
+
@Override
public PageSkin getSkin() {
return PageSkin.VOTE;
@@ -151,6 +170,11 @@
this.parameters = parameters;
}
+ @Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+
public Poll getPoll() {
return poll;
}
@@ -300,15 +324,14 @@
// TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
votes = getVoteService().getAllVotes(poll);
- voteAllowed = !moderate && getSecurityService().isVoteAllowed(poll, pollAccount);
+ accountIdRole = (SecurityService.AccountIdRole)
+ request.getAttribute(PollVoteAccessRequired.ACCOUNT_ID_ROLE);
- if (voteAllowed) {
+ voteAllowed = !moderate &&
+ getSecurityService().isCanVote(poll,
+ getAccountId(),
+ accountIdRole);
- // can not vote if accountId from the url is the creator one
- voteAllowed = !poll.getCreator().getAccountId().equals(getUriId().getAccountId());
-
- }
-
// Current vote
if (voteAllowed) {
vote = getVoteService().getVoteEditable(poll, pollAccount);
@@ -319,18 +342,10 @@
feedFileExisting = getPollFeedService().isFeedExists(poll);
- PollAccount pollCreator = poll.getCreator();
- if (getPollenUserAccount() == null) {
+ creatorUser = getSecurityService().isPollCreator(poll,
+ getUriId(),
+ getPollenUserAccount());
- // User is creator if loaded pollAccount is the creator
- creatorUser = pollCreator.equals(pollAccount);
-
- } else {
-
- // User is creator if the userAccount is the same
- creatorUser = getPollenUserAccount().equals(pollCreator.getUserAccount());
- }
-
if (log.isInfoEnabled()) {
Date now = serviceContext.getCurrentTime();
log.info("pollChoiceOrVoteStarted = " + isPollChoiceOrVoteStarted());
@@ -375,8 +390,8 @@
return result;
}
- public boolean isModifAllowed(Vote vote) {
- return getSecurityService().isUpdateAllowed(
+ public boolean isModifyVoteAllowed(Vote vote) {
+ return getSecurityService().isCanModifyVote(
getPoll(),
vote.getTopiaId(),
getAccountId(),
@@ -390,14 +405,20 @@
public boolean isDeleteCommentAllowed(Comment comment) {
return getSecurityService().isCanDeleteComment(
comment,
- getPollAccount(),
- getPollenUserAccount(),
- isCreatorUser());
+ getUriId().getAccountId(),
+ accountIdRole,
+ getPollenUserAccount());
}
public boolean isDeleteVoteAllowed(Vote vote) {
- // can delete a vote if admin or poll creator
- return isUserAdmin() || isCreatorUser();
+ return getSecurityService().isCanDeleteVote(
+ getPoll(),
+ vote.getTopiaId(),
+ getUriId().getAccountId(),
+ accountIdRole,
+ getPollenUserAccount());
+// // can delete a vote if admin or poll creator
+// return isUserAdmin() || isCreatorUser();
}
public String escapeLineBreak(String text) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -83,7 +83,7 @@
}
public boolean isCanShowResult() {
- String errorMessage = getSecurityService().isCanShowResult(
+ String errorMessage = getSecurityService().isCanAccessResult(
poll, SecurityService.AccountIdRole.CREATOR);
return errorMessage == null;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -31,12 +31,12 @@
import org.apache.shiro.web.util.WebUtils;
import org.chorem.pollen.PollenApplicationContext;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.DefaultPollenServiceContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.PollenServiceFactory;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.SecurityService;
+import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.PollenSession;
import org.chorem.pollen.ui.PollenUIUtils;
import org.nuiton.topia.TopiaContext;
@@ -107,20 +107,62 @@
return result;
}
- protected SecurityService getSecurityService(ServletRequest request) {
- PollenServiceContext serviceContext = getServiceContext(request);
-
- SecurityService securityService =
- serviceContext.newService(SecurityService.class);
- return securityService;
- }
-
protected UserAccount getPollenUserAccount(ServletRequest request) {
PollenSession pollenSession = PollenSession.get(request);
return pollenSession.getUserAccount();
}
+ protected Poll getPollIdSane(PollUri pollUri,
+ PollenServiceContext serviceContext,
+ ServletRequest request) {
+
+ Poll poll = null;
+ String errorMessage = null;
+ if (pollUri == null) {
+
+ // no pollUri in url
+ errorMessage = n_("pollen.security.error.no.pollId");
+
+ } else {
+
+ if (!pollUri.isPollIdNotBlank()) {
+
+ // no pollId in uri
+ errorMessage = n_("pollen.security.error.no.pollId");
+ } else {
+
+ // there is a pollId check that it exists
+
+ PollService pollService =
+ serviceContext.newService(PollService.class);
+
+ poll = pollService.getPollByPollId(pollUri.getPollId());
+
+ if (poll == null) {
+
+ // poll not found
+ errorMessage = n_("pollen.security.error.poll.not.found");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Can access to this poll " +
+ pollUri.getPollId());
+ }
+
+ }
+ }
+
+ if (errorMessage != null) {
+
+ // something wrong happens
+ poll = null;
+ registerError(request, errorMessage);
+ }
+
+ return poll;
+ }
+
protected PollenServiceContext getServiceContext(ServletRequest request) {
PollenApplicationContext applicationContext =
PollenApplicationContext.get(getServletContext());
@@ -152,7 +194,6 @@
Map<String, String> params = Maps.newHashMap();
params.put("errorMessage", attribute);
WebUtils.issueRedirect(request, response, unauthorizedUrl, params);
-// request.removeAttribute(ERROR_MESSAGE_PARAMETER);
} else {
@@ -164,61 +205,6 @@
return false;
}
- protected boolean isPollIdSane(PollUri pollUri,
- SecurityService securityService,
- ServletRequest request) {
-
- String errorMessage = null;
- if (pollUri == null) {
-
- // no pollUri in url
- errorMessage = n_("pollen.security.error.no.pollId");
-
- } else {
-
- if (!pollUri.isPollIdNotBlank()) {
-
- // no pollId in uri
- errorMessage = n_("pollen.security.error.no.pollId");
- } else {
-
- // there is a pollId check that it exists
-
- try {
- securityService.checkPoll(pollUri);
-
- if (log.isDebugEnabled()) {
- log.debug("Can access to this poll " +
- pollUri.getPollId());
- }
-
- } catch (PollNotFoundException e) {
- if (log.isDebugEnabled()) {
- log.debug("Poll not found!");
- }
- errorMessage = n_("pollen.security.error.poll.not.found");
- }
- }
- }
- boolean isAccessAllowed;
-
- if (errorMessage == null) {
-
- // no error message seems ok
- isAccessAllowed = true;
-
- } else {
-
- // something wrong happens
- isAccessAllowed = false;
-
- registerError(request, errorMessage);
- }
-
- return isAccessAllowed;
- }
-
-
protected void registerError(ServletRequest request, String errorMessage) {
request.setAttribute(ERROR_MESSAGE_PARAMETER, errorMessage);
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -26,7 +26,6 @@
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.SecurityService;
import javax.servlet.ServletRequest;
@@ -60,9 +59,11 @@
SecurityService securityService =
serviceContext.newService(SecurityService.class);
- // test that poll is sane
- boolean isAccessAllowed = isPollIdSane(pollUri, securityService, request);
+ // get sane poll
+ Poll poll = getPollIdSane(pollUri, serviceContext, request);
+ boolean isAccessAllowed = poll != null;
+
SecurityService.AccountIdRole accountIdRole =
SecurityService.AccountIdRole.UNDEFINED;
@@ -70,10 +71,6 @@
// pollId is sane (poll exists from it)
- // get it
- Poll poll = serviceContext.newService(PollService.class).getPollByPollId(
- pollUri.getPollId());
-
// test if user is admin
boolean isAdmin = adminFilter.isAccessAllowed(request,
response,
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -25,7 +25,6 @@
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.SecurityService;
import javax.servlet.ServletRequest;
@@ -59,21 +58,16 @@
SecurityService securityService =
serviceContext.newService(SecurityService.class);
- // test that poll is sane
- boolean isAccessAllowed = isPollIdSane(pollUri, securityService, request);
+ // get sane poll
+ Poll poll = getPollIdSane(pollUri, serviceContext, request);
- Poll poll = null;
+ boolean isAccessAllowed = poll != null;
SecurityService.AccountIdRole accountIdRole = null;
if (isAccessAllowed) {
// pollId is sane (poll exists from it)
-
- // get it
- poll = serviceContext.newService(PollService.class).getPollByPollId(
- pollUri.getPollId());
-
// test if user is admin
boolean isAdmin = adminFilter.isAccessAllowed(request,
@@ -109,11 +103,11 @@
if (isAccessAllowed) {
// pollId is sane
- // accountId also
+ // accountId is sane
// check now poll results can be displayed
- String errorMessage = securityService.isCanShowResult(
+ String errorMessage = securityService.isCanAccessResult(
poll, accountIdRole);
if (errorMessage != null) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -24,9 +24,7 @@
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.SecurityService;
import javax.servlet.ServletRequest;
@@ -42,6 +40,8 @@
*/
public class PollVoteAccessRequired extends AbstractPollenAuthorization {
+ public static final String ACCOUNT_ID_ROLE = "accountIdRole";
+
protected final AdminUserRequired adminFilter;
public PollVoteAccessRequired() {
@@ -60,11 +60,10 @@
SecurityService securityService =
serviceContext.newService(SecurityService.class);
- // test that poll is sane
- boolean isAccessAllowed = isPollIdSane(pollUri, securityService,
- request);
+ // get sane poll
+ final Poll poll = getPollIdSane(pollUri, serviceContext, request);
- Poll poll = null;
+ boolean isAccessAllowed = poll != null;
SecurityService.AccountIdRole accountIdRole = null;
@@ -72,10 +71,6 @@
// pollId is sane (poll exists from it)
- // get it
- poll = serviceContext.newService(PollService.class).getPollByPollId(
- pollUri.getPollId());
-
// test if user is admin
boolean isAdmin = adminFilter.isAccessAllowed(request,
response,
@@ -93,9 +88,8 @@
// bad account Id
isAccessAllowed = false;
- registerError(
- request,
- n_("pollen.security.error.bad.accountId"));
+ registerError(request,
+ n_("pollen.security.error.bad.accountId"));
}
}
@@ -109,23 +103,27 @@
if (isAccessAllowed) {
// pollId is sane
- // accountId also
+ // accountId is sane
// check now poll votes can be displayed
- boolean pollIsFree = PollType.FREE == poll.getPollType();
+ String errorMessage = securityService.isCanAccessVote(
+ poll, pollUri.getAccountId(), accountIdRole);
- if (!pollIsFree &&
- !SecurityService.NONE_FREE_ACCOUNT_ID_ROLES.contains(accountIdRole)) {
+ if (errorMessage != null) {
- // on none free poll, only creator or restricted user can have it
+ // can not vote
isAccessAllowed = false;
- registerError(
- request,
- n_("pollen.security.error.poll.not.free.and.access.not.granted"));
+ registerError(request, errorMessage);
}
}
+ if (isAccessAllowed) {
+
+ // store accountIdRole in request
+ request.setAttribute(ACCOUNT_ID_ROLE, accountIdRole);
+ }
+
return isAccessAllowed;
}
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 07:58:19 UTC (rev 3505)
@@ -93,7 +93,7 @@
$votingIdField.attr('disabled', $anonymousField.prop('checked'));
- $anonymousField.change(function() {
+ $anonymousField.change(function () {
$votingIdField.attr('disabled', $(this).prop('checked'));
});
@@ -232,8 +232,7 @@
<s:if test="imageType">
<s:iterator value="poll.choice" var="choice">
<s:if test="!isChoiceHidden(#choice)">
- <s:url id="imageUrl" namespace="/io"
- action="getPollChoiceImage"
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
escapeAmp="false">
<s:param name="choiceId" value="name"/>
<s:param name="pollId" value="poll.pollId"/>
@@ -277,28 +276,24 @@
<s:if test="!isChoiceHidden(#choice)">
<th>
<s:if test="normalVoteCounting">
- <s:checkbox
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- theme="simple"/>
+ <s:checkbox theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
<s:if test="percentageVoteCounting">
- <s:textfield
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- required="true" size="3" theme="simple"/>
+ <s:textfield required="true" size="3" theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
<s:if test="condorcetVoteCounting">
- <s:textfield
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- id="condorcetInput" size="3" theme="simple"/>
+ <s:textfield id="condorcetInput" size="3" theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
<s:if test="numberVoteCounting">
- <s:textfield
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- size="3" theme="simple"/>
+ <s:textfield size="3" theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
</th>
</s:if>
@@ -320,7 +315,7 @@
</s:else>
</s:if>
<s:if test="!poll.anonymous">
- <s:if test="isModifAllowed(#vote)">
+ <s:if test="isModifyVoteAllowed(#vote)">
<s:a action="editVote" namespace="/poll">
<s:param name="pollId" value="%{pollId}"/>
<s:param name="accountId" value="%{#vote.pollAccount.accountId}"/>
@@ -418,7 +413,8 @@
<s:if test="voteAllowed">
<div id="buttons">
<s:if test="poll.anonymousVoteAllowed">
- <s:checkbox key="vote.anonymous" label='%{getText("pollen.common.voteAnonymous")}'/>
+ <s:checkbox key="vote.anonymous"
+ label='%{getText("pollen.common.voteAnonymous")}'/>
<br/>
</s:if>
<s:submit action="vote/%{uriId}" key="pollen.action.pollVote"
@@ -457,9 +453,10 @@
<s:textarea cols="36" key="choice.description"
label="%{getText('pollen.common.description')}"/>
<br/>
+
<div class="cleanBoth">
- <s:submit action="addChoice/%{uriId}" key="pollen.action.addChoice"
- align="center"/>
+ <s:submit action="addChoice/%{uriId}" key="pollen.action.addChoice"
+ align="center"/>
</div>
</s:form>
</div>
@@ -470,7 +467,7 @@
<div id="commentZone">
- <%--Show paginated comments--%>
+ <%--Show paginated comments--%>
<%@include file="displayPollComments.jsp" %>
<div id="commentFormDiv">
1
0
r3504 - in trunk/pollen-ui-struts2/src/main/webapp/WEB-INF: decorators jsp
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:55:12 +0200 (Mon, 18 Jun 2012)
New Revision: 3504
Url: http://chorem.org/repositories/revision/pollen/3504
Log:
refs #618: Stay on same url for poll form
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-06-18 07:54:54 UTC (rev 3503)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-06-18 07:55:12 UTC (rev 3504)
@@ -190,7 +190,7 @@
<div class="top_left${pageLogo}"></div>
<ul class="top_middle${pageLogo}">
<li>
- <s:a action="create" namespace="/poll" method="input">
+ <s:a action="create" namespace="/poll">
<s:text name="pollen.menu.createPoll"/>
</s:a>
</li>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp 2012-06-18 07:54:54 UTC (rev 3503)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp 2012-06-18 07:55:12 UTC (rev 3504)
@@ -31,7 +31,7 @@
</div>
<div class="center">
- <s:a action="create" namespace="/poll" method="input">
+ <s:a action="create" namespace="/poll">
<img src="<s:url value='/img/smallCreation_%{safeLanguage}.png' />" alt="poll creation"/>
</s:a>
<img src="<s:url value='/img/smallVote_%{safeLanguage}.png' />" alt="vote"/>
1
0
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:54:54 +0200 (Mon, 18 Jun 2012)
New Revision: 3503
Url: http://chorem.org/repositories/revision/pollen/3503
Log:
refs #618: Stay on same url for poll form
Modified:
trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-06-18 07:54:19 UTC (rev 3502)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-06-18 07:54:54 UTC (rev 3503)
@@ -40,7 +40,8 @@
</result-types>
<!-- create poll -->
- <action name="create" class="org.chorem.pollen.ui.actions.poll.CreatePoll">
+ <action name="create" class="org.chorem.pollen.ui.actions.poll.CreatePoll"
+ method="execute">
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
<result type="pollenRedirectAction">
<param name="namespace">/poll</param>
@@ -49,7 +50,8 @@
</action>
<!-- edit poll -->
- <action name="edit/*" class="org.chorem.pollen.ui.actions.poll.EditPoll">
+ <action name="edit/*" class="org.chorem.pollen.ui.actions.poll.EditPoll"
+ method="execute">
<param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
<result type="pollenRedirectAction">
@@ -59,7 +61,8 @@
</action>
<!-- clone poll -->
- <action name="clone/*" class="org.chorem.pollen.ui.actions.poll.ClonePoll">
+ <action name="clone/*" class="org.chorem.pollen.ui.actions.poll.ClonePoll"
+ method="execute">
<param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
<result type="pollenRedirectAction">
1
0
r3502 - trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:54:19 +0200 (Mon, 18 Jun 2012)
New Revision: 3502
Url: http://chorem.org/repositories/revision/pollen/3502
Log:
refs #618: Stay on same url for poll form
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-17 13:23:21 UTC (rev 3501)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-18 07:54:19 UTC (rev 3502)
@@ -37,6 +37,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ParameterAware;
+import org.apache.struts2.interceptor.ServletRequestAware;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
import org.chorem.pollen.bean.PollUri;
@@ -65,6 +66,7 @@
import org.chorem.pollen.ui.converters.DateConverter;
import org.nuiton.util.StringUtil;
+import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -82,7 +84,7 @@
* @author fdesbois <desbois(a)codelutin.com>
* $Id$
*/
-public abstract class AbstractPollForm extends PollenActionSupport implements Preparable, ParameterAware, FileUploadAware {
+public abstract class AbstractPollForm extends PollenActionSupport implements Preparable, ParameterAware, FileUploadAware, ServletRequestAware {
private static final long serialVersionUID = 1L;
@@ -188,6 +190,13 @@
private PollUri pollUri;
+ /**
+ * The incoming request (some stuff are store in it from security filters).
+ *
+ * @since 1.4
+ */
+ private transient HttpServletRequest request;
+
public abstract boolean isClone();
protected abstract Poll savePoll(Poll poll) throws PollNotFoundException;
@@ -195,82 +204,86 @@
public abstract boolean isEdit();
@Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+
+ @Override
public void prepare() throws Exception {
prepareFormPage();
- if (parameters.containsKey("poll.title")) {
+ if (isGetMethod()) {
- if (log.isInfoEnabled()) {
- log.info("Starts prepare form...");
- }
+ // do not prepare when coming as GET
+ return;
+ }
- // we are after a submit
+ // we are after a submit
- String pollUid = getNonEmptyParameterValue("poll.pollId");
- String userId = getNonEmptyParameterValue("userId");
- if (StringUtils.isBlank(userId)) {
+ String pollUid = getNonEmptyParameterValue("poll.pollId");
+ String userId = getNonEmptyParameterValue("userId");
+ if (StringUtils.isBlank(userId)) {
- // try to take the one from current user
- UserAccount userAccount = getPollenUserAccount();
- if (userAccount != null) {
- userId = userAccount.getTopiaId();
- }
+ // try to take the one from current user
+ UserAccount userAccount = getPollenUserAccount();
+ if (userAccount != null) {
+ userId = userAccount.getTopiaId();
}
- UserAccount userAccount = null;
- if (StringUtils.isNotBlank(userId)) {
- // load use account to use
- userAccount = getPollService().getEntityById(
- UserAccount.class, userId);
- }
+ }
+ UserAccount userAccount = null;
+ if (StringUtils.isNotBlank(userId)) {
+ // load use account to use
+ userAccount = getPollService().getEntityById(
+ UserAccount.class, userId);
+ }
- // get a copy (or a fresh new poll)
- poll = getPollService().getPollEditable(pollUid, userAccount, false);
+ // get a copy (or a fresh new poll)
+ poll = getPollService().getPollEditable(pollUid, userAccount, false);
- // If vote is started, prepare choices and votingLists is useless
- // because they can't be updated.
- if (!isVoteStarted()) {
+ // 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);
+ // 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
+ // build poll choices
- switch (pollChoiceType) {
+ switch (pollChoiceType) {
- case TEXT:
- choices = buildTextChoices();
- break;
- case DATE:
- choices = buildDateChoices();
- break;
- case IMAGE:
- choices = buildImageChoices();
- break;
- }
- PollType pollType;
- String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
- pollType = PollType.valueOf(pollTypeParam);
- switch (pollType) {
+ case TEXT:
+ choices = buildTextChoices();
+ break;
+ case DATE:
+ choices = buildDateChoices();
+ break;
+ case IMAGE:
+ choices = buildImageChoices();
+ break;
+ }
+ PollType pollType;
+ String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
+ pollType = PollType.valueOf(pollTypeParam);
+ switch (pollType) {
- case FREE:
+ case FREE:
- // empty voting list
- votingLists = Maps.newTreeMap();
- break;
- case RESTRICTED:
+ // empty voting list
+ votingLists = Maps.newTreeMap();
+ break;
+ case RESTRICTED:
- // restricted voting list
- votingLists = buildVotingLists(pollType);
- break;
- case GROUP:
+ // restricted voting list
+ votingLists = buildVotingLists(pollType);
+ break;
+ case GROUP:
- // group voting lists
- votingLists = buildVotingLists(pollType);
- break;
- }
+ // group voting lists
+ votingLists = buildVotingLists(pollType);
+ break;
}
}
}
@@ -278,8 +291,6 @@
@Override
public String input() throws Exception {
- prepareFormPage();
-
UserAccount userAccount = getPollenUserAccount();
String pollUid = pollUri == null ? null : pollUri.getPollId();
PollService service = getPollService();
@@ -413,6 +424,12 @@
@InputConfig(methodName = "inputAfterValidationError")
public String execute() throws Exception {
+ if (isGetMethod()) {
+
+ // input method
+ return input();
+ }
+
// Save choices and votingLists only if vote is not started
if (!isVoteStarted()) {
//TODO-tchemit comment me 2012-06-04 A merge would be nicer but more complex to code
@@ -489,9 +506,18 @@
return SUCCESS;
}
+ protected boolean isGetMethod() {
+ return "GET".equalsIgnoreCase(request.getMethod());
+ }
+
@Override
public void validate() {
+ if (isGetMethod()) {
+
+ // input method
+ return;
+ }
validateInformations();
validateOptions();
1
0
r3501 - trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 17 Jun '12
by tchemit@users.chorem.org 17 Jun '12
17 Jun '12
Author: tchemit
Date: 2012-06-17 15:23:21 +0200 (Sun, 17 Jun 2012)
New Revision: 3501
Url: http://chorem.org/repositories/revision/pollen/3501
Log:
fix svn properties = header
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java 2012-06-17 13:22:40 UTC (rev 3500)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java 2012-06-17 13:23:21 UTC (rev 3501)
@@ -1,8 +1,8 @@
/*
* #%L
* Pollen :: UI (struts2)
- * $Id: SavePoll.java 3467 2012-06-13 15:57:49Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/main/java/org/… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
* %%
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java 2012-06-17 13:22:40 UTC (rev 3500)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java 2012-06-17 13:23:21 UTC (rev 3501)
@@ -1,8 +1,8 @@
/*
* #%L
* Pollen :: UI (struts2)
- * $Id: SavePoll.java 3467 2012-06-13 15:57:49Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/main/java/org/… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
* %%
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r3500 - trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 17 Jun '12
by tchemit@users.chorem.org 17 Jun '12
17 Jun '12
Author: tchemit
Date: 2012-06-17 15:22:40 +0200 (Sun, 17 Jun 2012)
New Revision: 3500
Url: http://chorem.org/repositories/revision/pollen/3500
Log:
fix struts form submit
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp 2012-06-17 13:12:38 UTC (rev 3499)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollChoice.jsp 2012-06-17 13:22:40 UTC (rev 3500)
@@ -24,7 +24,7 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<br/>
-<s:form method="POST" namespace="/poll" action="deleteChoice">
+<s:form method="POST" namespace="/poll">
<s:hidden key="uriId" label=''/>
<s:hidden key="choiceId" value="%{choice.topiaId}" label=''/>
@@ -40,6 +40,6 @@
<div align="right">
<s:submit onclick="return closeConfirmDialog();" theme="simple"
key="pollen.action.cancel"/>
- <s:submit key="pollen.action.delete" theme="simple"/>
+ <s:submit key="pollen.action.delete" theme="simple" action="deleteChoice"/>
</div>
</s:form>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-06-17 13:12:38 UTC (rev 3499)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollComment.jsp 2012-06-17 13:22:40 UTC (rev 3500)
@@ -23,7 +23,7 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<br/>
-<s:form method="POST" namespace="/poll" action="deleteComment">
+<s:form method="POST" namespace="/poll">
<s:hidden name="uriId" value='%{uriId}'/>
<s:hidden name="commentId" value='%{comment.topiaId}'/>
@@ -45,6 +45,6 @@
<div align="right">
<s:submit onclick="return closeConfirmDialog();" theme="simple"
key="pollen.action.cancel"/>
- <s:submit key="pollen.action.delete" theme="simple"/>
+ <s:submit key="pollen.action.delete" theme="simple" action="deleteComment"/>
</div>
</s:form>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-06-17 13:12:38 UTC (rev 3499)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/confirmDeletePollVote.jsp 2012-06-17 13:22:40 UTC (rev 3500)
@@ -23,7 +23,7 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<br/>
-<s:form method="POST" namespace="/poll" action="deleteVote">
+<s:form method="POST" namespace="/poll">
<s:hidden key="uriId" label=''/>
<s:hidden key="voteId" value="%{vote.topiaId}" label=''/>
@@ -42,6 +42,6 @@
<div align="right">
<s:submit onclick="return closeConfirmDialog();" theme="simple"
key="pollen.action.cancel"/>
- <s:submit key="pollen.action.delete" theme="simple"/>
+ <s:submit key="pollen.action.delete" theme="simple" action="deleteVote"/>
</div>
</s:form>
1
0
r3499 - in trunk: . pollen-persistence pollen-persistence/src/main/java/org/chorem/pollen/business/persistence pollen-persistence/src/test/java/org/chorem/pollen/business/persistence
by tchemit@users.chorem.org 17 Jun '12
by tchemit@users.chorem.org 17 Jun '12
17 Jun '12
Author: tchemit
Date: 2012-06-17 15:12:38 +0200 (Sun, 17 Jun 2012)
New Revision: 3499
Url: http://chorem.org/repositories/revision/pollen/3499
Log:
- fixes #615: Cannot add choices if no begin date is set
- improve some code
- add tests on Poll
Added:
trunk/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollTest.java
Modified:
trunk/pollen-persistence/pom.xml
trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java
trunk/pom.xml
Modified: trunk/pollen-persistence/pom.xml
===================================================================
--- trunk/pollen-persistence/pom.xml 2012-06-16 21:57:35 UTC (rev 3498)
+++ trunk/pollen-persistence/pom.xml 2012-06-17 13:12:38 UTC (rev 3499)
@@ -61,7 +61,13 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java 2012-06-16 21:57:35 UTC (rev 3498)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollImpl.java 2012-06-17 13:12:38 UTC (rev 3499)
@@ -116,7 +116,9 @@
@Override
public boolean isRunning(Date currentDate) {
- return !isClosed() && isStarted(currentDate) && !isFinished(currentDate);
+ return !isClosed() &&
+ isStarted(currentDate) &&
+ !isFinished(currentDate);
}
@Override
@@ -126,52 +128,62 @@
@Override
public boolean isAddChoiceStarted(Date currentDate) {
- return choiceAddAllowed && (beginChoiceDate == null || beginChoiceDate.before(currentDate));
+ return isChoiceAddAllowed() &&
+ (beginChoiceDate == null || beginChoiceDate.before(currentDate));
}
@Override
public boolean isAddChoiceRunning(Date currentDate) {
- return !isClosed() && !isFinished(currentDate) && isAddChoiceStarted(currentDate) && !isAddChoiceFinished(currentDate);
+ return isChoiceAddAllowed() &&
+ !isClosed() &&
+ !isFinished(currentDate) &&
+ isAddChoiceStarted(currentDate) &&
+ !isAddChoiceFinished(currentDate);
}
@Override
public boolean isAddChoiceFinished(Date currentDate) {
- return !choiceAddAllowed || (endChoiceDate != null && endChoiceDate.after(currentDate));
+ return !isChoiceAddAllowed() ||
+ (endChoiceDate != null && endChoiceDate.before(currentDate));
}
@Override
public PreventRule getPreventRuleByScope(String scope) {
Preconditions.checkNotNull(scope);
+ PreventRule rule = null;
for (PreventRule value : getPreventRule()) {
if (scope.equals(value.getScope())) {
- return value;
+ rule = value;
+ break;
}
}
- return null;
+ return rule;
}
@Override
public PersonToList getPersonToListByVote(Vote vote) {
Preconditions.checkNotNull(vote);
- PersonToList result;
+ PollAccount pollAccount = vote.getPollAccount();
+
+ PersonToList personToList = null;
for (VotingList votingList : getVotingList()) {
- result = votingList.getPollAccountPersonToList(vote.getPollAccount());
+ personToList = votingList.getPollAccountPersonToList(pollAccount);
- if (result != null) {
- return result;
+ if (personToList != null) {
+ break;
}
}
- return null;
+ return personToList;
}
@Override
public List<PollAccount> getPollAccounts(boolean withNoVote) {
- List<PollAccount> result = Lists.newLinkedList();
+ List<PollAccount> pollAccounts = Lists.newLinkedList();
for (VotingList votingList : getVotingList()) {
@@ -183,7 +195,7 @@
continue;
}
- result.add(personToList.getPollAccount());
+ pollAccounts.add(personToList.getPollAccount());
//
// if (!withNoVote || !personToList.isHasVoted()) {
//
@@ -191,7 +203,7 @@
// }
}
}
- return result;
+ return pollAccounts;
}
} //PollImpl
Added: trunk/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollTest.java
===================================================================
--- trunk/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollTest.java (rev 0)
+++ trunk/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollTest.java 2012-06-17 13:12:38 UTC (rev 3499)
@@ -0,0 +1,385 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.business.persistence;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.nuiton.util.DateUtil;
+
+import java.util.Date;
+
+/**
+ * Tests the {@link PollImpl} methods.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class PollTest {
+
+ Date yesterday() {
+ return DateUtil.createDate(1, 1, 2012);
+ }
+
+ Date today() {
+ return DateUtil.createDate(2, 1, 2012);
+ }
+
+ Date tomorrow() {
+ return DateUtil.createDate(3, 1, 2012);
+ }
+
+ @Test
+ public void testIsStarted() throws Exception {
+
+ Poll poll = new PollImpl();
+
+ // no begin date, started
+ Assert.assertTrue(poll.isStarted(today()));
+
+ // begin date yesterday, started
+ poll.setBeginDate(yesterday());
+ Assert.assertTrue(poll.isStarted(today()));
+
+ // begin date tomorrow, not started
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isStarted(today()));
+ }
+
+ @Test
+ public void testIsFinished() throws Exception {
+
+ Poll poll = new PollImpl();
+
+ // no end date, not finished
+ Assert.assertFalse(poll.isFinished(today()));
+
+ // end date tomorrow, not finished
+ poll.setEndDate(tomorrow());
+ Assert.assertFalse(poll.isFinished(today()));
+
+ // end date yesterday, not finished
+ poll.setEndDate(yesterday());
+ Assert.assertTrue(poll.isFinished(today()));
+ }
+
+ @Test
+ public void testIsAddChoiceStarted() throws Exception {
+
+ Poll poll = new PollImpl();
+
+ // -- no choiceAddAllowed -- //
+
+ // no choiceAddAllowed, not choice started
+ Assert.assertFalse(poll.isAddChoiceStarted(today()));
+
+ // begin add choice yesterday, no choiceAddAllowed, not choice started
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertFalse(poll.isAddChoiceStarted(today()));
+
+ // begin add choice tomorrow, no choiceAddAllowed, not choice started
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceStarted(today()));
+
+ // -- choiceAddAllowed -- //
+
+ poll.setChoiceAddAllowed(true);
+
+ // no begin choice date, started
+ poll.setBeginChoiceDate(null);
+ Assert.assertTrue(poll.isAddChoiceStarted(today()));
+
+ // begin add choice yesterday, started
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertTrue(poll.isAddChoiceStarted(today()));
+
+ // begin add choice tomorrow, not started
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceStarted(today()));
+ }
+
+ @Test
+ public void testIsAddChoiceFinished() throws Exception {
+
+ Poll poll = new PollImpl();
+
+ // -- no choiceAddAllowed -- //
+
+ // no choiceAddAllowed, add choice finished
+ Assert.assertTrue(poll.isAddChoiceFinished(today()));
+
+ // no end choice date, no choiceAddAllowed, add choice finished
+ Assert.assertTrue(poll.isAddChoiceFinished(today()));
+
+ // end add choice tomorrow, no choiceAddAllowed, add choice finished
+ poll.setEndChoiceDate(tomorrow());
+ Assert.assertTrue(poll.isAddChoiceFinished(today()));
+
+ // end add choice yesterday, no choiceAddAllowed, add choice finished
+ poll.setEndChoiceDate(yesterday());
+ Assert.assertTrue(poll.isAddChoiceFinished(today()));
+
+ // -- choiceAddAllowed -- //
+ poll.setChoiceAddAllowed(true);
+
+ // no end choice date, not finished
+ poll.setEndChoiceDate(null);
+ Assert.assertFalse(poll.isAddChoiceFinished(today()));
+
+ // end add choice tomorrow, not finished
+ poll.setEndChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceFinished(today()));
+
+ // end add choice yesterday, finished
+ poll.setEndChoiceDate(yesterday());
+ Assert.assertTrue(poll.isAddChoiceFinished(today()));
+ }
+
+ @Test
+ public void testIsRunning() throws Exception {
+
+ Poll poll = new PollImpl();
+
+ // -- closed -- //
+ // -- closed -- //
+ // -- closed -- //
+
+ // closed, not running
+ poll.setClosed(true);
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // -- No end date -- //
+
+ // no begin date, no end date, closed, not running
+ poll.setBeginDate(null);
+ poll.setEndDate(null);
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date yesterday, no end date, closed, not running
+ poll.setBeginDate(yesterday());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date tomorrow, no end date, closed, not running
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // -- end date yesterday -- //
+
+ poll.setBeginDate(null);
+ poll.setEndDate(yesterday());
+
+ // no begin date, end date yesterday, closed, not running
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date yesterday, end date yesterday, closed, not running
+ poll.setBeginDate(yesterday());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date tomorrow, end date yesterday, closed, not running
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // -- end date tomorrow -- //
+
+ poll.setBeginDate(null);
+ poll.setEndDate(tomorrow());
+
+ // no begin date, end date tomorrow, running
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date yesterday, end date tomorrow, running
+ poll.setBeginDate(yesterday());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date tomorrow, end date tomorrow, not running (not started)
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // -- not closed -- //
+ // -- not closed -- //
+ // -- not closed -- //
+
+ poll.setClosed(false);
+
+ // must be started but not finished
+
+ // -- No end date -- //
+
+ // no begin date, no end date, running
+ poll.setBeginDate(null);
+ poll.setEndDate(null);
+ Assert.assertTrue(poll.isRunning(today()));
+
+ // begin date yesterday, no end date, running
+ poll.setBeginDate(yesterday());
+ Assert.assertTrue(poll.isRunning(today()));
+
+ // begin date tomorrow, no end date, not running (not started)
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // -- end date yesterday -- //
+
+ poll.setBeginDate(null);
+ poll.setEndDate(yesterday());
+
+ // no begin date, end date yesterday, not running (finished)
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date yesterday, end date yesterday, not running (finished)
+ poll.setBeginDate(yesterday());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // begin date tomorrow, end date yesterday, not running (finished)
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isRunning(today()));
+
+ // -- end date tomorrow -- //
+
+ poll.setBeginDate(null);
+ poll.setEndDate(tomorrow());
+
+ // no begin date, end date tomorrow, running
+ Assert.assertTrue(poll.isRunning(today()));
+
+ // begin date yesterday, end date tomorrow, running
+ poll.setBeginDate(yesterday());
+ Assert.assertTrue(poll.isRunning(today()));
+
+ // begin date tomorrow, end date tomorrow, not running (not started)
+ poll.setBeginDate(tomorrow());
+ Assert.assertFalse(poll.isRunning(today()));
+ }
+
+ @Test
+ public void testIsAddChoiceRunning() throws Exception {
+
+ // says that poll is not closed and is not finished
+ // only begin choice date and end choice date have a meaning
+
+ PollImpl poll = Mockito.mock(PollImpl.class);
+ Mockito.when(poll.isClosed()).thenReturn(false);
+ Mockito.when(poll.isFinished(Mockito.any(Date.class))).thenReturn(false);
+
+ Mockito.when(poll.isChoiceAddAllowed()).thenCallRealMethod();
+ Mockito.when(poll.isAddChoiceRunning(Mockito.any(Date.class))).thenCallRealMethod();
+ Mockito.when(poll.isAddChoiceStarted(Mockito.any(Date.class))).thenCallRealMethod();
+ Mockito.when(poll.isAddChoiceFinished(Mockito.any(Date.class))).thenCallRealMethod();
+
+ Mockito.doCallRealMethod().when(poll).setChoiceAddAllowed(Mockito.anyBoolean());
+ Mockito.doCallRealMethod().when(poll).setBeginChoiceDate(Mockito.any(Date.class));
+ Mockito.doCallRealMethod().when(poll).setEndChoiceDate(Mockito.any(Date.class));
+
+ // -- choiceAddAllowed -- //
+ // -- choiceAddAllowed -- //
+ // -- choiceAddAllowed -- //
+
+ poll.setChoiceAddAllowed(true);
+
+ // -- no end choice date (choice not finished) -- //
+
+ poll.setEndChoiceDate(null);
+
+ // no begin date (choice running)
+ poll.setBeginChoiceDate(null);
+ Assert.assertTrue(poll.isAddChoiceRunning(today()));
+
+ // begin date yesterday (choice running)
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertTrue(poll.isAddChoiceRunning(today()));
+
+ // begin date tomorrow (choice not running)
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ // -- end choice date yesterday (choice finished) -- //
+
+ poll.setEndChoiceDate(yesterday());
+
+ // no begin date (choice not running) (choice finished)
+ poll.setBeginChoiceDate(null);
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ // begin date yesterday (choice not running) (choice finished)
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ // begin date tomorrow (choice not running) (choice finished)
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ // -- end choice date tomorrow (choice not finished) -- //
+
+ poll.setEndChoiceDate(tomorrow());
+
+ // no begin date (choice running)
+ poll.setBeginChoiceDate(null);
+ Assert.assertTrue(poll.isAddChoiceRunning(today()));
+
+ // begin date yesterday (choice running)
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertTrue(poll.isAddChoiceRunning(today()));
+
+ // begin date tomorrow (choice not running)
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ // -- not choiceAddAllowed (so all is false) -- //
+ // -- not choiceAddAllowed (so all is false) -- //
+ // -- not choiceAddAllowed (so all is false) -- //
+
+ poll.setChoiceAddAllowed(false);
+
+ // -- no end choice date (choice not finished) -- //
+
+ poll.setEndChoiceDate(null);
+ poll.setBeginChoiceDate(null);
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setEndChoiceDate(yesterday());
+ poll.setBeginChoiceDate(null);
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setEndChoiceDate(tomorrow());
+ poll.setBeginChoiceDate(null);
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setBeginChoiceDate(yesterday());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+
+ poll.setBeginChoiceDate(tomorrow());
+ Assert.assertFalse(poll.isAddChoiceRunning(today()));
+ }
+}
Property changes on: trunk/pollen-persistence/src/test/java/org/chorem/pollen/business/persistence/PollTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-06-16 21:57:35 UTC (rev 3498)
+++ trunk/pom.xml 2012-06-17 13:12:38 UTC (rev 3499)
@@ -193,6 +193,7 @@
<jettyVersion>${jettyPluginVersion}</jettyVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
<seleniumVersion>2.21.0</seleniumVersion>
+ <mockitoVersion>1.9.0</mockitoVersion>
<pollenI18nBundle>pollen-i18n</pollenI18nBundle>
<!-- license to use -->
@@ -419,6 +420,13 @@
<version>1.1.3</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>${mockitoVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
1
0
r3498 - in trunk/pollen-ui-struts2/src/main: resources/i18n webapp/WEB-INF/jsp/poll webapp/js
by tchemit@users.chorem.org 16 Jun '12
by tchemit@users.chorem.org 16 Jun '12
16 Jun '12
Author: tchemit
Date: 2012-06-16 23:57:35 +0200 (Sat, 16 Jun 2012)
New Revision: 3498
Url: http://chorem.org/repositories/revision/pollen/3498
Log:
improve + clean create poll form javascript and prefer use css class to mark some widgets to disable when vote started
Modified:
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-16 21:50:27 UTC (rev 3497)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-06-16 21:57:35 UTC (rev 3498)
@@ -319,10 +319,7 @@
pollen.security.error.creator_required=Only the poll creator or an administrator can access this page.
pollen.security.error.illegal_access=You are not authorise to access this page for following reason\:
pollen.security.error.no.pollId=No poll id given
-pollen.security.error.poll.not.closed.and.results.not.continuous=The poll is not closed and results are not continuous
pollen.security.error.poll.not.found=Poll not found with this id
-pollen.security.error.poll.not.free.and.access.not.granted=You can not access to this non free poll
-pollen.security.error.poll.result.private.and.access.not.granted=Results of the poll are private and you do not have credentials to see them
pollen.security.error.poll_access_required=You are not authorise to access this poll page.
pollen.security.error.poll_required=No poll found with the given url.
pollen.security.error.result_access_required=You are not authorise to access this result page.
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-16 21:50:27 UTC (rev 3497)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-06-16 21:57:35 UTC (rev 3498)
@@ -319,10 +319,7 @@
pollen.security.error.creator_required=Seul le créateur du sondage ou un administrateur peut accéder à cette page.
pollen.security.error.illegal_access=Vous n'êtes pas autorisé à accéder à cette page pour la raison suivante \:
pollen.security.error.no.pollId=Pas d'identifiant de sondage donné.
-pollen.security.error.poll.not.closed.and.results.not.continuous=
pollen.security.error.poll.not.found=Sondage non trouvé pour l'identifiant donné
-pollen.security.error.poll.not.free.and.access.not.granted=Vou s n'avez pas accès à ce sondage restreint
-pollen.security.error.poll.result.private.and.access.not.granted=Vous n'avez pas accès aux résultats privés de ce sondage
pollen.security.error.poll_access_required=Vous n'êtes pas autorisé à accéder à cette page de sondage.
pollen.security.error.poll_required=Aucun sondage à l'url donné.
pollen.security.error.result_access_required=Vous n'êtes pas autorisé à accéder à cette page de résultats.
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-06-16 21:50:27 UTC (rev 3497)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-06-16 21:57:35 UTC (rev 3498)
@@ -57,7 +57,6 @@
voteCountingType:'<s:property value="%{poll.voteCountingType.name()}"/>',
choiceType:'<s:property value="%{poll.choiceType.name()}"/>',
pollType:'<s:property value="%{poll.pollType.name()}"/>',
-
confirmCloseTitle:"<s:text name='pollen.title.close.poll'/>",
confirmCloseUrl:'<s:url action="confirmClosePoll/" namespace="/poll"/>'
+ '<s:property value="%{poll.adminId}"/>',
@@ -101,7 +100,7 @@
<br/>
- <fieldset>
+ <fieldset class="disableForVoteStarted">
<legend>
<s:text name="pollen.common.voteCountingType"/>
<img src="<s:url value='/img/tooltip.png'/>" class="tooltip"
@@ -109,7 +108,7 @@
title="<s:text name='pollen.common.voteCountingType.help'/>"/>
</legend>
<s:radio key='poll.voteCountingType' list="voteCountingTypes"
- label='' theme="simple" disabled="%{voteStarted}"/>
+ label='' theme="simple"/>
</fieldset>
<br/>
@@ -146,11 +145,10 @@
alt="<s:text name='pollen.fieldset.pollDate.options.help'/>"/>
</legend>
- <sj:datepicker key="poll.beginDate"
+ <sj:datepicker key="poll.beginDate" cssClass="disableForVoteStarted"
displayFormat="%{getText('pollen.common.datePickerPattern')}"
label="%{getText('pollen.common.beginDate')}"
- timepicker="true"
- disabled="%{voteStarted}"/>
+ timepicker="true"/>
<sj:datepicker key="poll.endDate"
displayFormat="%{getText('pollen.common.datePickerPattern')}"
timepicker="true"
@@ -158,7 +156,7 @@
</fieldset>
<br/>
- <fieldset>
+ <fieldset class="disableForVoteStarted">
<legend>
<s:text name="pollen.fieldset.choice.options"/>
<img src="<s:url value='/img/tooltip.png'/>" class="tooltip"
@@ -191,7 +189,7 @@
</fieldset>
<br/>
- <fieldset>
+ <fieldset class="disableForVoteStarted">
<legend>
<s:text name="pollen.fieldset.vote.options"/>
<img src="<s:url value='/img/tooltip.png'/>" class="tooltip"
@@ -250,7 +248,7 @@
</fieldset>
<br/>
- <fieldset>
+ <fieldset class="disableForVoteStarted">
<legend>
<s:text name="pollen.common.pollType"/>
<img src="<s:url value='/img/tooltip.png'/>" class="tooltip"
@@ -258,8 +256,7 @@
alt="<s:text name='pollen.common.pollType.help'/>"/>
</legend>
<s:radio key='poll.pollType' list="pollTypes"
- label='%{getText("pollen.common.pollType")}'
- disabled="%{voteStarted}"/>
+ label='%{getText("pollen.common.pollType")}'/>
<hr/>
<div id="pollTypeFREE" class="pollType">
@@ -288,12 +285,11 @@
</div>
<div align="center">
<s:submit key="pollen.action.addVotingList" theme="simple"
- onclick="return addNewVotingList();"
- disabled="%{voteStarted}"/>
+ onclick="return addNewVotingList();"/>
<s:if test="userLoggued">
<s:submit key="pollen.action.addVotingListFromPersonList"
onclick='return selectPersonListToCreateNewVotingList();'
- theme="simple" disabled="%{voteStarted}"/>
+ theme="simple"/>
</s:if>
</div>
</div>
@@ -338,10 +334,11 @@
}
if (<s:property value="%{poll.closed}"/>) {
- $('#registerForm input, textarea').attr('disabled', true);
- $('#registerForm :button, fieldset a, :submit, input[type="file"]').hide();
+ disablePoll();
}
-
+ if (<s:property value="%{voteStarted}"/>) {
+ disableWhenVoteStarted();
+ }
});
</script>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-06-16 21:50:27 UTC (rev 3497)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-06-16 21:57:35 UTC (rev 3498)
@@ -24,220 +24,212 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sp" uri="/nuiton-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-<fieldset>
-<legend><s:text name="pollen.fieldset.poll.choices"/></legend>
-<s:radio key='poll.choiceType' list="choiceTypes" label=''
- theme="simple" disabled="%{voteStarted}"/>
-<hr/>
-<s:fielderror fieldName="poll.choices" id="poll_choices_error" />
+<fieldset class="disableForVoteStarted">
+ <legend><s:text name="pollen.fieldset.poll.choices"/></legend>
+ <s:radio key='poll.choiceType' list="choiceTypes" label='' theme="simple"/>
+ <hr/>
+ <s:fielderror fieldName="poll.choices" id="poll_choices_error"/>
-<s:set id='deleteTitle'><s:text
- name="pollen.action.pollChoiceDelete"/></s:set>
-<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
-<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+ <s:set id='deleteTitle'><s:text
+ name="pollen.action.pollChoiceDelete"/></s:set>
+ <s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+ <s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
-<div id="choicesTEXT" class="choices">
- <s:iterator value="textChoices" status="status" var="choice">
- <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">textChoice_<s:property
- value="%{#choiceNumber}"/></s:set>
- <div id='choicesTEXT_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
- <sp:fielderror fieldName="%{#prefix}" id="%{#prefix}_error"/>
- <div class="fleft choiceName">
- <sp:fielderror fieldName="%{#prefix}.name" id="%{#prefix}.name_error"/>
- <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}"
- 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}"
- disabled="%{voteStarted}"/>
- </div>
- <s:if test="!voteStarted">
- <div class="fright">
- <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>
- <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>
+ <div id="choicesTEXT" class="choices">
+ <s:iterator value="textChoices" status="status" var="choice">
+ <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:set name="prefix">textChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
+ <div id='choicesTEXT_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
+ <sp:fielderror fieldName="%{#prefix}" id="%{#prefix}_error"/>
+ <div class="fleft choiceName">
+ <sp:fielderror fieldName="%{#prefix}.name"
+ id="%{#prefix}.name_error"/>
+ <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{#choiceNumber}"
+ theme="simple" value=''/>
+ <s:textfield cssClass="nameField" id='%{#prefix}.name' theme="simple"
+ key="%{#prefix}.name" label='' value="%{#choice.name}"/>
+ -
+ <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}"/>
</div>
- </s:if>
- <div class="cleanBoth"></div>
- </div>
- </s:iterator>
-</div>
-<div id="choicesDATE" class="choices">
- <s:iterator value="dateChoices" status="status" var="choice">
- <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">dateChoice_<s:property
- value="%{#choiceNumber}"/></s:set>
- <div id='choicesDATE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' id='%{#prefix}.topiaId'
- value='%{#choice.topiaId}' label='' theme="simple"/>
- <sp:fielderror fieldName="%{#prefix}" id="%{#prefix}_error"/>
- <div class="fleft choiceName">
- <sp:fielderror fieldName="%{#prefix}.name" id="%{#prefix}.name_error"/>
- <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name"
- changeMonth="true"
- changeYear="true" labelSeparator="" theme="simple"
- label=""
- timepicker="true" value="%{#choice.name}"
- displayFormat="%{getText('pollen.common.datePickerPattern')}"
- disabled="%{voteStarted}"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <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>
+ <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>
+ </div>
+ </s:if>
+ <div class="cleanBoth"></div>
</div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description"
- key="%{#prefix}.description" label='' theme="simple"
- value="%{#choice.description}"
- disabled="%{voteStarted}"/>
- </div>
- <s:if test="!voteStarted">
- <div class="fright">
- <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>
- <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:iterator>
+ </div>
+ <div id="choicesDATE" class="choices">
+ <s:iterator value="dateChoices" status="status" var="choice">
+ <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:set name="prefix">dateChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
+ <div id='choicesDATE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' id='%{#prefix}.topiaId'
+ theme="simple"
+ value='%{#choice.topiaId}' label=''/>
+ <sp:fielderror fieldName="%{#prefix}" id="%{#prefix}_error"/>
+ <div class="fleft choiceName">
+ <sp:fielderror fieldName="%{#prefix}.name"
+ id="%{#prefix}.name_error"/>
+ <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" label=""
+ changeMonth="true" changeYear="true" labelSeparator=""
+ theme="simple" timepicker="true"
+ value="%{#choice.name}"
+ displayFormat="%{getText('pollen.common.datePickerPattern')}"/>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
</div>
- </s:if>
- <div class="cleanBoth"></div>
- </div>
- </s:iterator>
-</div>
-<div id="choicesIMAGE" class="choices">
- <s:iterator value="imageChoices" status="status" var="choice">
- <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">imageChoice_<s:property
- value="%{#choiceNumber}"/></s:set>
- <div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
- <sp:fielderror fieldName="%{#prefix}" id="%{#prefix}_error"/>
- <div class="fleft choiceName">
- <sp:fielderror fieldName="%{#prefix}.name" id="%{#prefix}.name_error"/>
- <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <s:if test="#choice.name != null">
+ <div class="fleft">
+ <s:textarea cols="30" id="%{#prefix}.description" theme="simple"
+ key="%{#prefix}.description" label=''
+ value="%{#choice.description}"/>
+ </div>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <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>
+ <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>
+ </div>
+ </s:if>
+ <div class="cleanBoth"></div>
+ </div>
+ </s:iterator>
+ </div>
+ <div id="choicesIMAGE" class="choices">
+ <s:iterator value="imageChoices" status="status" var="choice">
+ <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:set name="prefix">imageChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
+ <div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
+ <sp:fielderror fieldName="%{#prefix}" id="%{#prefix}_error"/>
+ <div class="fleft choiceName">
+ <sp:fielderror fieldName="%{#prefix}.name"
+ id="%{#prefix}.name_error"/>
+ <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <s:if test="#choice.name != null">
- <%--Uploaded image--%>
- <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
- value="%{#choice.name}" label='' theme="simple"/>
+ <%--Uploaded image--%>
+ <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
+ value="%{#choice.name}" label='' theme="simple"/>
- <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
- value="%{#choice.location}" label='' theme="simple"/>
- <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
- escapeAmp="true">
- <s:param name="choiceTokenId">
- imagechoicesThumb_<s:property value='name'/>
- </s:param>
- </s:url>
- <img name="<s:property value="#prefix"/>.thumb"
- alt="<s:property value='name'/>"
- title="<s:property value='name'/>"
- src="<s:property value='imageUrl'/>">
+ <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
+ value="%{#choice.location}" label='' theme="simple"/>
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="true">
+ <s:param name="choiceTokenId">
+ imagechoicesThumb_<s:property value='name'/>
+ </s:param>
+ </s:url>
+ <img name="<s:property value="#prefix"/>.thumb"
+ alt="<s:property value='name'/>"
+ title="<s:property value='name'/>"
+ src="<s:property value='imageUrl'/>">
- <s:file key='imageChoice[%{#choiceNumber}]' label=''
- theme="simple"
- cssClass="nameField fleft"
- disabled="%{voteStarted}" cssStyle="margin-left:50px;"/>
- </s:if>
- <s:else>
- <%--New image--%>
- <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
- escapeAmp="false" value="/img/7ter.jpg"/>
- <img name="<s:property value="#prefix"/>.thumb"
- alt="<s:text name='pollen.image.not.loaded'/>"
- title="<s:text name='pollen.image.not.loaded'/>"
- src="<s:property value='imageUrl'/>" width="100px" height="75px">
- <s:file key='imageChoice[%{#choiceNumber}]' label=''
- theme="simple"
- cssClass="nameField fleft"
- disabled="%{voteStarted}" cssStyle="margin-left:50px;"/>
+ <s:file key='imageChoice[%{#choiceNumber}]' label='' theme="simple"
+ cssClass="nameField fleft" cssStyle="margin-left:50px;"/>
+ </s:if>
+ <s:else>
+ <%--New image--%>
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false" value="/img/7ter.jpg"/>
+ <img name="<s:property value="#prefix"/>.thumb"
+ alt="<s:text name='pollen.image.not.loaded'/>"
+ title="<s:text name='pollen.image.not.loaded'/>"
+ src="<s:property value='imageUrl'/>" width="100px"
+ height="75px">
+ <s:file key='imageChoice[%{#choiceNumber}]' label='' theme="simple"
+ cssClass="nameField fleft"
+ cssStyle="margin-left:50px;"/>
- </s:else>
+ </s:else>
- </div>
- <div class="fleft">
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- <s:textarea cols="30" id="%{#prefix}.description" label=''
- theme="simple"
- key="%{#prefix}.description"
- value="%{#choice.description}"
- disabled="%{voteStarted}"/>
- </div>
- <s:if test="!voteStarted">
- <div class="fright">
- <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>
- <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>
</div>
- </s:if>
+ <div class="fleft">
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ <s:textarea cols="30" id="%{#prefix}.description" label=''
+ theme="simple" key="%{#prefix}.description"
+ value="%{#choice.description}"/>
+ </div>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <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>
+ <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>
+ </div>
+ </s:if>
- <div class="cleanBoth"></div>
- </div>
- </s:iterator>
-</div>
-<hr/>
-<s:submit key="pollen.action.addChoice" align="center"
- onclick="return addNewChoice();" disabled="%{voteStarted}"/>
+ <div class="cleanBoth"></div>
+ </div>
+ </s:iterator>
+ </div>
+ <hr/>
+ <s:submit key="pollen.action.addChoice" align="center"
+ onclick="return addNewChoice();"/>
</fieldset>
Modified: trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-06-16 21:50:27 UTC (rev 3497)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-06-16 21:57:35 UTC (rev 3498)
@@ -137,7 +137,6 @@
async:false,
dataType:"html",
success:function (data) {
- console.info("My fucking containerId : " + containerId);
var container = $("#" + containerId);
container.append(data);
prepareVotingList(containerId, votingListNumber);
@@ -270,7 +269,7 @@
} else {
// remove all empty personToList
var numbers = getAllPersonToListNumbers(containerId);
- for (n in numbers) {
+ for (var n in numbers) {
if (n >= firstNumber) {
deletePersonToList(containerId + "_" + n);
}
@@ -470,29 +469,24 @@
function upChoice(choiceId) {
var choice = $('#' + choiceId);
- var containerId = choice.data('choiceType');
var choicePrefix = choice.data('choicePrefix');
var choiceNumber = choice.data('choiceNumber');
var newChoiceNumber = (choiceNumber - 1);
- return switchChoices(containerId, choicePrefix, choiceNumber, newChoiceNumber);
+ return switchChoices(choicePrefix, choiceNumber, newChoiceNumber);
}
function downChoice(choiceId) {
var choice = $('#' + choiceId);
- var containerId = choice.data('choiceType');
var choicePrefix = choice.data('choicePrefix');
var choiceNumber = choice.data('choiceNumber');
var newChoiceNumber = (choiceNumber + 1);
- return switchChoices(containerId, choicePrefix, choiceNumber, newChoiceNumber);
+ return switchChoices(choicePrefix, choiceNumber, newChoiceNumber);
}
-function switchChoices(containerId, choicePrefix, choiceNumber, newChoiceNumber) {
+function switchChoices( choicePrefix, choiceNumber, newChoiceNumber) {
- //console.info("will switch (" + choicePrefix + ") [" + choiceNumber
- // + "] to [" + newChoiceNumber + "]");
-
// change topiaId
switchValue(choicePrefix, choiceNumber, newChoiceNumber, '.topiaId');
// change description
@@ -546,7 +540,7 @@
}
function confirmClose() {
- $('.ui-dialog-title').html(datas['confirmCloseTitle'])
+ $('.ui-dialog-title').html(datas['confirmCloseTitle']);
var dialog = $("#confirmDialog");
var url = datas['confirmCloseUrl'] + '?'
+ $.param({redirectUrl:datas['confirmCloseRedirectUrl']});
@@ -555,6 +549,23 @@
return false;
}
+function disablePoll() {
+ $('#registerForm input, textarea').attr('disabled', true);
+ $('#registerForm :button, fieldset a, :submit, input[type="file"]').hide();
+}
+
+function disableWhenVoteStarted() {
+ $('#registerForm input.disableForVoteStarted').attr('disabled', true);
+ $('#registerForm textarea.disableForVoteStarted').attr('disabled', true);
+ $('#'+$('#registerForm input.disableForVoteStarted').parent().attr('id')+' button').hide();
+ $('#registerForm .disableForVoteStarted input').attr('disabled', true);
+ $('#registerForm .disableForVoteStarted textarea').attr('disabled', true);
+ $('#registerForm .disableForVoteStarted :button').hide();
+ $('#registerForm .disableForVoteStarted fieldset a').hide();
+ $('#registerForm .disableForVoteStarted :submit').hide();
+ $('#registerForm .disableForVoteStarted input[type="file"]').hide();
+}
+
jQuery(document).ready(function () {
function changeChoiceAddAllowed(val) {
1
0
r3497 - trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 16 Jun '12
by tchemit@users.chorem.org 16 Jun '12
16 Jun '12
Author: tchemit
Date: 2012-06-16 23:50:27 +0200 (Sat, 16 Jun 2012)
New Revision: 3497
Url: http://chorem.org/repositories/revision/pollen/3497
Log:
improve add choice ui layout
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-16 21:49:58 UTC (rev 3496)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-16 21:50:27 UTC (rev 3497)
@@ -430,7 +430,7 @@
<!-- Ajout de choix -->
<s:if test="pollChoiceRunning">
- <div id="choiceFormDiv">
+ <div id="choiceFormDiv" class="clearfix">
<s:form id="choiceForm" method="POST" namespace="/poll"
enctype="multipart/form-data">
<h4><s:text name="pollen.action.addChoice"/></h4>
@@ -457,8 +457,10 @@
<s:textarea cols="36" key="choice.description"
label="%{getText('pollen.common.description')}"/>
<br/>
+ <div class="cleanBoth">
<s:submit action="addChoice/%{uriId}" key="pollen.action.addChoice"
align="center"/>
+ </div>
</s:form>
</div>
</s:if>
1
0