mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +01:00
Prevent naming a package the same as a collection
This commit is contained in:
parent
ea2f1f4f6f
commit
eb81674f06
@ -281,7 +281,7 @@ class PackageForm(FlaskForm):
|
|||||||
def handle_create_edit(package: typing.Optional[Package], form: PackageForm, author: User):
|
def handle_create_edit(package: typing.Optional[Package], form: PackageForm, author: User):
|
||||||
wasNew = False
|
wasNew = False
|
||||||
if package is None:
|
if package is None:
|
||||||
package = Package.query.filter_by(name=form["name"].data, author_id=author.id).first()
|
package = Package.query.filter_by(name=form.name.data, author_id=author.id).first()
|
||||||
if package is not None:
|
if package is not None:
|
||||||
if package.state == PackageState.DELETED:
|
if package.state == PackageState.DELETED:
|
||||||
flash(
|
flash(
|
||||||
@ -293,6 +293,12 @@ def handle_create_edit(package: typing.Optional[Package], form: PackageForm, aut
|
|||||||
gettext("Package already exists")), "danger")
|
gettext("Package already exists")), "danger")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if Collection.query \
|
||||||
|
.filter(Collection.name == form.name.data, Collection.author == author) \
|
||||||
|
.count() > 0:
|
||||||
|
flash(gettext("A collection with a similar name already exists"), "danger")
|
||||||
|
return
|
||||||
|
|
||||||
package = Package()
|
package = Package()
|
||||||
db.session.add(package)
|
db.session.add(package)
|
||||||
package.author = author
|
package.author = author
|
||||||
|
Loading…
Reference in New Issue
Block a user