branch feature/58-limitation-des-votants updated (9616ed8e -> 4187caaa)
This is an automated email from the git hooks/post-receive script. New change to branch feature/58-limitation-des-votants in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from 9616ed8e Dans les listes des sondages : voir les sondage hors limites du nombre de votants (ref #58) new 4187caaa Création et modification d'un sondage restreint, avertir si le nombre de participant dépasse le nombre maximum de votants (ref #58) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4187caaa946f433af756e71f1dd74e5be683e0ee Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Sep 28 13:33:36 2017 +0200 Création et modification d'un sondage restreint, avertir si le nombre de participant dépasse le nombre maximum de votants (ref #58) Summary of changes: .../chorem/pollen/services/bean/VoterListBean.java | 12 +++++++++++ .../pollen/services/service/PollService.java | 3 +++ .../pollen/services/service/VoterListService.java | 19 +++++++++++++++- pollen-ui-riot-js/src/main/web/i18n/en.json | 2 ++ pollen-ui-riot-js/src/main/web/i18n/fr.json | 2 ++ .../src/main/web/js/VoterListService.js | 25 ++++++++++++++++++++-- .../src/main/web/tag/voterList/VoterList.tag.html | 17 +++++++++++++-- 7 files changed, 75 insertions(+), 5 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/58-limitation-des-votants in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 4187caaa946f433af756e71f1dd74e5be683e0ee Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Sep 28 13:33:36 2017 +0200 Création et modification d'un sondage restreint, avertir si le nombre de participant dépasse le nombre maximum de votants (ref #58) --- .../chorem/pollen/services/bean/VoterListBean.java | 12 +++++++++++ .../pollen/services/service/PollService.java | 3 +++ .../pollen/services/service/VoterListService.java | 19 +++++++++++++++- pollen-ui-riot-js/src/main/web/i18n/en.json | 2 ++ pollen-ui-riot-js/src/main/web/i18n/fr.json | 2 ++ .../src/main/web/js/VoterListService.js | 25 ++++++++++++++++++++-- .../src/main/web/tag/voterList/VoterList.tag.html | 17 +++++++++++++-- 7 files changed, 75 insertions(+), 5 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoterListBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoterListBean.java index 7d76b4f8..97ff6fce 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoterListBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoterListBean.java @@ -23,6 +23,8 @@ package org.chorem.pollen.services.bean; import org.chorem.pollen.persistence.entity.VoterList; +import java.util.Set; + /** * Created on 5/15/14. * @@ -41,6 +43,8 @@ public class VoterListBean extends PollenBean<VoterList> { protected long countMembers; + protected Set<String> allEmails; + public VoterListBean() { super(VoterList.class); } @@ -87,4 +91,12 @@ public class VoterListBean extends PollenBean<VoterList> { public void setCountMembers(long countMembers) { this.countMembers = countMembers; } + + public Set<String> getAllEmails() { + return allEmails; + } + + public void setAllEmails(Set<String> allEmails) { + this.allEmails = allEmails; + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index 084d48b1..050f9e7f 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -272,6 +272,9 @@ public class PollService extends PollenServiceSupport { } + boolean premium = getUserService().isPremium(connectedUser); + pollBean.setMaxVoters(premium ? 0 : getPollenServiceConfig().getMaxVoters()); + return pollBean; } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java index c9038094..eb9a3833 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoterListService.java @@ -174,6 +174,8 @@ public class VoterListService extends PollenServiceSupport { bean.setCountSubLists(countSubLists); bean.setCountMembers(countMembers); + bean.setAllEmails(getVoterListMemberMails(entity)); + return bean; } @@ -825,11 +827,26 @@ public class VoterListService extends PollenServiceSupport { public long getVoterListMemberCount(Poll poll) { VoterList voterList = getMainVoterList0(poll); + return getVoterListMemberCount(voterList); + } + + public long getVoterListMemberCount(VoterList voterList) { + List<VoterListMember> allMembers = getVoterListDao().getAllMembers(voterList); - + return allMembers.stream() .map(VoterListMember::getMember) .distinct() .count(); } + + public Set<String> getVoterListMemberMails(VoterList voterList) { + + List<VoterListMember> allMembers = getVoterListDao().getAllMembers(voterList); + + return allMembers.stream() + .map(VoterListMember::getMember) + .map(PollenPrincipal::getEmail) + .collect(Collectors.toSet()); + } } diff --git a/pollen-ui-riot-js/src/main/web/i18n/en.json b/pollen-ui-riot-js/src/main/web/i18n/en.json index 7b2afe76..e61596f6 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/en.json +++ b/pollen-ui-riot-js/src/main/web/i18n/en.json @@ -529,6 +529,8 @@ "voterList_member_deleteMessage": "Delete member ?", "voterList_member_resendInvitation": "Resent a invitation", "voterList_member_resendInvitation_success": "invitation send", + "voterList_maxVotersAlert_title": "Number of voters limitation", + "voterList_maxVotersAlert": "The number of voters exceeds the limit of the standard offer ({0} voters). Users can continue to vote but only the first {0} votes are taken into account in the calculation of the resultles. Read <a href=\"#home\">the offers page</a> to unlock this limit.", "modal_cancel": "Cancel", "modal_ok": "Ok", "confirm_cancel": "Cancel", diff --git a/pollen-ui-riot-js/src/main/web/i18n/fr.json b/pollen-ui-riot-js/src/main/web/i18n/fr.json index b0bce51c..9fe43d58 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/fr.json +++ b/pollen-ui-riot-js/src/main/web/i18n/fr.json @@ -529,6 +529,8 @@ "voterList_member_deleteMessage": "Supprimer le participant ?", "voterList_member_resendInvitation": "Renvoyer une invitation", "voterList_member_resendInvitation_success": "L'invitation est envoyée", + "voterList_maxVotersAlert_title": "Limitation du Nombre de votants", + "voterList_maxVotersAlert": "Le nombre de participants dépasse la limite de l'offre standard ({0} votants). Tout les participants pourront voter mais seul les {0} premiers votes seront pris en compte dans le calcul du résultat. Cousulter <a href=\"#home\">la page des nos offres</a> pour déverrouiller cette limite.", "modal_cancel": "Annuler", "modal_ok": "Ok", "confirm_cancel": "Annuler", diff --git a/pollen-ui-riot-js/src/main/web/js/VoterListService.js b/pollen-ui-riot-js/src/main/web/js/VoterListService.js index 7ebaa475..173f4743 100644 --- a/pollen-ui-riot-js/src/main/web/js/VoterListService.js +++ b/pollen-ui-riot-js/src/main/web/js/VoterListService.js @@ -8,12 +8,12 @@ * 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% @@ -46,6 +46,7 @@ class VoterListService extends FetchService { subLists: [], countMembers: 0, members: [], + allEmails: [], name: name, weight: weight || 1, loadded: true, @@ -216,6 +217,26 @@ class VoterListService extends FetchService { return Promise.resolve(member); } + countAllEmails(voterList) { + let emails = this.getAllEmails(voterList); + return emails.size; + } + + getAllEmails(voterList) { + let emails = new Set(); + if (voterList.loadded) { + voterList.members + .map(m => m.email) + .forEach(email => emails.add(email)); + voterList.subLists + .map(subList => this.getAllEmails(subList)) + .forEach(subEmails => subEmails.forEach(email => emails.add(email))); + } else { + voterList.allEmails.forEach(email => emails.add(email)); + } + return emails; + } + deleteMember(member) { let voterList = this.voterListsById[member.voterListId]; let index = voterList.members.indexOf(member); diff --git a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html index c1251aa9..fecfd26b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html @@ -8,12 +8,12 @@ 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% @@ -38,6 +38,14 @@ require("../components/ContextualMenu.tag.html"); </li> </ol> + <div show={isOutOfLimite()} + class="c-alert c-alert--warning"> + <div> + <strong> {__.maxVotersAlert_title}</strong> + </div> + <InnerHtml html={_l("maxVotersAlert", opts.form.model.maxVoters)} /> + </div> + <div class="elements"> <VoterListCard each={subList in opts.form.currentVoterList.subLists} voter-list={subList} @@ -186,6 +194,11 @@ require("../components/ContextualMenu.tag.html"); }); }; + this.isOutOfLimite = () => { + return this.opts.form.model.maxVoters > 0 + && voterListService.countAllEmails(this.opts.form.mainVoterList) > this.opts.form.model.maxVoters; + }; + this.submit = () => { this.opts.form.mainVoterList.name = this.__.mainList + this.opts.form.model.title; }; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm