From 59a5cf2df59d50a488f93b3d69c5ca945d7c8826 Mon Sep 17 00:00:00 2001
From: rubenwardy
Date: Thu, 12 Aug 2021 18:57:25 +0100
Subject: [PATCH] Add editor queue for packages with "Other" licenses
Fixes #283
---
app/blueprints/todo/__init__.py | 10 ++++++++--
app/models/packages.py | 13 +++++++++++++
app/templates/todo/editor.html | 24 ++++++++++++++++++++++--
3 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/app/blueprints/todo/__init__.py b/app/blueprints/todo/__init__.py
index a30c1400..5bb30b92 100644
--- a/app/blueprints/todo/__init__.py
+++ b/app/blueprints/todo/__init__.py
@@ -63,18 +63,24 @@ def view_editor():
else:
abort(400)
+ license_needed = Package.query \
+ .filter(Package.state.in_([PackageState.READY_FOR_REVIEW, PackageState.APPROVED])) \
+ .filter(or_(Package.license.has(License.name.like("Other %")),
+ Package.media_license.has(License.name.like("Other %")))) \
+ .all()
+
total_packages = Package.query.filter_by(state=PackageState.APPROVED).count()
total_to_tag = Package.query.filter_by(state=PackageState.APPROVED, tags=None).count()
unfulfilled_meta_packages = MetaPackage.query \
.filter(~ MetaPackage.packages.any(state=PackageState.APPROVED)) \
- .filter(MetaPackage.dependencies.any(optional=False)) \
+ .filter(MetaPackage.dependencies.any(Package.state == PackageState.APPROVED, optional=False)) \
.order_by(db.asc(MetaPackage.name)).count()
return render_template("todo/editor.html", current_tab="editor",
packages=packages, wip_packages=wip_packages, releases=releases, screenshots=screenshots,
canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn,
- total_packages=total_packages, total_to_tag=total_to_tag,
+ license_needed=license_needed, total_packages=total_packages, total_to_tag=total_to_tag,
unfulfilled_meta_packages=unfulfilled_meta_packages)
diff --git a/app/models/packages.py b/app/models/packages.py
index 3354c94c..24a51139 100644
--- a/app/models/packages.py
+++ b/app/models/packages.py
@@ -96,6 +96,19 @@ class PackageState(enum.Enum):
def __str__(self):
return self.name
+ @property
+ def color(self):
+ if self == self.WIP:
+ return "warning"
+ elif self == self.CHANGES_NEEDED:
+ return "danger"
+ elif self == self.READY_FOR_REVIEW:
+ return "success"
+ elif self == self.APPROVED:
+ return "info"
+ else:
+ return "danger"
+
@classmethod
def get(cls, name):
try:
diff --git a/app/templates/todo/editor.html b/app/templates/todo/editor.html
index 097a8162..572d321d 100644
--- a/app/templates/todo/editor.html
+++ b/app/templates/todo/editor.html
@@ -60,8 +60,6 @@
{% endif %}
{{ p.title }} by {{ p.author.display_name }}
-
-
{% else %}
No packages need reviewing.
@@ -102,6 +100,28 @@
{% endif %}
+ {% if license_needed %}
+ License Needed
+
+ {% endif %}
+
Tag Packages