mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-11 07:27:36 +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):
|
if not package.checkPerm(current_user, Permission.ADD_SCREENSHOTS):
|
||||||
return redirect(package.getDetailsURL())
|
return redirect(package.getDetailsURL())
|
||||||
|
|
||||||
|
if package.screenshots.count() == 0:
|
||||||
|
return redirect(package.getNewScreenshotURL())
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
order = request.form.get("order")
|
order = request.form.get("order")
|
||||||
if order:
|
if order:
|
||||||
@ -76,11 +79,17 @@ def create_screenshot(package):
|
|||||||
uploadedUrl, uploadedPath = doFileUpload(form.fileUpload.data, "image",
|
uploadedUrl, uploadedPath = doFileUpload(form.fileUpload.data, "image",
|
||||||
"a PNG or JPG image file")
|
"a PNG or JPG image file")
|
||||||
if uploadedUrl is not None:
|
if uploadedUrl is not None:
|
||||||
|
counter = 1
|
||||||
|
for screenshot in package.screenshots:
|
||||||
|
screenshot.order = counter
|
||||||
|
counter += 1
|
||||||
|
|
||||||
ss = PackageScreenshot()
|
ss = PackageScreenshot()
|
||||||
ss.package = package
|
ss.package = package
|
||||||
ss.title = form["title"].data or "Untitled"
|
ss.title = form["title"].data or "Untitled"
|
||||||
ss.url = uploadedUrl
|
ss.url = uploadedUrl
|
||||||
ss.approved = package.checkPerm(current_user, Permission.APPROVE_SCREENSHOT)
|
ss.approved = package.checkPerm(current_user, Permission.APPROVE_SCREENSHOT)
|
||||||
|
ss.order = counter
|
||||||
db.session.add(ss)
|
db.session.add(ss)
|
||||||
|
|
||||||
msg = "Screenshot added {}" \
|
msg = "Screenshot added {}" \
|
||||||
|
@ -37,13 +37,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<li class="list-group-item">
|
||||||
|
<i>No screenshots.</i>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<form action="" method="POST" class="form mt-4" role="form">
|
<form action="" method="POST" class="form mt-4" role="form">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<input type="hidden" name="order" value="" />
|
<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>
|
</form>
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
<header class="jumbotron pb-3"
|
<header class="jumbotron pb-3"
|
||||||
style="background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.7)), url('{{ package.getMainScreenshotURL() }}');
|
style="background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.7)), url('{{ package.getMainScreenshotURL() }}');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;">
|
background-position: center;">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="display-3">
|
<h1 class="display-3">
|
||||||
{{ package.title }}
|
{{ package.title }}
|
||||||
@ -382,7 +382,7 @@
|
|||||||
|
|
||||||
{% if package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
|
{% if package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
|
||||||
<a href="{{ package.getEditScreenshotsURL() }}" class="btn btn-primary float-right">
|
<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
|
Edit
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user