-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make donations configurable Added donation button to dashboard Generalize merchant defined data for payment processor
- Loading branch information
Will Daly
committed
Oct 7, 2014
1 parent
8d60a8b
commit 6442e87
Showing
22 changed files
with
1,070 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Decorators for model-based configuration. """ | ||
from functools import wraps | ||
from django.http import HttpResponseNotFound | ||
|
||
|
||
def require_config(config_model): | ||
"""View decorator that enables/disables a view based on configuration. | ||
Arguments: | ||
config_model (ConfigurationModel subclass): The class of the configuration | ||
model to check. | ||
Returns: | ||
HttpResponse: 404 if the configuration model is disabled, | ||
otherwise returns the response from the decorated view. | ||
""" | ||
def _decorator(func): | ||
@wraps(func) | ||
def _inner(*args, **kwargs): | ||
if not config_model.current().enabled: | ||
return HttpResponseNotFound() | ||
else: | ||
return func(*args, **kwargs) | ||
return _inner | ||
return _decorator |
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
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
Oops, something went wrong.