-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add first name and last name to signup and profile #2105
Add first name and last name to signup and profile #2105
Conversation
server/fishtest/schemas.py
Outdated
@@ -90,6 +90,8 @@ def size_is_length(x): | |||
user_schema = { | |||
"_id?": ObjectId, | |||
"username": username, | |||
"firstname": union("", str), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this union is redundant, btw I didn't include any regex, only length limit, because from experience no matter how smart you would be about a regex for names, you will either allow everything or miss the most obscure legal name ever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is redundant since “” is a string.
The union means that the object should either be equal to “” or else be of type string. This is equivalent to being of type string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this union is redundant, btw I didn't include any regex, only length limit, because from experience no matter how smart you would be about a regex for names, you will either allow everything or miss the most obscure legal name ever.
If you want to include a length limit (say 20) in the schema you can do it as
"firstname": intersect(str, size(0, 20))
The size(lb, ub)
schema matches objects that satisfy lb <= len(object) <= ub
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the limit is more to avoid spam rather than an intrinsic property of the names.. but noted for the future.. I guess this schema is possible because of vtjson, thanks for the package!
DEV updated. |
Jul 04 23:30:22 dfts-0 pserve[102834]: Traceback (most recent call last):
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/env/lib/python3.12/site-packages/pyramid_mako/__init__.py", line 148, in __call__
Jul 04 23:30:22 dfts-0 pserve[102834]: result = template.render_unicode(**system)
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/env/lib/python3.12/site-packages/mako/template.py", line 443, in render_unicode
Jul 04 23:30:22 dfts-0 pserve[102834]: return runtime._render(
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/env/lib/python3.12/site-packages/mako/runtime.py", line 874, in _render
Jul 04 23:30:22 dfts-0 pserve[102834]: _render_context(
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/env/lib/python3.12/site-packages/mako/runtime.py", line 916, in _render_context
Jul 04 23:30:22 dfts-0 pserve[102834]: _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/env/lib/python3.12/site-packages/mako/runtime.py", line 943, in _exec_template
Jul 04 23:30:22 dfts-0 pserve[102834]: callable_(context, *args, **kwargs)
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/fishtest/templates/base.mak", line 561, in render_body
Jul 04 23:30:22 dfts-0 pserve[102834]: <div>${self.body()}</div>
Jul 04 23:30:22 dfts-0 pserve[102834]: File "/home/usr00/fishtest/server/fishtest/templates/user.mak", line 90, in render_body
Jul 04 23:30:22 dfts-0 pserve[102834]: value="${user['firstname']}"
Jul 04 23:30:22 dfts-0 pserve[102834]: KeyError: 'firstname'
|
I think I mentioned above that we need to add such keys to every old user before this can be tested.. now while the current way of perfectly making the schema predictable in the mako rendering side, I agree that it might feel shaky that thereis one point of failure. But at the same time not using |
Please consider using this version which I updated to fulfill this request: https://github.com/maximmasiutin/fishtest-contributors/blob/main/fishtest_contributors.py You may copy this file to your own repository, be it a separate repository for this script that you may create, or just add it to an existing repository such as the main Stockfish repository, so that you would not need to maintain this file separately. |
I prefer one single display name field to two first/last name fields because 1) middle name does exist and 2) some people in Indonesia have only one name afaik. |
I like the idea of a display name as well. |
not tested yet, needs adding the fields to the user collection (converting db), but still optional for those who prefer to be anonymous.