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

refactor(apis_metainfo): move clean_uri from get_or_create to get #566

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apis_core/apis_metainfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ class InheritanceForeignKey(models.ForeignKey):


# Uri model
# We use a custom UriManager, so we can override the queryset `get_or_create`
# method. This is useful because we normalize the uri field before saving.
# We use a custom UriManager, so we can override the queryset `get`
# method. This way we can normalize the uri field.


class UriQuerySet(models.query.QuerySet):
def get_or_create(self, defaults=None, **kwargs):
def get(self, *args, **kwargs):
if "uri" in kwargs:
kwargs["uri"] = clean_uri(kwargs["uri"])
return super().get_or_create(defaults, **kwargs)
return super().get(*args, **kwargs)


class UriManager(models.Manager):
Expand Down
Loading