mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 06:24:12 +02:00
First pass
This commit is contained in:
parent
b18d126b7f
commit
992e86f7bb
6 changed files with 110 additions and 109 deletions
|
@ -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]
|
||||
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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} -----"]
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue