mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 22:44:11 +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):
|
def load(cls):
|
||||||
# Lumped under .atomic to ensure we don't make redundant DB calls.
|
# 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.
|
# This bundles them all together, and then saves it in a single call.
|
||||||
with transaction.atomic():
|
|
||||||
try:
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
# Get the usernames of users created in the UserFixture
|
# Get the usernames of users created in the UserFixture
|
||||||
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]
|
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.
|
# 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.
|
# This bundles them all together, and then saves it in a single call.
|
||||||
with transaction.atomic():
|
|
||||||
try:
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
user = User.objects.all().last()
|
user = User.objects.all().last()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
|
@ -106,6 +106,7 @@ class PortfolioFixture:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
portfolio = Portfolio(
|
portfolio = Portfolio(
|
||||||
creator=user,
|
creator=user,
|
||||||
organization_name=portfolio_data["organization_name"],
|
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
|
# 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.
|
# nested iteration fails, which will cause an early exit and make it hard to debug.
|
||||||
# Comment out with transaction.atomic() when debugging.
|
# Comment out with transaction.atomic() when debugging.
|
||||||
with transaction.atomic():
|
|
||||||
try:
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
# Get the usernames of users created in the UserFixture
|
# Get the usernames of users created in the UserFixture
|
||||||
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]
|
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.
|
# 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.
|
# This bundles them all together, and then saves it in a single call.
|
||||||
with transaction.atomic():
|
|
||||||
try:
|
try:
|
||||||
# Get the usernames of users created in the UserFixture
|
# Get the usernames of users created in the UserFixture
|
||||||
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]
|
created_usernames = [user_data["username"] for user_data in UserFixture.ADMINS + UserFixture.STAFF]
|
||||||
|
|
|
@ -149,9 +149,9 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
with transaction.atomic():
|
|
||||||
# Try to delete the portfolios
|
# Try to delete the portfolios
|
||||||
try:
|
try:
|
||||||
|
with transaction.atomic():
|
||||||
summary = []
|
summary = []
|
||||||
for portfolio in portfolios_to_delete:
|
for portfolio in portfolios_to_delete:
|
||||||
portfolio_summary = [f"---- CASCADE SUMMARY for {portfolio.organization_name} -----"]
|
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,
|
Execute within an atomic transaction so that if a unique constraint violation occurs,
|
||||||
the individual transaction is rolled back without invalidating any larger transaction.
|
the individual transaction is rolled back without invalidating any larger transaction.
|
||||||
"""
|
"""
|
||||||
with transaction.atomic():
|
|
||||||
try:
|
try:
|
||||||
|
# NOTE - is transaction doing anything here??
|
||||||
|
with transaction.atomic():
|
||||||
yield
|
yield
|
||||||
except IntegrityError as e:
|
except IntegrityError as e:
|
||||||
if e.__cause__.pgcode == errorcodes.UNIQUE_VIOLATION:
|
if e.__cause__.pgcode == errorcodes.UNIQUE_VIOLATION:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue