mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Check type and author in package details
This commit is contained in:
parent
bc88027fbe
commit
07a9b79396
@ -71,6 +71,17 @@ class PackageType(enum.Enum):
|
|||||||
else:
|
else:
|
||||||
return "TXP"
|
return "TXP"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def fromName(name):
|
||||||
|
if name == "mod":
|
||||||
|
return PackageType.MOD
|
||||||
|
elif name == "game":
|
||||||
|
return PackageType.GAME
|
||||||
|
elif name == "texturepacks":
|
||||||
|
return PackageType.TXP
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
class Package(db.Model):
|
class Package(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
|
@ -24,7 +24,12 @@ def txp_page():
|
|||||||
|
|
||||||
@app.route("/<type>s/<author>/<name>/")
|
@app.route("/<type>s/<author>/<name>/")
|
||||||
def package_page(type, author, name):
|
def package_page(type, author, name):
|
||||||
package = Package.query.filter_by(name=name).first()
|
user = User.query.filter_by(username=author).first()
|
||||||
|
if user is None:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
package = Package.query.filter_by(name=name, author_id=user.id,
|
||||||
|
type=PackageType.fromName(type)).first()
|
||||||
if package is None:
|
if package is None:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user