-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: shorten profile name fields to 150 characters
First and last name need to be limited to 150 characters on the Profile model. Updates to name information are also sent to keycloak, which will put the name information into the API tokens that it produces. User model has 150 character name fields. Upon receiving an API token this backend will try to update the user object with the information in the token. If the name is over 150 characters an error will be produced and the user will be unable to use the API. Users with this error will also be unable to resolve the issue by themselves. Refs: HP-2344
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
profiles/migrations/0058_alter_profile_first_name_alter_profile_last_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 4.2.9 on 2024-04-17 10:00 | ||
|
||
from django.db import migrations | ||
from django.db.models.functions import Substr | ||
|
||
import utils.fields | ||
|
||
|
||
def truncate_name_fields(apps, schema_editor): | ||
Profile = apps.get_model("profiles", "Profile") | ||
Profile.objects.update( | ||
first_name=Substr("first_name", 1, 150), last_name=Substr("last_name", 1, 150) | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("profiles", "0057_remove_profile_id_default_value__noop"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(truncate_name_fields, migrations.RunPython.noop), | ||
migrations.AlterField( | ||
model_name="profile", | ||
name="first_name", | ||
field=utils.fields.NullToEmptyCharField( | ||
blank=True, db_index=True, max_length=150 | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="profile", | ||
name="last_name", | ||
field=utils.fields.NullToEmptyCharField( | ||
blank=True, db_index=True, max_length=150 | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters