mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Finish screenshot approval feature
This commit is contained in:
parent
53df124973
commit
fb2552ab55
@ -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):
|
||||
|
@ -5,6 +5,8 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<img src="{{ screenshot.getThumbnailURL() }}" alt="{{ screenshot.title }}" />
|
||||
|
||||
{% from "macros/forms.html" import render_field, render_submit_field %}
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
{{ form.hidden_tag() }}
|
||||
|
@ -41,11 +41,13 @@
|
||||
|
||||
<ul class="screenshot_list">
|
||||
{% for ss in package.screenshots %}
|
||||
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
|
||||
<li>
|
||||
<a href="{% if package.checkPerm(current_user, 'ADD_SCREENSHOTS') %}{{ ss.getEditURL() }}{% else %}{{ ss.url }}{% endif %}">
|
||||
<img src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
{% if canApproveNew %}
|
||||
<h2>Packages Awaiting Approval</h2>
|
||||
<ul>
|
||||
{% for p in approve_new %}
|
||||
{% for p in packages %}
|
||||
<li><a href="{{ p.getDetailsURL() }}">
|
||||
{{ p.title }} by {{ p.author.display_name }}
|
||||
</a></li>
|
||||
@ -18,6 +18,23 @@
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if canApproveScn %}
|
||||
<h2>Screenshots Awaiting Approval</h2>
|
||||
<ul>
|
||||
{% for s in screenshots %}
|
||||
<li>
|
||||
<a href="{{ s.getEditURL() }}">{{ s.title }}</a>
|
||||
on
|
||||
<a href="{{ s.package.getDetailsURL() }}">
|
||||
{{ s.package.title }} by {{ s.package.author.display_name }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li><i>No screenshots need reviewing.</i></ul>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if canApproveRel %}
|
||||
<h2>Releases Awaiting Approval</h2>
|
||||
<ul>
|
||||
|
@ -195,6 +195,10 @@ def approve_package_page(package):
|
||||
else:
|
||||
package.approved = True
|
||||
|
||||
screenshots = PackageScreenshot.query.filter_by(package=package, approved=False).all()
|
||||
for s in screenshots:
|
||||
screenshots.approved = True
|
||||
|
||||
triggerNotif(package.author, current_user,
|
||||
"{} approved".format(package.title), package.getDetailsURL())
|
||||
db.session.commit()
|
||||
|
@ -26,6 +26,7 @@ from app.models import *
|
||||
def todo_page():
|
||||
canApproveNew = Permission.APPROVE_NEW.check(current_user)
|
||||
canApproveRel = Permission.APPROVE_RELEASE.check(current_user)
|
||||
canApproveScn = Permission.APPROVE_SCREENSHOT.check(current_user)
|
||||
|
||||
packages = None
|
||||
if canApproveNew:
|
||||
@ -35,6 +36,10 @@ def todo_page():
|
||||
if canApproveRel:
|
||||
releases = PackageRelease.query.filter_by(approved=False).all()
|
||||
|
||||
screenshots = None
|
||||
if canApproveScn:
|
||||
screenshots = PackageScreenshot.query.filter_by(approved=False).all()
|
||||
|
||||
return render_template("todo.html", title="Reports and Work Queue",
|
||||
approve_new=packages, releases=releases,
|
||||
canApproveNew=canApproveNew, canApproveRel=canApproveRel)
|
||||
packages=packages, releases=releases, screenshots=screenshots,
|
||||
canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn)
|
||||
|
Loading…
Reference in New Issue
Block a user