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

fix: Set application default language #2206

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

shaohuzhang1
Copy link
Contributor

fix: Set application default language

Copy link

f2c-ci-robot bot commented Feb 10, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Feb 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -14,6 +12,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='applicationaccesstoken',
name='language',
field=models.CharField(default=application.models.api_key_model.get_language, max_length=10, verbose_name='语言'),
field=models.CharField(default=None, max_length=10, null=True, verbose_name='语言')
),
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no major issues with this code, but here's some minor feedback:

  1. default=None and null=True: The use of None and null=True for the language field means that it can be left blank when creating a new instance of ApplicationAccessToken. This might not be desired behavior if you always want to have a value set.

  2. Redundancy: You're calling application.models.api_key_model.get_language twice within different contexts—once directly on a model class ('models.CharField(...)), and once through an import statement (from application.models.api_key_model ...). If get_language is called elsewhere in your code, consider moving its implementation into a more central location or defining it only once at the top of your migration file.

  3. Consistency with other fields: Ensure consistency between optional attributes like null=True across all columns where it makes sense, especially those that store strings.

Overall, the migration looks clean and functional based on the current state.

@shaohuzhang1 shaohuzhang1 merged commit 0e68f4a into main Feb 10, 2025
4 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_application_language branch February 10, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant