Commit 55977a28 authored by Oliver Eglseder's avatar Oliver Eglseder
Browse files

[TASK] Add submit vote action

parent de837511
......@@ -81,12 +81,35 @@ class FeElectionController extends ActionController
}
}
/**
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function initializeSubmitVoteAction()
{
if ($this->request->hasArgument('electionVoting')) {
$electionVoting = $this->request->getArgument('electionVoting');
if (isset($electionVoting['nominees']) && is_array($electionVoting['nominees'])) {
$electionVoting['nominees'] = array_filter($electionVoting['nominees']);
$this->request->setArgument('electionVoting', $electionVoting);
}
}
}
/**
* @param ElectionVoting $electionVoting
*/
public function submitVoteAction(ElectionVoting $electionVoting)
{
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($electionVoting, __CLASS__ . '@' . __LINE__, 20);
if (count($electionVoting->getNominees()) > $electionVoting->getElectionInvitation()
->getElectionCircular()
->getElection()
->getNumberOfVotes()
) {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump('too many votes', __CLASS__ . '@' . __LINE__, 20);
} else {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump('accepted', __CLASS__ . '@' . __LINE__, 20);
}
die;
}
......
<?php
namespace TYPO3\Election\Domain\Model\Dto;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\Election\Domain\Model\AbstractEntity;
/**
* Class ElectionVoting
*/
class ElectionVoting
class ElectionVoting extends AbstractEntity
{
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\Election\Domain\Model\Nominee>
*/
protected $nominees = null;
protected $nominees;
/**
* @var \TYPO3\Election\Domain\Model\ElectionInvitation
*/
protected $electionInvitation;
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
......@@ -26,4 +46,20 @@ class ElectionVoting
{
$this->nominees = $nominees;
}
/**
* @return \TYPO3\Election\Domain\Model\ElectionInvitation
*/
public function getElectionInvitation()
{
return $this->electionInvitation;
}
/**
* @param \TYPO3\Election\Domain\Model\ElectionInvitation $electionInvitation
*/
public function setElectionInvitation($electionInvitation)
{
$this->electionInvitation = $electionInvitation;
}
}
......@@ -31,7 +31,7 @@
<f:link.page pageUid="{nominee.url}">{nominee.url}</f:link.page>
</td>
<td>
<f:form.checkbox property="nominees.{nominee.uid}" value="{nominee.uid}"/>
<f:form.checkbox property="nominees." value="{nominee.uid}"/>
</td>
</tr>
</f:if>
......
......@@ -15,6 +15,7 @@
</f:translate>
</p>
<f:form action="submitVote" object="{electionVoting}" objectName="electionVoting">
<f:form.hidden property="electionInvitation" value="{electionInvitation}"/>
<f:render partial="Model/Nominee/VoteList"
arguments="{nominees:electionInvitation.electionCircular.election.nominees}"/>
<f:form.submit value="vote"/>
......
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