Skip to content
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

[#1701] Changed User.get_full_name() to prefer .display_name over .first_name #769

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

Bartvaderkin
Copy link
Contributor

Ability to change this centrally shows why DRY code (like a method) is preferred over spreading ad-hoc code.

@@ -313,7 +313,8 @@ def seed(self):
return self._seed

def get_full_name(self):
parts = (self.first_name, self.infix, self.last_name)
first_name = self.display_name or self.first_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The display_name field uses CharFieldValidator, which allows strings containing only spaces. We probably don't want to prefer a display_name containing only space. We could should strip() and use isspace() to check for that or change the validator on the model field to prevent this from arising in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh that's not great. It is unlikely we have only-spaces values because form-fields use .strip() by default but I modified the code to be safe.

@alextreme alextreme merged commit 6b544f1 into develop Sep 28, 2023
14 checks passed
@alextreme alextreme deleted the fix/1701-user-display-name branch September 28, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants