mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-09 17:13:45 +01:00
Disallow "_game" as a package name
This commit is contained in:
parent
3b140df508
commit
a8de369edf
@ -249,6 +249,10 @@ class PackageForm(FlaskForm):
|
|||||||
|
|
||||||
submit = SubmitField(lazy_gettext("Save"))
|
submit = SubmitField(lazy_gettext("Save"))
|
||||||
|
|
||||||
|
def validate_name(form, field):
|
||||||
|
if field.data == "_game":
|
||||||
|
raise ValidationError(lazy_gettext("_game is not an allowed name"))
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -382,7 +382,7 @@ class Package(db.Model):
|
|||||||
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
|
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
|
||||||
approved_at = db.Column(db.DateTime, nullable=True, default=None)
|
approved_at = db.Column(db.DateTime, nullable=True, default=None)
|
||||||
|
|
||||||
name_valid = db.CheckConstraint("name ~* '^[a-z0-9_]+$'")
|
name_valid = db.CheckConstraint("name ~* '^[a-z0-9_]+$' AND name != '_game'")
|
||||||
|
|
||||||
search_vector = db.Column(TSVectorType("name", "title", "short_desc", "desc",
|
search_vector = db.Column(TSVectorType("name", "title", "short_desc", "desc",
|
||||||
weights={ "name": "A", "title": "B", "short_desc": "C", "desc": "D" }))
|
weights={ "name": "A", "title": "B", "short_desc": "C", "desc": "D" }))
|
||||||
|
26
migrations/versions/6e59ad5cc62a_.py
Normal file
26
migrations/versions/6e59ad5cc62a_.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 6e59ad5cc62a
|
||||||
|
Revises: 8425c06b7d77
|
||||||
|
Create Date: 2022-06-25 02:39:15.959553
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '6e59ad5cc62a'
|
||||||
|
down_revision = '8425c06b7d77'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.drop_constraint("name_valid", "package", type_="check")
|
||||||
|
op.create_check_constraint("name_valid", "package", "name ~* '^[a-z0-9_]+$' AND name != '_game'")
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_constraint("name_valid", "package", type_="check")
|
||||||
|
op.create_check_constraint("name_valid", "package", "name ~* '^[a-z0-9_]+$'")
|
Loading…
Reference in New Issue
Block a user