Skip to content

Commit

Permalink
Merge pull request #858 from PennyDreadfulMTG/duplicate-entry
Browse files Browse the repository at this point in the history
Avoid 500 when adding player to an event that is already entered but has no deck
  • Loading branch information
bakert authored Nov 27, 2024
2 parents ce8084e + 1821bab commit 94cfa6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
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>

0 comments on commit 94cfa6b

Please sign in to comment.