mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +01:00
Prevent disabling game detection without manually specifying games
This commit is contained in:
parent
e091bd6fb0
commit
bfbab7ae9e
@ -628,7 +628,7 @@ def similar(package):
|
|||||||
|
|
||||||
|
|
||||||
class GameSupportForm(FlaskForm):
|
class GameSupportForm(FlaskForm):
|
||||||
enable_support_detection = BooleanField(lazy_gettext("Enable support detection based on dependencies"))
|
enable_support_detection = BooleanField(lazy_gettext("Enable support detection based on dependencies (recommended)"), [Optional()])
|
||||||
supported = StringField(lazy_gettext("Supported games (Comma-separated)"), [Optional()])
|
supported = StringField(lazy_gettext("Supported games (Comma-separated)"), [Optional()])
|
||||||
unsupported = StringField(lazy_gettext("Unsupported games (Comma-separated)"), [Optional()])
|
unsupported = StringField(lazy_gettext("Unsupported games (Comma-separated)"), [Optional()])
|
||||||
submit = SubmitField(lazy_gettext("Save"))
|
submit = SubmitField(lazy_gettext("Save"))
|
||||||
@ -645,6 +645,9 @@ def game_support(package):
|
|||||||
if not (can_edit or package.checkPerm(current_user, Permission.APPROVE_NEW)):
|
if not (can_edit or package.checkPerm(current_user, Permission.APPROVE_NEW)):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
|
force_game_detection = package.supported_games.filter(and_(
|
||||||
|
PackageGameSupport.confidence > 1, PackageGameSupport.supports == True)).count() == 0
|
||||||
|
|
||||||
form = GameSupportForm() if can_edit else None
|
form = GameSupportForm() if can_edit else None
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
form.enable_support_detection.data = package.enable_game_support_detection
|
form.enable_support_detection.data = package.enable_game_support_detection
|
||||||
@ -665,8 +668,9 @@ def game_support(package):
|
|||||||
|
|
||||||
next_url = package.getURL("packages.game_support")
|
next_url = package.getURL("packages.game_support")
|
||||||
|
|
||||||
if form.enable_support_detection.data != package.enable_game_support_detection:
|
enable_support_detection = form.enable_support_detection.data or force_game_detection
|
||||||
package.enable_game_support_detection = form.enable_support_detection.data
|
if enable_support_detection != package.enable_game_support_detection:
|
||||||
|
package.enable_game_support_detection = enable_support_detection
|
||||||
if package.enable_game_support_detection:
|
if package.enable_game_support_detection:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@ -682,4 +686,5 @@ def game_support(package):
|
|||||||
return redirect(next_url)
|
return redirect(next_url)
|
||||||
|
|
||||||
return render_template("packages/game_support.html", package=package, form=form,
|
return render_template("packages/game_support.html", package=package, form=form,
|
||||||
|
force_game_detection=force_game_detection,
|
||||||
tabs=get_package_tabs(current_user, package), current_tab="game_support")
|
tabs=get_package_tabs(current_user, package), current_tab="game_support")
|
||||||
|
@ -5,17 +5,14 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<a class="float-right btn btn-secondary" href="{{ url_for('flatpage', path='help/game_support') }}">
|
||||||
|
{{ _("Documentation") }}
|
||||||
|
</a>
|
||||||
<h2 class="mt-0">{{ self.title() }}</h2>
|
<h2 class="mt-0">{{ self.title() }}</h2>
|
||||||
|
|
||||||
<p class="alert alert-warning">
|
<p class="alert alert-warning">
|
||||||
This feature is experimental
|
This feature is experimental
|
||||||
</p>
|
</p>
|
||||||
<p class="alert alert-info">
|
|
||||||
<a class="float-right btn btn-sm" href="{{ url_for('flatpage', path='help/game_support') }}">
|
|
||||||
{{ _("Read more") }}
|
|
||||||
</a>
|
|
||||||
{{ _("Support is determined based on dependencies and fields in mod.conf") }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
@ -75,7 +72,12 @@
|
|||||||
<form method="POST" action="" class="tableform">
|
<form method="POST" action="" class="tableform">
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
|
|
||||||
{{ render_checkbox_field(form.enable_support_detection) }}
|
{{ render_checkbox_field(form.enable_support_detection, disabled=force_game_detection) }}
|
||||||
|
{% if force_game_detection %}
|
||||||
|
<p class="text-muted">
|
||||||
|
{{ _("You need to manually define at least one supported game before you can turn this off.") }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if package.checkPerm(current_user, "EDIT_PACKAGE") and current_user not in package.maintainers %}
|
{% if package.checkPerm(current_user, "EDIT_PACKAGE") and current_user not in package.maintainers %}
|
||||||
<h3>
|
<h3>
|
||||||
|
Loading…
Reference in New Issue
Block a user