Skip to content

Commit

Permalink
Merge pull request #12159 from PennyDreadfulMTG/lock-match-logs-for-n…
Browse files Browse the repository at this point in the history
…on-admins

Hide match logs for 24 hours from non-admins
  • Loading branch information
mergify[bot] committed Apr 10, 2024
2 parents cb081f9 + 0d51ffd commit 50a7a90
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
57 changes: 31 additions & 26 deletions logsite/templates/match.mustache
@@ -1,28 +1,33 @@
<div class="banner">
<div class="title">
<h1>{{{players_string_safe}}} ({{id}})</h1>
<div class="subtitle">{{format_name}}: "{{comment}}"</div>
<div class="subtitle">{{display_date}}</div>
{{#hidden}}
<p>The match log will be available one day after the match.</p>
{{/hidden}}
{{^hidden}}
<div class="banner">
<div class="title">
<h1>{{{players_string_safe}}} ({{id}})</h1>
<div class="subtitle">{{format_name}}: "{{comment}}"</div>
<div class="subtitle">{{display_date}}</div>
</div>
<ul class="buttons">
<li><a title="" href="/export/{{id}}">Download</a></li>
{{#has_unexpected_third_game}}
<li><a title="Match has an unexpected game 3" href="#">Switcheroo</a></li>
{{/has_unexpected_third_game}}
{{#is_tournament}}
<li><a title="" href="#">Tournament Match</a></li>
{{/is_tournament}}
</ul>
</div>
<ul class="buttons">
<li><a title="" href="/export/{{id}}">Download</a></li>
{{#has_unexpected_third_game}}
<li><a title="Match has an unexpected game 3" href="#">Switcheroo</a></li>
{{/has_unexpected_third_game}}
{{#is_tournament}}
<li><a title="" href="#">Tournament Match</a></li>
{{/is_tournament}}
</ul>
</div>
{{#no_games}}
PDBot was interested by this match, but felt no need to join it.
{{/no_games}}
{{#game_one}}
{{#no_games}}
PDBot was interested by this match, but felt no need to join it.
{{/no_games}}
{{#game_one}}
{{> game_view}}
{{/game_one}}
{{#game_two}}
{{> game_view}}
{{/game_two}}
{{#game_three}}
{{/game_three}}
{{> game_view}}
{{/game_one}}
{{#game_two}}
{{> game_view}}
{{/game_two}}
{{#game_three}}
{{> game_view}}
{{/game_three}}
{{/hidden}}
6 changes: 5 additions & 1 deletion logsite/views/match_view.py
@@ -1,8 +1,9 @@
import datetime
import html

import inflect
import titlecase
from flask import url_for
from flask import session, url_for

from shared.pd_exception import DoesNotExistException

Expand All @@ -28,6 +29,9 @@ def __init__(self, viewed_match: match.Match) -> None:
self.players_string = ' vs '.join([p.name for p in viewed_match.players])
self.players_string_safe = ' vs '.join([player_link(p.name) for p in viewed_match.players])
self.module_string = ', '.join([m.name for m in viewed_match.modules])
if viewed_match.start_time > datetime.datetime.now() - datetime.timedelta(days=1) and not session.get('admin'):
self.hidden = True
return
if not viewed_match.games:
self.no_games = True
return
Expand Down

0 comments on commit 50a7a90

Please sign in to comment.