edit_game.html fixed

This commit is contained in:
nocci 2025-05-08 16:05:13 +02:00
parent 171719a85f
commit 3b3e43d9af
1 changed files with 54 additions and 118 deletions

172
setup.sh
View File

@ -898,13 +898,6 @@ def edit_game(game_id):
game.steam_appid = request.form.get('steam_appid', '') game.steam_appid = request.form.get('steam_appid', '')
game.redeem_date = safe_parse_date(request.form.get('redeem_date', '')) game.redeem_date = safe_parse_date(request.form.get('redeem_date', ''))
# Zeitzonen-korrekte Umwandlung
game.redeem_date_local = (
game.redeem_date.astimezone(local_tz)
if game.redeem_date
else None
)
# Token-Logik # Token-Logik
if game.status == 'geschenkt': if game.status == 'geschenkt':
# Vorhandene Tokens löschen # Vorhandene Tokens löschen
@ -1918,7 +1911,7 @@ cat <<HTML_END > templates/edit_game.html
{% block content %} {% block content %}
<div class="card p-4 shadow-sm"> <div class="card p-4 shadow-sm">
<h2 class="mb-4">{{ _('Spiel bearbeiten') }}</h2> <h2 class="mb-4">{{ _('Spiel bearbeiten') }}</h2>
<!-- Flash-Nachrichten --> <!-- Flash-Nachrichten -->
{% with messages = get_flashed_messages(with_categories=true) %} {% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %} {% if messages %}
@ -1932,11 +1925,11 @@ cat <<HTML_END > templates/edit_game.html
</div> </div>
{% endif %} {% endif %}
{% endwith %} {% endwith %}
<form method="POST" aria-label="{{ _('Spiel bearbeiten') }}"> <form method="POST" aria-label="{{ _('Spiel bearbeiten') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="row g-3"> <div class="row g-3">
<!-- Hauptformularfelder --> <!-- Formularfelder -->
<div class="col-md-6"> <div class="col-md-6">
<label class="form-label">{{ _('Name') }} <span class="text-danger">*</span></label> <label class="form-label">{{ _('Name') }} <span class="text-danger">*</span></label>
<input type="text" name="name" class="form-control" value="{{ game.name }}" required> <input type="text" name="name" class="form-control" value="{{ game.name }}" required>
@ -1945,9 +1938,7 @@ cat <<HTML_END > templates/edit_game.html
<label for="game_platform" class="form-label">{{ _('Platform') }} <span class="text-danger">*</span></label> <label for="game_platform" class="form-label">{{ _('Platform') }} <span class="text-danger">*</span></label>
<select id="game_platform" name="platform" class="form-select" required> <select id="game_platform" name="platform" class="form-select" required>
{% for value, label in platforms %} {% for value, label in platforms %}
<option value="{{ value }}" {% if game.platform == value %}selected{% endif %}> <option value="{{ value }}" {% if game.platform == value %}selected{% endif %}>{{ _(label) }}</option>
{{ _(label) }}
</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -1955,9 +1946,7 @@ cat <<HTML_END > templates/edit_game.html
<label for="game_status" class="form-label">{{ _('Status') }} <span class="text-danger">*</span></label> <label for="game_status" class="form-label">{{ _('Status') }} <span class="text-danger">*</span></label>
<select id="game_status" name="status" class="form-select" required> <select id="game_status" name="status" class="form-select" required>
{% for value, label in statuses %} {% for value, label in statuses %}
<option value="{{ value }}" {% if game.status == value %}selected{% endif %}> <option value="{{ value }}" {% if game.status == value %}selected{% endif %}>{{ _(label) }}</option>
{{ _(label) }}
</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -1966,69 +1955,34 @@ cat <<HTML_END > templates/edit_game.html
<input type="text" name="steam_key" class="form-control" value="{{ game.steam_key }}" required> <input type="text" name="steam_key" class="form-control" value="{{ game.steam_key }}" required>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label for="game_appid" class="form-label">{{ _('Steam AppID') }}</label> <label for="game_appid" class="form-label">{{ _('Steam AppID') }}</label>
<input type="text" <input type="text" id="game_appid" name="steam_appid" class="form-control" value="{{ game.steam_appid or '' }}">
id="game_appid"
name="steam_appid"
class="form-control"
value="{{ game.steam_appid or '' }}">
</div> </div>
<!-- Redeem Date -->
<div class="col-md-6"> <div class="col-md-6">
<label for="game_redeem_date" class="form-label">{{ _('Redeem by') }}</label> <label for="game_redeem_date" class="form-label">{{ _('Redeem by') }}</label>
<input type="date" <input type="date" id="game_redeem_date" name="redeem_date" class="form-control" value="{{ game.redeem_date.strftime('%Y-%m-%d') if game.redeem_date else '' }}">
id="game_redeem_date" </div>
name="redeem_date" <div class="col-12">
class="form-control" <label for="game_recipient" class="form-label">{{ _('Recipient') }}</label>
value="{{ game.redeem_date.strftime('%Y-%m-%d') if game.redeem_date else '' }}"> <input type="text" id="game_recipient" name="recipient" class="form-control" value="{{ game.recipient }}">
</div>
<div class="col-12">
<label for="game_url" class="form-label">{{ _('Shop URL') }}</label>
<input type="url" id="game_url" name="url" class="form-control" value="{{ game.url }}">
</div>
<div class="col-12">
<label for="game_notes" class="form-label">{{ _('Notes') }}</label>
<textarea id="game_notes" name="notes" class="form-control" rows="3">{{ game.notes }}</textarea>
</div> </div>
<!-- Recipient -->
<div class="col-12">
<label for="game_recipient" class="form-label">{{ _('Recipient') }}</label>
<input type="text"
id="game_recipient"
name="recipient"
class="form-control"
value="{{ game.recipient }}">
</div>
<!-- Shop URL -->
<div class="col-12">
<label for="game_url" class="form-label">{{ _('Shop URL') }}</label>
<input type="url"
id="game_url"
name="url"
class="form-control"
value="{{ game.url }}">
</div>
<!-- Notes -->
<div class="col-12">
<label for="game_notes" class="form-label">{{ _('Notes') }}</label>
<textarea id="game_notes"
name="notes"
class="form-control"
rows="3">{{ game.notes }}</textarea>
</div>
</div>
<!-- Externe Daten Card --> <!-- Externe Daten Card -->
<div class="col-12"> <div class="col-12">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center"> <div class="card-header d-flex justify-content-between align-items-center">
<span>🔄 {{ _('Externe Daten') }}</span> <span>🔄 {{ _('Externe Daten') }}</span>
<form method="POST" action="{{ url_for('update_game_data', game_id=game.id) }}"> <a href="{{ url_for('update_game_data', game_id=game.id) }}" class="btn btn-secondary">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> Update Data
<input type="hidden" name="steam_appid_to_update" value="{{ game.steam_appid }}"> </a>
<button type="submit"
formaction="{{ url_for('update_game_data', game_id=game.id) }}"
name="update_data"
value="1"
class="btn btn-secondary">
Update Data
</button>
</form>
</div> </div>
<div class="card-body"> <div class="card-body">
{% if game.release_date %} {% if game.release_date %}
@ -2037,33 +1991,24 @@ cat <<HTML_END > templates/edit_game.html
{{ game.release_date|strftime('%d.%m.%Y') }} {{ game.release_date|strftime('%d.%m.%Y') }}
</div> </div>
{% endif %} {% endif %}
{% if game.current_price %}
<!-- Preisanzeige --> <div class="text-center mb-2">
<td> <span class="badge bg-primary d-block">{{ _('Now') }}</span>
<td> <div class="fw-bold" style="font-size:1.1em;">
{% if game.current_price %} {{ "%.2f"|format(game.current_price) }}
<div class="text-center mb-2">
<span class="badge bg-primary d-block">{{ _('Now') }}</span>
<div class="fw-bold" style="font-size:1.1em;">
{{ "%.2f"|format(game.current_price) }}
</div>
</div> </div>
{% endif %} </div>
{% if game.historical_low %} {% endif %}
<div class="text-center"> {% if game.historical_low %}
<span class="badge bg-secondary d-block">{{ _('Hist. Low') }}</span> <div class="text-center">
<div class="fw-bold" style="font-size:1.1em;"> <span class="badge bg-secondary d-block">{{ _('Hist. Low') }}</span>
{{ "%.2f"|format(game.historical_low) }} <div class="fw-bold" style="font-size:1.1em;">
</div> {{ "%.2f"|format(game.historical_low) }}
</div> </div>
{% endif %} </div>
</td> {% endif %}
<!-- ITAD-Link -->
{% if game.itad_slug %} {% if game.itad_slug %}
<a href="https://isthereanydeal.com/game/{{ game.itad_slug }}/info/" <a href="https://isthereanydeal.com/game/{{ game.itad_slug }}/info/" target="_blank" rel="noopener" class="btn btn-outline-info mt-2">
target="_blank"
rel="noopener"
class="btn btn-outline-info">
🔗 {{ _('View on IsThereAnyDeal') }} 🔗 {{ _('View on IsThereAnyDeal') }}
</a> </a>
{% endif %} {% endif %}
@ -2077,37 +2022,29 @@ cat <<HTML_END > templates/edit_game.html
<div class="card mb-3"> <div class="card mb-3">
<div class="card-header">{{ _('Einlöse-Links') }}</div> <div class="card-header">{{ _('Einlöse-Links') }}</div>
<div class="card-body"> <div class="card-body">
{% for token in game.redeem_tokens if not token.is_expired() %} {% for token in game.redeem_tokens if not token.is_expired() %}
<div class="input-group mb-3"> <div class="input-group mb-3">
<input type="text" <input type="text" class="form-control" value="{{ url_for('redeem', token=token.token, _external=True) }}" readonly id="redeem-link-{{ loop.index }}">
class="form-control" <button type="button" class="btn btn-outline-secondary copy-btn" data-clipboard-target="#redeem-link-{{ loop.index }}">
value="{{ url_for('redeem', token=token.token, _external=True) }}" {{ _('Copy') }}
readonly </button>
id="redeem-link-{{ loop.index }}"> </div>
<button type="button" <small class="text-muted">
class="btn btn-outline-secondary copy-btn" {{ _('Expires at') }}: {{ token.expires.astimezone(local_tz).strftime('%d.%m.%Y %H:%M') }}
data-clipboard-target="#redeem-link-{{ loop.index }}"> </small>
{{ _('Copy') }} {% else %}
</button> <p class="text-muted mb-0">{{ _('No active redeem links') }}</p>
</div> {% endfor %}
<small class="text-muted">
{{ _('Expires at') }}: {{ token.expires.astimezone(local_tz).strftime('%d.%m.%Y %H:%M') }}
</small>
{% else %}
<p class="text-muted mb-0">{{ _('No active redeem links') }}</p>
{% endfor %}
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif %}
<a href="{{ url_for('game_details', game_id=game.id) }}"
class="btn btn-info ms-2">
🔍 {{ _('View Details') }}
</a>
<!-- Buttons --> <!-- Buttons -->
<div class="col-12"> <div class="col-12">
<button type="submit" class="btn btn-primary">{{ _('Save') }}</button> <button type="submit" class="btn btn-primary">{{ _('Save') }}</button>
<a href="{{ url_for('index') }}" class="btn btn-outline-secondary ms-2">{{ _('Cancel') }}</a> <a href="{{ url_for('index') }}" class="btn btn-outline-secondary ms-2">{{ _('Cancel') }}</a>
<a href="{{ url_for('game_details', game_id=game.id) }}" class="btn btn-info ms-2">🔍 {{ _('View Details') }}</a>
</div> </div>
</div> </div>
</form> </form>
@ -2129,7 +2066,6 @@ document.querySelectorAll('.copy-btn').forEach(btn => {
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}
HTML_END HTML_END