Commit b2d7c679 authored by Stefan Busemann's avatar Stefan Busemann

Merge branch '22-resend-a-single-token' into 'master'

Resolve "Resend a single token"

Closes #22

See merge request t3o/election!15
parents 71c2de94 4704237c
......@@ -13,6 +13,10 @@ namespace T3o\Election\Controller;
*
* The TYPO3 project - inspiring people to share!
*/
use T3o\Election\Domain\Model\ElectionInvitation;
use T3o\Election\Service\ElectionInvitationService;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use T3o\Election\Domain\Model\Dto\ElectorImport as ElectorImportDto;
use T3o\Election\Domain\Model\Election;
......@@ -20,6 +24,7 @@ use T3o\Election\Domain\Model\Elector;
use T3o\Election\Domain\Model\ElectorImport;
use T3o\Election\Utility\CsvUtility;
use T3o\Election\Utility\FileUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* Class BeConfigurationController
......@@ -38,6 +43,7 @@ class BeElectorController extends AbstractProtectedBeController
const ACTION_UPLOAD = 'upload';
const ACTION_PROCESS_IMPORT = 'processImport';
const ACTION_OVERWRITE_ALL = 'overwriteAll';
const ACTION_RESEND_ELECTION_INVITATION = 'resendElectionInvitation';
/**
* @var \T3o\Election\Domain\Repository\ElectorateRepository
......@@ -180,6 +186,26 @@ class BeElectorController extends AbstractProtectedBeController
$this->redirect(self::ACTION_LIST);
}
/**
* @param Elector $elector
* @param ElectionInvitation $electionInvitation
*/
public function resendElectionInvitationAction(Elector $elector, ElectionInvitation $electionInvitation){
/** @var ElectionInvitationService $electionInvitationService */
$electionInvitationService = $this->objectManager->get(ElectionInvitationService::class);
$electionInvitationService->resendElectionInvitation($this->configuration, $electionInvitation);
$labelKey = $electionInvitation->isSuccess() ? 'view.be.elector.edit.election_invitaion_resend_body_success' : 'view.be.elector.edit.election_invitaion_resend_body_failure';
$severity = $electionInvitation->isSuccess() ? AbstractMessage::OK : AbstractMessage::ERROR;
$this->addFlashMessage(
LocalizationUtility::translate($labelKey, $this->extensionName),
LocalizationUtility::translate('view.be.elector.edit.election_invitaion_resend_title', $this->extensionName),
$severity
);
$this->redirect(self::ACTION_EDIT, self::CONTROLLER_NAME, 'election', ['elector' => $elector]);
}
/**
* @return string
*/
......@@ -199,6 +225,7 @@ class BeElectorController extends AbstractProtectedBeController
self::ACTION_UPLOAD,
self::ACTION_PROCESS_IMPORT,
self::ACTION_OVERWRITE_ALL,
self::ACTION_RESEND_ELECTION_INVITATION,
]
);
}
......
......@@ -133,7 +133,7 @@ class Election extends AbstractEntity
}
/**
* @param \VerteXVaaR\Election\Domain\Model\Electorate $electorate
* @param \T3o\Election\Domain\Model\Electorate $electorate
*/
public function setElectorate($electorate)
{
......
......@@ -59,6 +59,17 @@ class ElectionInvitationService
}
}
/**
* @param Configuration $configuration
* @param ElectionInvitation $electionInvitation
*/
public function resendElectionInvitation(Configuration $configuration, ElectionInvitation $electionInvitation)
{
$electionInvitation->setSuccess($this->sendElectionInvitation($configuration, $electionInvitation));
$this->electionInvitationRepository->update($electionInvitation);
$this->electionInvitationRepository->persistAll();
}
/**
* @param Configuration $configuration
* @param ElectionInvitation $electionInvitation
......
......@@ -117,6 +117,15 @@
<trans-unit id="view.be.dashboard.index.no_electionmanagergroup_msg_body">
<source>Please add an election group in your configuration.</source>
</trans-unit>
<trans-unit id="view.be.elector.edit.election_invitaion_resend_title">
<source>Resend election invitation</source>
</trans-unit>
<trans-unit id="view.be.elector.edit.election_invitaion_resend_body_success">
<source>Election invitation has been resent!</source>
</trans-unit>
<trans-unit id="view.be.elector.edit.election_invitaion_resend_body_failure">
<source>ERROR: Election invitation has NOT been resent!</source>
</trans-unit>
......
<f:render partial="Model/Election/FormFields/Title" arguments="{election:election}"/>
<fieldset class="form-section">
<div class="form-group">
<label>
......
<fieldset class="form-section">
<div class="form-group">
<label>
<f:translate key="model.elector.field.electionInvitations">Election Invitations</f:translate>
</label>
<div class="form-control-wrap" style="max-width: 480px">
<f:if condition="{elector.electionInvitations}">
<f:then>
<table class="table">
<thead>
<th>Election Circular</th>
<th>Sent</th>
<th>Voted</th>
<th></th>
</thead>
<tbody>
<f:for each="{elector.electionInvitations}" as="electionInvitation">
<tr>
<td>{electionInvitation.electionCircular.subject}</td>
<td>{f:if(condition:'{electionInvitation.success}',then:'yes',else:'no')}</td>
<td>{f:if(condition:'{electionInvitation.voted}',then:'yes',else:'no')}</td>
<td>
<f:if condition="{electionInvitation.voted}">
<f:then></f:then>
<f:else>
<f:link.action action="resendElectionInvitation" arguments="{elector:elector, electionInvitation:electionInvitation}" class="btn btn-default">
<core:icon identifier="actions-move-right"/> resend election invitation
</f:link.action>
</f:else>
</f:if>
</td>
</tr>
</f:for>
</tbody>
</table>
</f:then>
<f:else>
<f:translate key="model.elector.field.electionInvitations_empty">There are no election invitations</f:translate>
</f:else>
</f:if>
</div>
</div>
</fieldset>
\ No newline at end of file
......@@ -4,3 +4,4 @@
<f:render partial="Model/AbsctractPerson/FormFields/Gender" arguments="{object:elector}"/>
<f:render partial="Model/AbsctractPerson/FormFields/Email"/>
<f:render partial="Model/Elector/FormFields/Electorates" arguments="{elector:elector,electorates:electorates}"/>
<f:render partial="Model/Elector/FormFields/ElectionInvitation" arguments="{elector:elector}"/>
\ No newline at end of file
Markdown is supported
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