Skip to content

Commit

Permalink
Cleaner, uniform settings declarations using env.get defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
ndarville committed Mar 23, 2013
1 parent 07d89ac commit d1e54c7
Showing 1 changed file with 18 additions and 39 deletions.
57 changes: 18 additions & 39 deletions ponyforum/settings.py
Expand Up @@ -65,17 +65,11 @@
# timezone as the operating system. # timezone as the operating system.
# If running in a Windows environment this must be set to the same as your # If running in a Windows environment this must be set to the same as your
# system time zone. # system time zone.
if not LOCAL_DEVELOPMENT: TIME_ZONE = env.get('TIME_ZONE', 'America/Chicago')
TIME_ZONE = env.get('TIME_ZONE', 'America/Chicago')
else:
TIME_ZONE = 'America/Chicago'


# Language code for this installation. All choices can be found here: # Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html # http://www.i18nguy.com/unicode/language-identifiers.html
if not LOCAL_DEVELOPMENT: LANGUAGE_CODE = env.get('LANGUAGE_CODE', 'en-us')
LANGUAGE_CODE = env.get('LANGUAGE_CODE', 'en-us')
else:
LANGUAGE_CODE = 'en-us'


SITE_ID = 1 SITE_ID = 1


Expand Down Expand Up @@ -225,22 +219,13 @@
} }


### PONY-FORUM APP ### PONY-FORUM APP
if LOCAL_DEVELOPMENT: POSTS_PER_PAGE = int(env.get('POSTS_PER_PAGE', '25'))
POSTS_PER_PAGE = 25 THREADS_PER_PAGE = int(env.get('THREADS_PER_PAGE', '25'))
THREADS_PER_PAGE = 25 USER_POSTS_PER_PAGE = int(env.get('USER_POSTS_PER_PAGE', '10'))
USER_POSTS_PER_PAGE = 10 USER_THREADS_PER_PAGE = int(env.get('USER_THREADS_PER_PAGE', '25'))
USER_THREADS_PER_PAGE = 25 SUBSCRIPTIONS_PER_PAGE = int(env.get('SUBSCRIPTIONS_PER_PAGE', '25'))
SUBSCRIPTIONS_PER_PAGE = 25 BOOKMARKS_PER_PAGE = int(env.get('BOOKMARKS_PER_PAGE', '35'))
BOOKMARKS_PER_PAGE = 35 SAVES_PER_PAGE = int(env.get('SAVES_PER_PAGE', '10'))
SAVES_PER_PAGE = 10
else:
POSTS_PER_PAGE = int(env.get('POSTS_PER_PAGE', '25'))
THREADS_PER_PAGE = int(env.get('THREADS_PER_PAGE', '25'))
USER_POSTS_PER_PAGE = int(env.get('USER_POSTS_PER_PAGE', '10'))
USER_THREADS_PER_PAGE = int(env.get('USER_THREADS_PER_PAGE', '25'))
SUBSCRIPTIONS_PER_PAGE = int(env.get('SUBSCRIPTIONS_PER_PAGE', '25'))
BOOKMARKS_PER_PAGE = int(env.get('BOOKMARKS_PER_PAGE', '35'))
SAVES_PER_PAGE = int(env.get('SAVES_PER_PAGE', '10'))


# If you change these default values without changing the URLs style.css, # If you change these default values without changing the URLs style.css,
# the icons will break, because their URLs are hardcoded. # the icons will break, because their URLs are hardcoded.
Expand All @@ -255,24 +240,18 @@


### E-MAIL SERVER ### E-MAIL SERVER
## http://sontek.net/using-gmail-to-send-e-mails-from-django ## http://sontek.net/using-gmail-to-send-e-mails-from-django
if not LOCAL_DEVELOPMENT: EMAIL_HOST = env.get('EMAIL_HOST', 'smtp.gmail.com')
EMAIL_HOST = env.get('EMAIL_HOST', 'smtp.gmail.com') EMAIL_HOST_USER = env.get('EMAIL_HOST_USER', 'myusername@gmail.com')
EMAIL_HOST_USER = env.get('EMAIL_HOST_USER', 'myusername@gmail.com') EMAIL_HOST_PASSWORD = env.get('EMAIL_HOST_PASSWORD', 'mypassword')
EMAIL_HOST_PASSWORD = env.get('EMAIL_HOST_PASSWORD', 'mypassword') EMAIL_PORT = int(env.get('EMAIL_PORT', '587'))
EMAIL_PORT = int(env.get('EMAIL_PORT', '587')) EMAIL_USE_TLS = env.get('EMAIL_USE_TLS', 'True') == 'True'
EMAIL_USE_TLS = env.get('EMAIL_USE_TLS', 'True') == 'True' # DEFAULT_FROM_EMAIL = env.get('DEFAULT_FROM_EMAIL', 'noreply@equestria.pony')
DEFAULT_FROM_EMAIL = env.get('DEFAULT_FROM_EMAIL', # EMAIL_SUBJECT_PREFIX = "" # Doesn't work, optional
'noreply@equestria.pony')
# EMAIL_SUBJECT_PREFIX = "" # Doesn't work, optional
### ###


### DJANGO-REGISTRATION ### DJANGO-REGISTRATION
if LOCAL_DEVELOPMENT: ACCOUNT_ACTIVATION_DAYS = int(env.get('ACCOUNT_ACTIVATION_DAYS', '7'))
ACCOUNT_ACTIVATION_DAYS = 7 REGISTRATION_OPEN = env.get('REGISTRATION_OPEN', 'True') == 'True'
REGISTRATION_OPEN = True
else:
ACCOUNT_ACTIVATION_DAYS = int(env.get('ACCOUNT_ACTIVATION_DAYS', '7'))
REGISTRATION_OPEN = env.get('REGISTRATION_OPEN', 'True') == 'True'
### ###


### DJANGO-SECURE HTTPS ### DJANGO-SECURE HTTPS
Expand Down

0 comments on commit d1e54c7

Please sign in to comment.