Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid 500 when adding player to an event that is already entered but has no deck #858

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gatherling/Models/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public function __construct(int $event_id, string $playername)

public static function findByEventAndPlayer(int $event_id, string $playername): ?self
{
$sql = 'SELECT deck FROM entries WHERE event_id = :event_id AND player = :player';
$sql = 'SELECT player FROM entries WHERE event_id = :event_id AND player = :player';
$params = ['event_id' => $event_id, 'player' => $playername];
$deckId = db()->optionalInt($sql, $params);
if (!$deckId) {
$player = db()->optionalString($sql, $params);
if (!$player) {
return null;
}
return new self($event_id, $playername);
Expand Down
33 changes: 14 additions & 19 deletions gatherling/templates/partials/allDecks.mustache
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<p>Decks marked with a <font color="#FF0000">*</font> are not legal under current format.</p>

<div class="alpha grid_6">
<div id="gatherling_lefthalf">
<table width="275">
<tr>
<td colspan="3"><b>{{upPlayer}}'S DECKS</td>
</tr>
{{#decks}}
<tr>
<td width="20">{{#medalSrc}}<img alt="Medal" src="{{medalSrc}}" style="border-width: 0">{{/medalSrc}}</td>
<td width="20">{{recordString}}</td>
<td>{{#deckLink}}{{> deckLink}}{{/deckLink}}{{^isValid}}<font color="#FF0000">*</font>{{/isValid}}</td>
<td align="right"><a href="{{eventLink}}">{{eventName}}</a></td>
</tr>
{{/decks}}
</table>
</div>
</div>
<div class="omega grid_4">
<div id="gatherling_righthalf"></div>
<div>
<table>
<tr>
<td colspan="3"><b>{{upPlayer}}'S DECKS</b></td>
</tr>
{{#decks}}
<tr>
<td>{{#medalSrc}}<img alt="Medal" src="{{medalSrc}}" style="border-width: 0">{{/medalSrc}}</td>
<td>{{recordString}}</td>
<td>{{#deckLink}}{{> deckLink}}{{/deckLink}}{{^isValid}}<font color="#FF0000">*</font>{{/isValid}}</td>
<td align="right"><a href="{{eventLink}}">{{eventName}}</a></td>
</tr>
{{/decks}}
</table>
</div>