This file contains hidden or 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
# middlewares.py | |
import threading | |
_thread_locals = threading.local() | |
def get_current_user(): | |
"""Returns the current user.""" | |
return getattr(_thread_locals, 'user', None) |
This file contains hidden or 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
import unittest | |
import os | |
import django.core.handlers.wsgi | |
from ghost import GhostTestCase | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' | |
app = django.core.handlers.wsgi.WSGIHandler() | |
This file contains hidden or 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
import pycountry | |
class CountrySelectField(SelectField): | |
def __init__(self, *args, **kwargs): | |
super(CountrySelectField, self).__init__(*args, **kwargs) | |
self.choices = [(c.alpha3, c.name) for c in pycountry.countries] |
NewerOlder