Skip to content

Commit

Permalink
added untie participant from troop for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Dec 8, 2023
1 parent cabd305 commit 5608be0
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/Application/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,12 @@ public function addRoutesInto(App $app): App
$app->group('/troopManagement', function (RouteCollectorProxy $app) {
$app->get('', AdminController::class . '::showTroopManagement')
->setName('admin-troop-management');

$app->post('/tieTogether', AdminController::class . '::tieTogether')
->setName('admin-troop-tie-together');

$app->post('/untie', AdminController::class . '::untie')
->setName('admin-troop-untie');
});

$app->group('/export', function (RouteCollectorProxy $app) {
Expand Down
16 changes: 16 additions & 0 deletions src/Participant/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,20 @@ public function tieTogether(Request $request, Response $response, Event $event):
'admin-troop-management',
);
}

public function untie(Request $request, Response $response, Event $event): Response
{
$troopParticipantCode = $this->getParameterFromBody($request, 'tieCodeParticipant');

$this->troopService->tryUntieWithMessages(
$troopParticipantCode,
$event,
);

return $this->redirect(
$request,
$response,
'admin-troop-management',
);
}
}
23 changes: 23 additions & 0 deletions src/Participant/Troop/TroopService.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,27 @@ public function tryTieTogetherWithMessages(

return $valid;
}

public function tryUntieWithMessages(string $troopParticipantCode, Event $event): bool
{
$valid = true;
$tp = $this->troopParticipantRepository->findTroopParticipantFromTieCode($troopParticipantCode, $event);
if ($tp === null) {
$this->flashMessages->warning($this->translator->trans('flash.warning.troopParticipantNotFoundUntieNotPossible'));
$valid = false;
}

if ($tp !== null && $tp->getUserButNotNull()->status === UserStatus::Paid) {
$this->flashMessages->warning($this->translator->trans('flash.warning.troopParticipantPaidUntieNotPossible'));
$valid = false;
}

if ($valid && $tp !== null) {
$tp->troopLeader = null;
$this->troopParticipantRepository->persist($tp);
$this->flashMessages->success($this->translator->trans('flash.success.participantUntied'));
}

return $valid;
}
}
7 changes: 6 additions & 1 deletion src/Templates/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ detail:
driver-more10k: "Mám, na akci řídit chci a mám najeto víc než 10 000 km"
loginMethod: "Přihlášení"
closed-at: "Uzamknut"
adminNotice: "Poznámka od admina"
paid-at: "Zaplaceno"
adminNotice: "Org poznámka"
detail-guest:
notice: "Zvoucí a účel"
notice-placeholder: "Od koho máš pozvánku a jaký je tvůj záměr na akci?"
Expand Down Expand Up @@ -411,6 +412,7 @@ troopManagement-admin:
noTroopParticipants: "žádní účastníci bez skupiny nejsou k dispozici"
troopParticipantsWithoutLeader: "účastníci bez skupiny"
tieTogether: "Připojit účastníka do skupiny"
untie: "Odepnout účastníka od skupiny"
flash:
info:
participantDeleted: "Účastník byl smazán"
Expand Down Expand Up @@ -440,6 +442,7 @@ flash:
transfer: "Platba úspěšně přesunuta!"
troopParticipantTiedToTroopLeader: "Účastník úspěšně připojen do skupiny!"
troopTied: "Účastník úspěšně připojen do skupiny!"
participantUntied: "Účastník úspěšně odepnut od skupiny!"
warning:
noLock: "Registraci nelze uzamknout - nějaké informace jsou špatně vyplněné nebo chybí (pravděpodobně nějaké datum)"
plWrongData: "Nemůžeme uzamknout registraci - prosím oprav svoje údaje (nejspíš email nebo nějaké datum)"
Expand Down Expand Up @@ -479,6 +482,8 @@ flash:
troopParticipantNotFoundTieNotPossible: "Účastník nebyl nalezen, připojení do skupiny není možné"
troopParticipantPaidTieNotPossible: "Účastník má zaplacenou registraci, připojení do skupiny není možné"
troopParticipantHasTroopTieNotPossible: "Účastník již skupinu má, připojení do skupiny není možné"
troopParticipantNotFoundUntieNotPossible: "Účastník nebyl nalezen, odpojení od skupiny není možné"
troopParticipantPaidUntieNotPossible: "Účastník má zaplacenou registraci, odpojení od skupiny není možné"
error:
adminOnly: "Sorry bro, pouze pro administrátory"
plOnly: "Pardon, nejsi přihlášený jako vedoucí patroly"
Expand Down
7 changes: 6 additions & 1 deletion src/Templates/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ detail:
driver-more10k: "I have it and have driven more than 10 000 km"
loginMethod: "Login method"
closed-at: "Locked"
adminNotice: "Note from admin"
paid-at: "Paid"
adminNotice: "Admin note"
detail-guest:
notice: "Inviter and purpose"
notice-placeholder: "Who invited you and what is your intentions at event?"
Expand Down Expand Up @@ -411,6 +412,7 @@ troopManagement-admin:
noTroopParticipants: "there are no participants without troop"
troopParticipantsWithoutLeader: "participants without troop"
tieTogether: "Tie participant into troop"
untie: "Untie participant from troop"
flash:
info:
participantDeleted: "Participant was deleted"
Expand Down Expand Up @@ -440,6 +442,7 @@ flash:
transfer: "Payment transfer was successful!"
troopParticipantTiedToTroopLeader: "Troop participant is successfully tied to troop leader"
troopTied: "Participant successfully added to the group!"
participantUntied: "Participant successfully untied from the group!"
warning:
noLock: "Cannot lock the registration - some details are wrong or missing (probably email or date)"
plWrongData: "Cannot lock the registration - some details are wrong or missing (probably email or date)"
Expand Down Expand Up @@ -479,6 +482,8 @@ flash:
troopParticipantNotFoundTieNotPossible: "Troop participant not found, tie is not possible"
troopParticipantPaidTieNotPossible: "Troop participant has paid registration, tie is not possible"
troopParticipantHasTroopTieNotPossible: "Troop participant is already tied to a group, tie is not possible"
troopParticipantNotFoundUntieNotPossible: "Participant not found, untie is not possible"
troopParticipantPaidUntieNotPossible: "Participant has paid registration, untie is not possible"
error:
adminOnly: "Sorry bro, admins only"
plOnly: "Sorry, you are not logged as Patrol Leader"
Expand Down
8 changes: 6 additions & 2 deletions src/Templates/sk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ detail:
driver-more10k: "Mám a mám najazdených viac ako 10 000 km"
loginMethod: "Přihlášení"
closed-at: "Uzamknut"
adminNotice: "Poznámka od admina"
paid-at: "Zaplaceno"
adminNotice: "Org poznámka"
detail-guest:
notice: "Zvoucí a účel"
notice-placeholder: "Od koho máš pozvánku a jaký je tvůj záměr na akci?"
Expand Down Expand Up @@ -408,6 +409,7 @@ flash:
adminPairedPayments: "Párované bankovní transakce: "
transfer: "Přesun platby proběhl úspěšně!"
troopTied: "Účastník úspešne pridaný do skupiny!"
participantUntied: "Účastník úspěšně odepnut od skupiny!"
warning:
noLock: "Nie je možné uzamknúť registráciu - nejaký z údajov je nesprávny alebo chýbajúci (možno nejaký dátum)"
plWrongData: "Nie je možné uzamknúť registráciu - prosím oprav svoje údaje (nejspíš email nebo nějaké datum)"
Expand Down Expand Up @@ -436,7 +438,9 @@ flash:
troopLeaderPaidTieNotPossible: "Vedúci skupiny má zaplatenú registráciu, pridanie do skupiny nie je možné"
troopParticipantNotFoundTieNotPossible: "Účastník nebol nájdený, pridanie do skupiny nie je možné"
troopParticipantPaidTieNotPossible: "Účastník má zaplatenú registráciu, pridanie do skupiny nie je možné"
troopParticipantHasTroopTieNotPossible: "Účastník už skupinu má, pridanie do skupiny nie je možné"
troopParticipantHasTroopTieNotPossible: "Účastník už skupinu má, pridanie do skupiny nie je možné"
troopParticipantNotFoundUntieNotPossible: "Účastník nebyl nalezen, odpojení od skupiny není možné"
troopParticipantPaidUntieNotPossible: "Účastník má zaplacenou registraci, odpojení od skupiny není možné"
error:
adminOnly: "Sorry bro, sem môžu len admini"
plOnly: "Prepáč, ale nie si prihlásený/á ako Patrol líder"
Expand Down
9 changes: 7 additions & 2 deletions src/Templates/translatable/admin/troopManagement.twig
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@

<h4>{% trans %}role.tp{% endtrans %} {% trans %}dashboard.details{% endtrans %}</h4>
{% for tp in tl.troopParticipants %}
<hr/>
{% include 'widgets/detailsForAdmin.twig' with {
'person': tp,
'ca': caTl,
'ca': caTp,
'useShortNaming': true
} %}
} %}<br/>
<form method="POST" action="{{ url_for('admin-troop-untie', {eventSlug: event.slug}) }}">
<input type="hidden" name="tieCodeParticipant" value="{{ tp.tieCode }}">
<input type="submit" class="btn btn-small btn-mini" value="{% trans %}troopManagement-admin.untie{% endtrans %}">
</form>
<br/>
{% endfor %}
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/Templates/translatable/widgets/detailsForAdmin.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
{% endif %}
</b></i><br/>
{% endif %}
{% if person.getRegistrationCloseDate %}
{% if person.user.status.value != 'open' and person.getRegistrationCloseDate %}
<i>{% trans %}detail.closed-at{% endtrans %}: <b>{{ person.getRegistrationCloseDate.format('d. m. Y, H:i:s') }}</b></i><br/>
{% endif %}
{% if person.user.status.value == 'paid' and person.getRegistrationPayDate %}
<i>{% trans %}detail.paid-at{% endtrans %}: <b>{{ person.getRegistrationPayDate.format('d. m. Y, H:i:s') }}</b></i><br/>
{% endif %}
{% include 'widgets/adminNotice.twig' with {'participantId': person.id} %}

0 comments on commit 5608be0

Please sign in to comment.