Skip to content

Commit

Permalink
Merge pull request #188 from edx/michaelroytman/user-model-full_name-…
Browse files Browse the repository at this point in the history
…empty

Alter User model full_name field to be non-nullable.
  • Loading branch information
MichaelRoytman authored Oct 2, 2023
2 parents 6321690 + ea96800 commit 38adf3e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
18 changes: 18 additions & 0 deletions edx_exams/apps/core/migrations/0019_alter_user_full_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.21 on 2023-10-02 20:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0018_staff_roles'),
]

operations = [
migrations.AlterField(
model_name='user',
name='full_name',
field=models.CharField(blank=True, default='', max_length=255, verbose_name='Full Name'),
),
]
3 changes: 2 additions & 1 deletion edx_exams/apps/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class User(AbstractUser):
.. pii_retirement: local_api
"""
full_name = models.CharField(_('Full Name'), max_length=255, blank=True, null=True)
# The default empty string was added to change full_name from nullable to non-nullable.
full_name = models.CharField(_('Full Name'), max_length=255, blank=True, default='')

lms_user_id = models.IntegerField(null=True, db_index=True)

Expand Down
2 changes: 1 addition & 1 deletion edx_exams/apps/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_get_full_name(self):

first_name = 'Jerry'
last_name = 'Seinfeld'
user = G(User, full_name=None, first_name=first_name, last_name=last_name)
user = G(User, first_name=first_name, last_name=last_name)
expected = '{first_name} {last_name}'.format(first_name=first_name, last_name=last_name)
self.assertEqual(user.get_full_name(), expected)

Expand Down

0 comments on commit 38adf3e

Please sign in to comment.