diff --git a/app/models.py b/app/models.py
index 8f711469..2ce66479 100644
--- a/app/models.py
+++ b/app/models.py
@@ -608,6 +608,13 @@ class PackageRelease(db.Model):
name=self.package.name,
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):
self.releaseDate = datetime.now()
diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html
index eb9196d8..f5ff628c 100644
--- a/app/templates/packages/view.html
+++ b/app/templates/packages/view.html
@@ -196,7 +196,7 @@
{% if not rel.approved %}{% endif %}
- {{ rel.title }}{% if rel.commit_hash %}
+ {{ rel.title }}{% if rel.commit_hash %}
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
created {{ rel.releaseDate | datetime }}.
{% if rel.task_id %}
diff --git a/app/views/packages/releases.py b/app/views/packages/releases.py
index b6f5b20d..2aeca24b 100644
--- a/app/views/packages/releases.py
+++ b/app/views/packages/releases.py
@@ -91,6 +91,23 @@ def create_release_page(package):
return render_template("packages/release_new.html", package=package, form=form)
+@app.route("/packages///releases//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///releases//", methods=["GET", "POST"])
@login_required
@is_package_page