-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out test for whether we are in a transaction.
- Loading branch information
Showing
2 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
from django.contrib.sites.models import Site | ||
from django.core import mail | ||
from django.db import transaction | ||
|
||
|
||
def get_current_site(): | ||
if Site._meta.installed: | ||
return Site.objects.get_current() | ||
return None | ||
|
||
def in_transaction(test_ignore=True): | ||
result = transaction.is_managed() | ||
if test_ignore: | ||
# Ignore when running inside a Django test case, which uses | ||
# transactions. | ||
result = result and not hasattr(mail, 'outbox') | ||
return result |