Commit de837511 authored by Oliver Eglseder's avatar Oliver Eglseder
Browse files

[WIP][TASK] begin voting

parent b6345dbd
......@@ -17,6 +17,7 @@ namespace TYPO3\Election\Controller;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\Election\Domain\Model\Dto\ElectionVoting;
use TYPO3\Election\Domain\Model\ElectionInvitation;
/**
......@@ -26,6 +27,7 @@ class FeElectionController extends ActionController
{
const CONTROLLER_NAME = 'FeElection';
const ACTION_VOTE = 'vote';
const ACTION_SUBMIT_VOTE = 'submitVote';
/**
* @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService
......@@ -60,6 +62,7 @@ class FeElectionController extends ActionController
$saltedEmail = $electionInvitation->getSecret() . $electionInvitation->getElector()->getEmail();
if ($this->hashService->validateHmac($saltedEmail, $hmac)) {
$this->view->assign('electionInvitation', $electionInvitation);
$this->view->assign('electionVoting', new ElectionVoting());
} else {
$this->addFlashMessage(
LocalizationUtility::translate('controller.fe.election.vote.hmac_invalid', 'election'),
......@@ -78,12 +81,21 @@ class FeElectionController extends ActionController
}
}
/**
* @param ElectionVoting $electionVoting
*/
public function submitVoteAction(ElectionVoting $electionVoting)
{
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($electionVoting, __CLASS__ . '@' . __LINE__, 20);
die;
}
/**
* @return string
*/
public static function getActionsForPluginConfiguration()
{
return implode(',', [self::ACTION_VOTE]);
return implode(',', [self::ACTION_VOTE, self::ACTION_SUBMIT_VOTE]);
}
/**
......
<?php
namespace TYPO3\Election\Domain\Model\Dto;
/**
* Class ElectionVoting
*/
class ElectionVoting
{
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\Election\Domain\Model\Nominee>
*/
protected $nominees = null;
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getNominees()
{
return $this->nominees;
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $nominees
*/
public function setNominees($nominees)
{
$this->nominees = $nominees;
}
}
......@@ -385,7 +385,7 @@
<source>Election</source>
</trans-unit>
<!-- FE ELECTION -->
<!-- FE ELECTION CONTROLLER -->
<trans-unit id="controller.fe.election.vote.hmac_invalid">
<source>HMAC invalid. You are not allowed to request this page.</source>
......@@ -397,6 +397,21 @@
<source>The link you clicked is not valid anymore.</source>
</trans-unit>
<!-- FE ELECTION -->
<trans-unit id="view.fe.election.vote.election">
<source>Election</source>
</trans-unit>
<trans-unit id="view.fe.election.vote.nominees">
<source>Nominees</source>
</trans-unit>
<trans-unit id="view.fe.election.vote.votes">
<source>You can vote for up to %d nominees in this election. You can only vote once, remaining votes will be discarded.</source>
</trans-unit>
<trans-unit id="view.fe.election.vote.vote">
<source>Vote</source>
</trans-unit>
</body>
</file>
</xliff>
......@@ -10,36 +10,31 @@
<f:translate key="model.abstract_person.field.full_name">Name</f:translate>
</th>
<th>
<f:translate key="model.abstract_person.field.email">Email</f:translate>
<f:translate key="model.abstract_person.field.url">URL</f:translate>
</th>
<th>
<f:translate key="view.be.anything.options">Vote</f:translate>
<f:translate key="view.fe.election.vote.vote">Vote</f:translate>
</th>
</tr>
</thead>
<tbody>
<f:for each="{nominees}" as="nominee">
<tr>
<td>
<f:image image="{nominee.image}" width="50c" height="50c"/>
</td>
<td>
<f:link.action action="edit" controller="BeNominee" arguments="{nominee:nominee}">
<f:if condition="{nominee.public}">
<tr>
<td>
<f:image image="{nominee.image}" width="50c" height="50c"/>
</td>
<td>
{nominee.fullName}
</f:link.action>
</td>
<td>
{nominee.email}
</td>
<td>
<div class="btn-group">
<f:link.action class="btn btn-default" action="edit" controller="BeNominee"
arguments="{nominee:nominee}">
<core:icon identifier="actions-edit-rename"/>
</f:link.action>
</div>
</td>
</tr>
</td>
<td>
<f:link.page pageUid="{nominee.url}">{nominee.url}</f:link.page>
</td>
<td>
<f:form.checkbox property="nominees.{nominee.uid}" value="{nominee.uid}"/>
</td>
</tr>
</f:if>
</f:for>
</tbody>
</table>
<f:layout name="Frontend"/>
<f:section name="Main">
<f:debug>{_all}</f:debug>
<h2>Election: {electionInvitation.electionCircular.election.title}</h2>
<h3>Nominees</h3>
<f:render partial="Model/Nominee/VoteList" arguments="{nominees:electionInvitation.electionCircular.election.nominees}"/>
<h2>
<f:translate key="view.fe.election.vote.election">Election</f:translate>
: {electionInvitation.electionCircular.election.title}
</h2>
<h3>
<f:translate key="view.fe.election.vote.nominees">Nominees</f:translate>
</h3>
<p>
<f:translate key="view.fe.election.vote.votes"
arguments="{0:electionInvitation.electionCircular.election.numberOfVotes}">You can vote up to
{electionInvitation.electionCircular.election.numberOfVotes} nominees
</f:translate>
</p>
<f:form action="submitVote" object="{electionVoting}" objectName="electionVoting">
<f:render partial="Model/Nominee/VoteList"
arguments="{nominees:electionInvitation.electionCircular.election.nominees}"/>
<f:form.submit value="vote"/>
</f:form>
</f:section>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment