First pass

This commit is contained in:
zandercymatics 2025-01-29 11:57:16 -07:00
parent b18d126b7f
commit 992e86f7bb
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
6 changed files with 110 additions and 109 deletions

View file

@ -29,8 +29,8 @@ class DomainFixture(DomainRequestFixture):
def load(cls):
# Lumped under .atomic to ensure we don't make redundant DB calls.
# This bundles them all together, and then saves it in a single call.
with transaction.atomic():
try:
with transaction.atomic():
# Get the usernames of users created in the UserFixture
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]

View file

@ -87,8 +87,8 @@ class PortfolioFixture:
# Lumped under .atomic to ensure we don't make redundant DB calls.
# This bundles them all together, and then saves it in a single call.
with transaction.atomic():
try:
with transaction.atomic():
user = User.objects.all().last()
except Exception as e:
logger.warning(e)
@ -106,6 +106,7 @@ class PortfolioFixture:
continue
try:
with transaction.atomic():
portfolio = Portfolio(
creator=user,
organization_name=portfolio_data["organization_name"],

View file

@ -309,8 +309,8 @@ class DomainRequestFixture:
# The atomic block will cause the code to stop executing if one instance in the
# nested iteration fails, which will cause an early exit and make it hard to debug.
# Comment out with transaction.atomic() when debugging.
with transaction.atomic():
try:
with transaction.atomic():
# Get the usernames of users created in the UserFixture
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]

View file

@ -26,7 +26,6 @@ class UserPortfolioPermissionFixture:
# Lumped under .atomic to ensure we don't make redundant DB calls.
# This bundles them all together, and then saves it in a single call.
with transaction.atomic():
try:
# Get the usernames of users created in the UserFixture
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]

View file

@ -149,9 +149,9 @@ class Command(BaseCommand):
)
return
with transaction.atomic():
# Try to delete the portfolios
try:
with transaction.atomic():
summary = []
for portfolio in portfolios_to_delete:
portfolio_summary = [f"---- CASCADE SUMMARY for {portfolio.organization_name} -----"]

View file

@ -9,8 +9,9 @@ def ignore_unique_violation():
Execute within an atomic transaction so that if a unique constraint violation occurs,
the individual transaction is rolled back without invalidating any larger transaction.
"""
with transaction.atomic():
try:
# NOTE - is transaction doing anything here??
with transaction.atomic():
yield
except IntegrityError as e:
if e.__cause__.pgcode == errorcodes.UNIQUE_VIOLATION: