sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #06319
Re: [Merge] ~thorsten-merten/maas-site-manager:MAASENG-1486-add-testdata into maas-site-manager:main
Added answers to inline comments. Branch update incoming
Diff comments:
> diff --git a/backend/msm/schema.py b/backend/msm/schema.py
> index 38a4ad5..10c726d 100644
> --- a/backend/msm/schema.py
> +++ b/backend/msm/schema.py
> @@ -2,9 +2,42 @@ from datetime import (
> datetime,
> timedelta,
> )
> +from decimal import Decimal
> from uuid import UUID
>
> -from pydantic import BaseModel
> +from pydantic import (
> + BaseModel,
> + SecretStr,
> +)
> +from pydantic.fields import Field
> +
> +# see discussion at
> +# https://stackabuse.com/python-validate-email-address-with-regular-expressions-regex/
> +valid_email = r"""
Changing to use EmailStr
> + ([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|
> + \"([]!#-[^-~ \t]|(\\[\t -~]))+\")
> + @
> + ([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\[[\t -Z^-~]*])"""
> +
> +
> +class CreateUser(BaseModel):
> + """
> + A MAAS Site Manager User
> + """
> +
> + email: str = Field(
FYI. This in turn uses python-email-validator, which uses regex:
https://github.com/JoshData/python-email-validator/blob/db0ebfe1d030ca8518366027c1f6084e969ab9f2/email_validator/rfc_constants.py#L33
(It does look more sophisticated though, and thus I am changing it)
> + title="email@xxxxxxxxxxx",
> + max_length=250,
> + min_length=3,
> + regex=valid_email,
> + )
> + full_name: str
> + password: SecretStr = Field(min_length=8, max_length=50)
Changing column size to max 360 according to rfc3696. python-email-validator takes care of min/max for us here now. (theoretical min length of an email is 3 chars)
> + disabled: bool
> +
> +
> +class User(CreateUser):
> + id: int
>
>
> class CreateSite(BaseModel):
> @@ -13,14 +46,13 @@ class CreateSite(BaseModel):
> """
>
> name: str
> - identifier: str
> city: str | None
> - latitude: str | None
> - longitude: str | None
> + latitude: str | Decimal | None
Changing to string only as it is used to convert incoming data automatically (coming as strings from via JSON)
> + longitude: str | Decimal | None
> note: str | None
> region: str | None
> street: str | None
> - timezone: str | None
> + timezone: str | Decimal | None
> url: str
> # TODO: we will need to add tags
>
--
https://code.launchpad.net/~thorsten-merten/maas-site-manager/+git/maas-site-manager/+merge/439266
Your team MAAS Committers is subscribed to branch ~thorsten-merten/maas-site-manager:MAASENG-1486-add-testdata.
References