Disable 'Submit for Approval' when release is broken

This commit is contained in:
rubenwardy 2022-02-04 13:36:26 +00:00
parent eeea5d004a
commit b82bcb0af9
2 changed files with 12 additions and 6 deletions

@ -736,7 +736,8 @@ class Package(db.Model):
needsScreenshot = \
(self.type == self.type.GAME or self.type == self.type.TXP) and \
self.screenshots.count() == 0
return self.releases.count() > 0 and not needsScreenshot
return self.releases.filter(PackageRelease.task_id.is_(None)).count() > 0 and not needsScreenshot
elif state == PackageState.CHANGES_NEEDED:
return self.checkPerm(user, Permission.APPROVE_NEW)

@ -14,19 +14,24 @@
</div>
{% set level = "warning" %}
{% if package.releases.count() == 0 %}
{% if package.releases.filter_by(task_id=None).count() == 0 %}
{% set message %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
{% if package.update_config %}
<a class="btn btn-sm btn-warning float-right" href="{{ package.getURL("packages.create_release") }}">
{{ _("Create first release") }}
<a class="btn btn-sm btn-warning float-right" href="{{ package.getURL('packages.create_release') }}">
{{ _("Create release") }}
</a>
{% else %}
<a class="btn btn-sm btn-warning float-right" href="{{ package.getURL("packages.setup_releases") }}">
<a class="btn btn-sm btn-warning float-right" href="{{ package.getURL('packages.setup_releases') }}">
{{ _("Set up releases") }}
</a>
{% endif %}
{{ _("You need to create a release before this package can be approved.") }}
{% if package.releases.count() == 0 %}
{{ _("You need to create a release before this package can be approved.") }}
{% else %}
{{ _("Release is still importing, or has an error.") }}
{% endif %}
{% else %}
{{ _("A release is required before this package can be approved.") }}
{% endif %}