mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-10 23:17:37 +01:00
Redirect to correct URL when _game is missing from package name
This commit is contained in:
parent
9a64809542
commit
d69da8e3ea
@ -266,6 +266,8 @@ def create_edit(author=None, name=None):
|
||||
|
||||
else:
|
||||
package = getPackageByInfo(author, name)
|
||||
if package is None:
|
||||
abort(404)
|
||||
if not package.checkPerm(current_user, Permission.EDIT_PACKAGE):
|
||||
return redirect(package.getDetailsURL())
|
||||
|
||||
|
17
app/utils.py
17
app/utils.py
@ -194,11 +194,11 @@ def rank_required(rank):
|
||||
def getPackageByInfo(author, name):
|
||||
user = User.query.filter_by(username=author).first()
|
||||
if user is None:
|
||||
abort(404)
|
||||
return None
|
||||
|
||||
package = Package.query.filter_by(name=name, author_id=user.id, soft_deleted=False).first()
|
||||
if package is None:
|
||||
abort(404)
|
||||
return None
|
||||
|
||||
return package
|
||||
|
||||
@ -208,7 +208,18 @@ def is_package_page(f):
|
||||
if not ("author" in kwargs and "name" in kwargs):
|
||||
abort(400)
|
||||
|
||||
package = getPackageByInfo(kwargs["author"], kwargs["name"])
|
||||
author = kwargs["author"]
|
||||
name = kwargs["name"]
|
||||
|
||||
package = getPackageByInfo(author, name)
|
||||
if package is None:
|
||||
package = getPackageByInfo(author, name + "_game")
|
||||
if package is None or package.type != PackageType.GAME:
|
||||
abort(404)
|
||||
|
||||
args = dict(kwargs)
|
||||
args["name"] = name + "_game"
|
||||
return redirect(url_for(request.endpoint, **args))
|
||||
|
||||
del kwargs["author"]
|
||||
del kwargs["name"]
|
||||
|
Loading…
Reference in New Issue
Block a user