mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Improve new screenshot behaviour
This commit is contained in:
parent
f93a2d8717
commit
4226e945e6
@ -45,6 +45,9 @@ def screenshots(package):
|
||||
if not package.checkPerm(current_user, Permission.ADD_SCREENSHOTS):
|
||||
return redirect(package.getDetailsURL())
|
||||
|
||||
if package.screenshots.count() == 0:
|
||||
return redirect(package.getNewScreenshotURL())
|
||||
|
||||
if request.method == "POST":
|
||||
order = request.form.get("order")
|
||||
if order:
|
||||
@ -76,11 +79,17 @@ def create_screenshot(package):
|
||||
uploadedUrl, uploadedPath = doFileUpload(form.fileUpload.data, "image",
|
||||
"a PNG or JPG image file")
|
||||
if uploadedUrl is not None:
|
||||
counter = 1
|
||||
for screenshot in package.screenshots:
|
||||
screenshot.order = counter
|
||||
counter += 1
|
||||
|
||||
ss = PackageScreenshot()
|
||||
ss.package = package
|
||||
ss.title = form["title"].data or "Untitled"
|
||||
ss.url = uploadedUrl
|
||||
ss.approved = package.checkPerm(current_user, Permission.APPROVE_SCREENSHOT)
|
||||
ss.order = counter
|
||||
db.session.add(ss)
|
||||
|
||||
msg = "Screenshot added {}" \
|
||||
|
@ -37,13 +37,17 @@
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<li class="list-group-item">
|
||||
<i>No screenshots.</i>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<form action="" method="POST" class="form mt-4" role="form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<input type="hidden" name="order" value="" />
|
||||
<input type="submit" value="{{ _("Update Order") }}" class="btn btn-primary">
|
||||
<input type="submit" value="{{ _("Save Order") }}" class="btn btn-primary">
|
||||
</form>
|
||||
|
||||
<noscript>
|
||||
|
@ -382,7 +382,7 @@
|
||||
|
||||
{% if package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
|
||||
<a href="{{ package.getEditScreenshotsURL() }}" class="btn btn-primary float-right">
|
||||
<i class="fas fa-edit"></i>
|
||||
<i class="fas fa-images mr-1"></i>
|
||||
Edit
|
||||
</a>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user