From bb41ea7dccdc41e27965b559d778a4abf4f0a318 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 19 Jun 2023 22:22:55 +0100 Subject: [PATCH] Prevent texture packs from supporting all games --- app/blueprints/packages/packages.py | 8 ++++++-- app/templates/packages/game_support.html | 16 +++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index 7e54b903..77396e1c 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -671,6 +671,8 @@ def game_support(package): force_game_detection = package.supported_games.filter(and_( PackageGameSupport.confidence > 1, PackageGameSupport.supports == True)).count() == 0 + can_support_all_games = package.type != PackageType.TXP + can_override = can_edit and current_user not in package.maintainers form = GameSupportForm() if can_edit else None @@ -713,7 +715,8 @@ def game_support(package): else: package.supported_games.filter_by(confidence=1).delete() - package.supports_all_games = form.supports_all_games.data + if can_support_all_games: + package.supports_all_games = form.supports_all_games.data add_audit_log(AuditSeverity.NORMAL, current_user, "Edited game support", package.get_url("packages.game_support"), package) @@ -744,7 +747,8 @@ def game_support(package): return render_template("packages/game_support.html", package=package, form=form, mod_conf_lines=mod_conf_lines, force_game_detection=force_game_detection, - tabs=get_package_tabs(current_user, package), current_tab="game_support") + can_support_all_games=can_support_all_games, tabs=get_package_tabs(current_user, package), + current_tab="game_support") @bp.route("/packages///stats/") diff --git a/app/templates/packages/game_support.html b/app/templates/packages/game_support.html index f4d9f7ef..75797348 100644 --- a/app/templates/packages/game_support.html +++ b/app/templates/packages/game_support.html @@ -90,11 +90,17 @@

{% endif %} - {{ render_checkbox_field(form.supports_all_games) }} -

- {{ _("Unless otherwise stated, this package should work with all games.") }} - {{ _("You can check this and still specify games in supported_games that you've tested.") }} -

+ {{ render_checkbox_field(form.supports_all_games, disabled=not can_support_all_games) }} + {% if can_support_all_games %} +

+ {{ _("Unless otherwise stated, this package should work with all games.") }} + {{ _("You can check this and still specify games in supported_games that you've tested.") }} +

+ {% elif package.type.name == "TXP" %} +

+ {{ _("It's not possible for texture packs to support all games") }} +

+ {% endif %} {% if form.supported and form.unsupported %}