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 = \ needsScreenshot = \
(self.type == self.type.GAME or self.type == self.type.TXP) and \ (self.type == self.type.GAME or self.type == self.type.TXP) and \
self.screenshots.count() == 0 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: elif state == PackageState.CHANGES_NEEDED:
return self.checkPerm(user, Permission.APPROVE_NEW) return self.checkPerm(user, Permission.APPROVE_NEW)

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