From fb2552ab558b227f03a3b092eeb6a5f7bc406900 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 25 May 2018 19:06:05 +0100 Subject: [PATCH] Finish screenshot approval feature --- app/models.py | 5 +++-- app/templates/packages/screenshot_edit.html | 2 ++ app/templates/packages/view.html | 12 +++++++----- app/templates/todo.html | 19 ++++++++++++++++++- app/views/packages/__init__.py | 4 ++++ app/views/packages/todo.py | 9 +++++++-- 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/models.py b/app/models.py index e8b66fba..aa67c6a8 100644 --- a/app/models.py +++ b/app/models.py @@ -83,7 +83,8 @@ class Permission(enum.Enum): if self == Permission.APPROVE_NEW or \ self == Permission.APPROVE_CHANGES or \ - self == Permission.APPROVE_RELEASE: + self == Permission.APPROVE_RELEASE or \ + self == Permission.APPROVE_SCREENSHOT: return user.rank.atLeast(UserRank.EDITOR) else: raise Exception("Non-global permission checked globally. Use Package.checkPerm or User.checkPerm instead.") @@ -353,7 +354,7 @@ class Package(db.Model): author=self.author.username, name=self.name) def getMainScreenshotURL(self): - screenshot = self.screenshots.first() + screenshot = self.screenshots.filter_by(approved=True).first() return screenshot.url if screenshot is not None else None def getDownloadRelease(self): diff --git a/app/templates/packages/screenshot_edit.html b/app/templates/packages/screenshot_edit.html index 7e0f9dc5..b53c07e0 100644 --- a/app/templates/packages/screenshot_edit.html +++ b/app/templates/packages/screenshot_edit.html @@ -5,6 +5,8 @@ {% endblock %} {% block content %} + {{ screenshot.title }} + {% from "macros/forms.html" import render_field, render_submit_field %}
{{ form.hidden_tag() }} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 85a0b7d7..e0f03c01 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -41,11 +41,13 @@ diff --git a/app/templates/todo.html b/app/templates/todo.html index 35aee9ac..b20f26c6 100644 --- a/app/templates/todo.html +++ b/app/templates/todo.html @@ -8,7 +8,7 @@ {% if canApproveNew %}

Packages Awaiting Approval

{% endif %} + {% if canApproveScn %} +

Screenshots Awaiting Approval

+ + {% endfor %} + + {% endif %} + {% if canApproveRel %}

Releases Awaiting Approval