mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add custom 404 page
This commit is contained in:
parent
c2994a27fd
commit
8dbd22f56c
@ -114,3 +114,7 @@ from .utils import clearNotifications
|
|||||||
def check_for_notifications():
|
def check_for_notifications():
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
clearNotifications(request.path)
|
clearNotifications(request.path)
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def page_not_found(e):
|
||||||
|
return render_template("404.html"), 404
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from flask import request, jsonify, current_app, abort
|
from flask import request, jsonify, current_app
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
@ -115,11 +115,11 @@ def topic_set_discard():
|
|||||||
tid = request.args.get("tid")
|
tid = request.args.get("tid")
|
||||||
discard = request.args.get("discard")
|
discard = request.args.get("discard")
|
||||||
if tid is None or discard is None:
|
if tid is None or discard is None:
|
||||||
abort(400)
|
error(400, "Missing topic ID or discard bool")
|
||||||
|
|
||||||
topic = ForumTopic.query.get(tid)
|
topic = ForumTopic.query.get(tid)
|
||||||
if not topic.checkPerm(current_user, Permission.TOPIC_DISCARD):
|
if not topic.checkPerm(current_user, Permission.TOPIC_DISCARD):
|
||||||
abort(403)
|
error(403, "Permission denied, need: TOPIC_DISCARD")
|
||||||
|
|
||||||
topic.discarded = discard == "true"
|
topic.discarded = discard == "true"
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@ -151,13 +151,13 @@ def list_all_releases():
|
|||||||
if "author" in request.args:
|
if "author" in request.args:
|
||||||
author = User.query.filter_by(username=request.args["author"]).first()
|
author = User.query.filter_by(username=request.args["author"]).first()
|
||||||
if author is None:
|
if author is None:
|
||||||
abort(404)
|
error(404, "Author not found")
|
||||||
query = query.filter(PackageRelease.package.has(author=author))
|
query = query.filter(PackageRelease.package.has(author=author))
|
||||||
|
|
||||||
if "maintainer" in request.args:
|
if "maintainer" in request.args:
|
||||||
maintainer = User.query.filter_by(username=request.args["maintainer"]).first()
|
maintainer = User.query.filter_by(username=request.args["maintainer"]).first()
|
||||||
if maintainer is None:
|
if maintainer is None:
|
||||||
abort(404)
|
error(404, "Maintainer not found")
|
||||||
query = query.join(Package)
|
query = query.join(Package)
|
||||||
query = query.filter(Package.maintainers.any(id=maintainer.id))
|
query = query.filter(Package.maintainers.any(id=maintainer.id))
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ Supported query parameters:
|
|||||||
* `min_minetest_version`: dict or null, minimum supported minetest version (inclusive).
|
* `min_minetest_version`: dict or null, minimum supported minetest version (inclusive).
|
||||||
* `max_minetest_version`: dict or null, minimum supported minetest version (inclusive).
|
* `max_minetest_version`: dict or null, minimum supported minetest version (inclusive).
|
||||||
* `package`
|
* `package`
|
||||||
* `author`: author username.
|
* `author`: author username
|
||||||
* `name`
|
* `name`: technical name
|
||||||
* `type`: `mod`, `game`, or `txp`
|
* `type`: `mod`, `game`, or `txp`
|
||||||
* GET `/api/packages/<username>/<name>/releases/` (List)
|
* GET `/api/packages/<username>/<name>/releases/` (List)
|
||||||
* Returns array of release dictionaries, see above, but without package info.
|
* Returns array of release dictionaries, see above, but without package info.
|
||||||
|
13
app/templates/404.html
Normal file
13
app/templates/404.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Page not found
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Page not found</h1>
|
||||||
|
<p>
|
||||||
|
That page could not be found. The link may be broken, the page may have been deleted,
|
||||||
|
or you may not have access to it.
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user