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

Update the unique bed name constraint to ignore deleted beds #2423

Closed
sainak opened this issue Sep 4, 2024 · 2 comments · Fixed by #2432
Closed

Update the unique bed name constraint to ignore deleted beds #2423

sainak opened this issue Sep 4, 2024 · 2 comments · Fixed by #2432
Assignees
Labels
bug Something isn't working

Comments

@sainak
Copy link
Member

sainak commented Sep 4, 2024

class Meta:
constraints = [
models.UniqueConstraint(
models.functions.Lower("name"),
"location",
name="unique_bed_name_per_location",
)
]
def __str__(self):
return self.name
def validate(self) -> None:
if (
Bed.objects.filter(location=self.location, name__iexact=self.name)
.exclude(pk=self.pk)
.exists()
):
raise ValidationError(
{"name": "Bed with same name already exists in location."}
)

@sainak sainak added the bug Something isn't working label Sep 4, 2024
@sainak sainak added this to Care Sep 4, 2024
@github-project-automation github-project-automation bot moved this to Triage in Care Sep 4, 2024
@sainak sainak moved this from Triage to Up Next in Care Sep 4, 2024
@sainak sainak self-assigned this Sep 4, 2024
@DraKen0009
Copy link
Contributor

@sainak can I pick this issue ?

@sainak sainak moved this from Up Next to Review required in Care Sep 7, 2024
Copy link

sentry-io bot commented Sep 7, 2024

Sentry Issue: CARE-6TJ

@github-project-automation github-project-automation bot moved this from Review required to Done in Care Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants