mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +01:00
Add release specific download URL
This commit is contained in:
parent
a3e82ad42f
commit
286207ffa2
@ -608,6 +608,13 @@ class PackageRelease(db.Model):
|
|||||||
name=self.package.name,
|
name=self.package.name,
|
||||||
id=self.id)
|
id=self.id)
|
||||||
|
|
||||||
|
def getDownloadURL(self):
|
||||||
|
return url_for("download_release_page",
|
||||||
|
author=self.package.author.username,
|
||||||
|
name=self.package.name,
|
||||||
|
id=self.id)
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.releaseDate = datetime.now()
|
self.releaseDate = datetime.now()
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@
|
|||||||
<li>
|
<li>
|
||||||
{% if not rel.approved %}<i>{% endif %}
|
{% if not rel.approved %}<i>{% endif %}
|
||||||
|
|
||||||
<a href="{{ rel.url }}">{{ rel.title }}</a>{% if rel.commit_hash %}
|
<a href="{{ rel.getDownloadURL() }}">{{ rel.title }}</a>{% if rel.commit_hash %}
|
||||||
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
|
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
|
||||||
created {{ rel.releaseDate | datetime }}.
|
created {{ rel.releaseDate | datetime }}.
|
||||||
{% if rel.task_id %}
|
{% if rel.task_id %}
|
||||||
|
@ -91,6 +91,23 @@ def create_release_page(package):
|
|||||||
|
|
||||||
return render_template("packages/release_new.html", package=package, form=form)
|
return render_template("packages/release_new.html", package=package, form=form)
|
||||||
|
|
||||||
|
@app.route("/packages/<author>/<name>/releases/<id>/download/")
|
||||||
|
@is_package_page
|
||||||
|
def download_release_page(package, id):
|
||||||
|
release = PackageRelease.query.get(id)
|
||||||
|
if release is None or release.package != package:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
if release is None:
|
||||||
|
if "application/zip" in request.accept_mimetypes and \
|
||||||
|
not "text/html" in request.accept_mimetypes:
|
||||||
|
return "", 204
|
||||||
|
else:
|
||||||
|
flash("No download available.", "error")
|
||||||
|
return redirect(package.getDetailsURL())
|
||||||
|
else:
|
||||||
|
return redirect(release.url, code=300)
|
||||||
|
|
||||||
@app.route("/packages/<author>/<name>/releases/<id>/", methods=["GET", "POST"])
|
@app.route("/packages/<author>/<name>/releases/<id>/", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
@is_package_page
|
@is_package_page
|
||||||
|
Loading…
Reference in New Issue
Block a user