-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from JamesRitchie/default_settings
Provide default settings
- Loading branch information
Showing
3 changed files
with
32 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Provides access to settings. | ||
Returns defaults if not set. | ||
""" | ||
from datetime import timedelta | ||
|
||
from django.conf import settings | ||
|
||
|
||
class TokenSettings(object): | ||
|
||
"""Provides settings as defaults for working with tokens.""" | ||
|
||
@property | ||
def EXPIRING_TOKEN_LIFESPAN(self): | ||
""" | ||
Return the allowed lifespan of a token as a TimeDelta object. | ||
Defaults to 30 days. | ||
""" | ||
try: | ||
val = settings.EXPIRING_TOKEN_LIFESPAN | ||
except AttributeError: | ||
val = timedelta(days=30) | ||
|
||
return val | ||
|
||
token_settings = TokenSettings() |
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 |
---|---|---|
|
@@ -31,5 +31,3 @@ | |
} | ||
|
||
ROOT_URLCONF = 'tests.urls' | ||
|
||
EXPIRING_TOKEN_LIFESPAN = timedelta(days=30) |