Skip to content

Commit

Permalink
django 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Justine Tunney committed Jun 6, 2012
1 parent 2e8870d commit 93be408
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 73 deletions.
3 changes: 2 additions & 1 deletion occupywallst/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"""

from django.utils.html import escape, urlquote
from django.utils.html import escape
from django.utils.http import urlquote
from django.contrib import admin, messages
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
Expand Down
5 changes: 0 additions & 5 deletions occupywallst/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
from django.utils.cache import add_never_cache_headers


class PrintException(object):
def process_exception(self, request, exception):
traceback.print_exc()


class NeverCache(object):
def process_response(self, request, response):
add_never_cache_headers(response)
Expand Down
69 changes: 67 additions & 2 deletions occupywallst/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = False
TIME_ZONE = 'UTC'
USE_TZ = True
TIME_ZONE = "US/Eastern"
DEFAULT_CHARSET = 'utf-8'
ROOT_URLCONF = 'occupywallst.urls'
LOGIN_URL = '/login/'
Expand All @@ -112,8 +113,9 @@
MEDIA_URL = '/media/'
STATIC_URL = '/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
# SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
SESSION_ENGINE = 'occupywallst.memcachedjson'
# SESSION_ENGINE = 'occupywallst.memcachedjson'
USE_X_FORWARDED_HOST = True
ROSETTA_MESSAGES_PER_PAGE = 25

Expand Down Expand Up @@ -181,6 +183,69 @@
'south',
]

LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"formatters": {
"verbose": {
"format": (GREEN + "%(asctime)s %(levelname)s "
"[%(filename)s:%(lineno)d] " + RESET + "%(message)s"),
},
"simple": {
"format": GREEN + "%(levelname)s " + RESET + "%(message)s",
},
"nocolor": {
"format": ("%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] "
"%(message)s"),
},
},
"handlers": {
"null": {
"level": "DEBUG",
"class": "django.utils.log.NullHandler",
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "simple",
},
"mail_admins": {
"level": "ERROR",
"class": "django.utils.log.AdminEmailHandler",
"include_html": True,
},
"occupywallst_file": {
"level": "INFO",
"class": "logging.FileHandler",
"formatter": "nocolor",
"filename": join(project_root, "../../log/occupywallst.log"),
},
"cdrproc_file": {
"level": "INFO",
"class": "logging.FileHandler",
"formatter": "nocolor",
"filename": join(project_root, "../../log/cdrproc.log"),
},
},
"loggers": {
"django": {
"level": "WARNING",
"handlers": ["console"],
"propagate": True,
},
"django.request": {
"level": "WARNING",
"handlers": ["console", "mail_admins"],
"propagate": False,
},
"occupywallst": {
"level": "WARNING",
"handlers": ["console", "occupywallst_file", "mail_admins"],
"propagate": False,
},
},
}

try:
from occupywallst.settings_local import *
except ImportError:
Expand Down
68 changes: 10 additions & 58 deletions occupywallst/settings_dev.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import sys
from occupywallst.settings import *

Expand All @@ -14,65 +13,18 @@
'127.0.0.1',
]

MIDDLEWARE_CLASSES += ['occupywallst.middleware.PrintException']

# MIDDLEWARE_CLASSES += ['debug_toolbar.middleware.DebugToolbarMiddleware']
# INSTALLED_APPS += ['debug_toolbar']

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': (GREEN + '%(asctime)s %(levelname)s %(name)s '
'%(filename)s:%(lineno)d ' + RESET + '%(message)s'),
},
'simple': {
'format': GREEN + '%(levelname)s ' + RESET + '%(message)s',
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'django.utils.log.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
},
},
'loggers': {
'django': {
'level': 'WARNING',
'handlers': ['console'],
'propagate': True,
},
'django.request': {
'level': 'WARNING',
'handlers': ['console', 'mail_admins'],
'propagate': False,
},
'occupywallst': {
'level': 'WARNING',
'handlers': ['console', 'mail_admins'],
'propagate': False,
},
},
MIDDLEWARE_CLASSES += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
INSTALLED_APPS += ["debug_toolbar"]
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}

LOGGING['loggers']['django']['level'] = 'DEBUG'
LOGGING['loggers']['django.request']['level'] = 'DEBUG'
LOGGING['loggers']['occupywallst']['level'] = 'DEBUG'
LOGGING['handlers']['console']['formatter'] = 'verbose'
LOGGING['handlers']['mail_admins'] = {'level': 'DEBUG',
'class': 'django.utils.log.NullHandler'}

LOGGING["loggers"]["django"]["level"] = "DEBUG"
LOGGING["loggers"]["django.request"]["level"] = "DEBUG"
LOGGING["loggers"]["occupywallst"]["level"] = "DEBUG"
LOGGING["handlers"]["console"]["formatter"] = "verbose"
LOGGING["handlers"]["mail_admins"] = {"level": "DEBUG",
"class": "django.utils.log.NullHandler"}

try:
from occupywallst.settings_dev_local import *
Expand Down
15 changes: 9 additions & 6 deletions occupywallst/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from datetime import datetime
from itertools import product

import redisbayes
from django.conf import settings
from django.test import TestCase
from django.contrib.gis.geos import Point
Expand Down Expand Up @@ -133,7 +134,8 @@ def new_article(user, **kwargs):
title=random_words(7),
slug=random_slug(),
content=random_words(20),
is_forum=True)
is_forum=True,
is_visible=True)
vals.update(kwargs)
return db.Article.objects.create(**vals)

Expand Down Expand Up @@ -215,7 +217,8 @@ def create_users(self):
self.mod_user.userinfo.save()

def setUp(self):
settings.OWS_LIMIT_VOTES = -1
redisbayes.RedisBayes().flush()
settings.OWS_LIMIT_VOTES = ()
settings.OWS_LIMIT_THREAD = -1
settings.OWS_LIMIT_COMMENT = -1
settings.OWS_LIMIT_MSG_DAY = 999999
Expand Down Expand Up @@ -755,13 +758,13 @@ def test_api_login_and_logout(self):
assert j['status'] == 'OK', jdump(j)
assert j['results'][0]['username'] == 'red', jdump(j)

# logging in again should fail
# logging in again should succeed
response = self.client.post('/api/login/',
{'username': 'blue',
'password': 'blue'})
j = assert_and_get_valid_json(response)
assert j['status'] == 'ERROR', jdump(j)
assert 'already logged in' in j['message'], jdump(j)
assert j['status'] == 'OK', jdump(j)
assert j['results'][0]['username'] == 'blue', jdump(j)

# logging out and in should succeed
response = self.client.post('/api/logout/')
Expand Down Expand Up @@ -888,7 +891,7 @@ def test_api_article(self):
response = self.client.post('/api/article_delete/',
{'article_slug': a.slug})
j = assert_and_get_valid_json(response)
assert j['status'] == 'ERROR' # TODO: confirm that this is correct
assert j['status'] == 'ZERO_RESULTS', jdump(j)

def test_api_comment(self):
settings.OWS_LIMIT_COMMENT = -1 # turn off limit for testing
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def read(fname):
author = 'Justine Tunney',
author_email = 'jtunney@lobstertech.com',
license = 'GNU AGPL v3 or later',
install_requires = ['Django==1.3.1', 'python-memcached>=1.40', 'pytz',
install_requires = ['Django>=1.4', 'python-memcached>=1.40', 'pytz',
'markdown', 'twilio', 'django-debug-toolbar',
'recaptcha-client', 'gunicorn', 'django-rosetta',
'django-imagekit', 'south', 'Whoosh', 'redis',
Expand Down

0 comments on commit 93be408

Please sign in to comment.