-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a page allowing users to edit a replay (#484)
* Add a custom field type for Django enums. The problem that caused me to write this PR is that enums get made available on Django forms as strings. This does work eventually; the string gets set on the model and is handled appropriately. But it's really annoying to work with programmatically. For example, equality checks fail in places you'd expect them to succeed. * Add a page that allows you to edit an existing replay. The edit replay page can be used to edit the metadata of an existing replay. I reuse the "finalize publishing replay" page for this purpose. You can't change the actual file, but you can change everything else. PC-98 games aren't supported, not for any particular reason but because this PR is big enough as it is. * Last-minute fixes * Respond to code review comments * Add test for posting an invalid replay edit. * Oops. Fix duplicate name
- Loading branch information
Showing
14 changed files
with
598 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
project/thscoreboard/replays/templates/replays/base/publish_or_edit.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
{% extends "base.html" %} | ||
{% load i18n %} | ||
|
||
{% block content %} | ||
<h1>{% block publish_or_edit_heading %}{% endblock %}</h1> | ||
<h2>{{ game_name }}</h2> | ||
<p> | ||
<table class="replay-header"> | ||
<tbody> | ||
{% if replay_timestamp %} | ||
<tr> | ||
<td>{% translate "Replay Date" %}</td> | ||
{% if game_id == "th06" or game_id == "th09" %} | ||
<td>{{ replay_timestamp|date:"d F Y" }}</td> | ||
{% elif game_id == "th07" %} | ||
<td>{{ replay_timestamp|date:"d F" }}</td> | ||
{% else %} | ||
<td>{{ replay_timestamp|date:"d F Y, h:i A" }}</td> | ||
{% endif %} | ||
</tr> | ||
{% endif %} | ||
<tr> | ||
<td>{% translate "Difficulty" %}</td> | ||
<td>{{ difficulty_name }}</td> | ||
</tr> | ||
<tr> | ||
<td>{% translate "Shot" %}</td> | ||
<td>{{ shot_name }}</td> | ||
</tr> | ||
{% if route_name %} | ||
<tr> | ||
<td>{% translate "Route" %}</td> | ||
<td>{{ route_name }}</td> | ||
</tr> | ||
{% endif %} | ||
{% if replay_slowdown is not None %} | ||
<tr> | ||
<td>{% translate "Slowdown" %}</td> | ||
<td>{{ replay_slowdown|floatformat:4 }}%</td> | ||
</tr> | ||
{% endif %} | ||
<tr> | ||
<td>{% translate "Replay Type" %}</td> | ||
<td>{{ replay_type }}</td> | ||
</tr> | ||
{% if replay_spell_card_id %} | ||
<tr> | ||
<td>{% translate "Spell Card ID" %}</td> | ||
<td>{{ replay_spell_card_id }}</td> | ||
</tr> | ||
{% endif %} | ||
</tbody> | ||
</table> | ||
</p> | ||
<form method="post" class="finish-uploading-form"> | ||
{% csrf_token %} | ||
{{ form.non_field_errors }} | ||
|
||
<table class="form-table"> | ||
<th style="width: 50%;"></th> | ||
<tr> | ||
<td> | ||
<label for="{{form.name.id_for_label}}">{% translate "Name" %}</label> | ||
{{ form.name.errors }} | ||
</td> | ||
<td> | ||
{{ form.name }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<label for="{{form.score.id_for_label}}">{% translate "Score" %}</label> | ||
{{ form.score.errors }} | ||
</td> | ||
<td> | ||
{{ form.score }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<label for="{{form.category.id_for_label}}">{% translate "Category" %}</label> | ||
{{ form.category.errors }} | ||
</td> | ||
<td> | ||
{{ form.category }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<label for="{{form.video_link.id_for_label}}">{% translate "Video link" %}</label> | ||
{{ form.video_link.errors }} | ||
</td> | ||
<td> | ||
{{ form.video_link }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<label for="{{form.is_clear.id_for_label}}">{% translate "Did it clear?" %}</label> | ||
</td> | ||
<td> | ||
{{ form.is_clear }} | ||
</td> | ||
</tr> | ||
{% if has_replay_file %} | ||
<tr> | ||
<td> | ||
<label for="{{form.is_good.id_for_label}}">{% translate "No desyncs" %}</label> | ||
{{ form.is_good.errors }} | ||
</td> | ||
<td> | ||
{{ form.is_good }} | ||
</td> | ||
</tr> | ||
{% endif %} | ||
{% if form.uses_bombs %} | ||
<tr> | ||
<td> | ||
<label for="{{form.uses_bombs.id_for_label}}">{% translate "Did you use bombs?" %}</label> | ||
{{ form.uses_bombs.errors }} | ||
</td> | ||
<td> | ||
{{ form.uses_bombs }} | ||
</td> | ||
</tr> | ||
{% endif %} | ||
{% if form.misses %} | ||
<tr> | ||
<td> | ||
<label for="{{form.misses.id_for_label}}">{% translate "Miss count (optional)" %}</label> | ||
{{ form.misses.errors }} | ||
</td> | ||
<td> | ||
{{ form.misses }} | ||
</td> | ||
</tr> | ||
{% endif %} | ||
</table> | ||
<div class="comment-input"> | ||
<label for="{{form.comment.id_for_label}}">{% translate "Comment" %}</label> {{ form.comment.errors }}<br> | ||
{{ form.comment }} | ||
</div> | ||
<input type="submit" value={% translate "Publish Replay" %}> | ||
</form> | ||
{% endblock %} |
4 changes: 4 additions & 0 deletions
4
project/thscoreboard/replays/templates/replays/edit_replay.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% extends "replays/base/publish_or_edit.html" %} | ||
{% load i18n %} | ||
|
||
{% block publish_or_edit_heading %}{% translate "Edit your replay" %}{% endblock %} |
7 changes: 7 additions & 0 deletions
7
project/thscoreboard/replays/templates/replays/edit_replay_not_allowed.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "simple_centered.html" %} | ||
{% load i18n %} | ||
|
||
{% block centered-content %} | ||
<p>{% blocktranslate %}You cannot edit this replay; only its owner can edit it.{% endblocktranslate %}</p> | ||
<p><a href="{% url 'Replays/Details' game_id replay_id %}">{% translate "Go back to the replay" %}</a></p> | ||
{% endblock %} |
Oops, something went wrong.