double redeem block deleted
This commit is contained in:
parent
fa8d4c4b1d
commit
1506201913
42
setup.sh
42
setup.sh
|
@ -259,6 +259,7 @@ ITAD_API_KEY_PLACEHOLDER = "your_api_key_here"
|
||||||
TZ = os.getenv('TZ', 'UTC')
|
TZ = os.getenv('TZ', 'UTC')
|
||||||
os.environ['TZ'] = TZ
|
os.environ['TZ'] = TZ
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
app.jinja_env.globals['getattr'] = getattr
|
||||||
|
|
||||||
# UNIX-Systems (Linux, Docker)
|
# UNIX-Systems (Linux, Docker)
|
||||||
try:
|
try:
|
||||||
|
@ -535,11 +536,13 @@ class GameForm(FlaskForm):
|
||||||
steam_appid = StringField('Steam App ID')
|
steam_appid = StringField('Steam App ID')
|
||||||
|
|
||||||
PLATFORM_CHOICES = [
|
PLATFORM_CHOICES = [
|
||||||
('pc', 'PC'),
|
('steam', 'Steam'),
|
||||||
|
('gog', 'GOG'),
|
||||||
('xbox', 'XBox'),
|
('xbox', 'XBox'),
|
||||||
('playstation', 'PlayStation'),
|
('playstation', 'PlayStation'),
|
||||||
('switch', 'Nintendo Switch'),
|
('switch', 'Nintendo Switch'),
|
||||||
('other', 'Andere')
|
('other', 'Other'),
|
||||||
|
('pc', 'PC')
|
||||||
]
|
]
|
||||||
|
|
||||||
STATUS_CHOICES = [
|
STATUS_CHOICES = [
|
||||||
|
@ -1119,7 +1122,6 @@ def import_games():
|
||||||
|
|
||||||
return render_template('import.html')
|
return render_template('import.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/generate_redeem/<int:game_id>', methods=['POST'])
|
@app.route('/generate_redeem/<int:game_id>', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def generate_redeem(game_id):
|
def generate_redeem(game_id):
|
||||||
|
@ -1149,31 +1151,45 @@ def generate_redeem(game_id):
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return jsonify({'error': str(e)}), 500
|
return jsonify({'error': str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
@app.route('/redeem/<token>', endpoint='redeem')
|
@app.route('/redeem/<token>', endpoint='redeem')
|
||||||
def redeem_page(token):
|
def redeem_page(token):
|
||||||
redeem_token = RedeemToken.query.filter_by(token=token).first()
|
redeem_token = RedeemToken.query.filter_by(token=token).first()
|
||||||
|
|
||||||
if not redeem_token:
|
if not redeem_token:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
# Zeit in UTC umwandeln
|
|
||||||
expires_utc = redeem_token.expires.astimezone(pytz.UTC)
|
expires_utc = redeem_token.expires.astimezone(pytz.UTC)
|
||||||
|
|
||||||
if datetime.now(pytz.UTC) > expires_utc:
|
if datetime.now(pytz.UTC) > expires_utc:
|
||||||
db.session.delete(redeem_token)
|
db.session.delete(redeem_token)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
game = Game.query.get(redeem_token.game_id)
|
game = Game.query.get(redeem_token.game_id)
|
||||||
redeem_token.used = True
|
redeem_token.used = True
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return render_template('redeem.html',
|
# which Plattform
|
||||||
|
if game.platform == "steam" or game.steam_appid:
|
||||||
|
platform_link = 'https://store.steampowered.com/account/registerkey?key='
|
||||||
|
platform_label = "Steam"
|
||||||
|
elif game.platform == "gog":
|
||||||
|
platform_link = 'https://www.gog.com/redeem/'
|
||||||
|
platform_label = "GOG"
|
||||||
|
elif game.platform == "xbox":
|
||||||
|
platform_link = 'https://redeem.microsoft.com/'
|
||||||
|
platform_label = "XBOX"
|
||||||
|
elif game.platform == "playstation":
|
||||||
|
platform_link = 'https://store.playstation.com/redeem'
|
||||||
|
platform_label = "PlayStation"
|
||||||
|
else:
|
||||||
|
platform_link = '#'
|
||||||
|
platform_label = game.platform.capitalize() if game.platform else "Unknown"
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
'redeem.html',
|
||||||
game=game,
|
game=game,
|
||||||
redeem_token=redeem_token,
|
redeem_token=redeem_token,
|
||||||
expires_timestamp=int(expires_utc.timestamp() * 1000), # Millisekunden
|
expires_timestamp=int(expires_utc.timestamp() * 1000),
|
||||||
platform_link='https://store.steampowered.com/account/registerkey?key=' if game.steam_appid else 'https://www.gog.com/redeem')
|
platform_link=platform_link,
|
||||||
|
platform_label=platform_label
|
||||||
|
)
|
||||||
|
|
||||||
@app.route('/admin/users')
|
@app.route('/admin/users')
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -2253,7 +2269,7 @@ cat <<'HTML_END' > templates/redeem.html
|
||||||
<a href="{{ platform_link }}{{ game.steam_key }}"
|
<a href="{{ platform_link }}{{ game.steam_key }}"
|
||||||
class="btn btn-primary btn-lg mb-3"
|
class="btn btn-primary btn-lg mb-3"
|
||||||
target="_blank">
|
target="_blank">
|
||||||
{{ _('Redeem now on') }} {% if game.steam_appid %}Steam{% else %}GOG{% endif %}
|
{{ _('Redeem now on') }} {{ platform_label }}
|
||||||
</a>
|
</a>
|
||||||
<div class="mt-4 text-muted">
|
<div class="mt-4 text-muted">
|
||||||
<small>
|
<small>
|
||||||
|
|
Loading…
Reference in New Issue