Skip to content

Commit

Permalink
Rename Django project to zproject.
Browse files Browse the repository at this point in the history
This includes a hack to preserve humbug/backends.py as a symlink, so
that we don't need to regenerate all our old sessions.

(imported from commit b7918988b31c71ec01bbdc270db7017d4069221d)
  • Loading branch information
timabbott committed Aug 7, 2013
1 parent 44057cb commit 7b9305b
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 85 deletions.
60 changes: 0 additions & 60 deletions humbug/backends.py

This file was deleted.

1 change: 1 addition & 0 deletions humbug/backends.py
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if "--no-traceback" not in sys.argv and len(sys.argv) > 1:
sys.argv.append("--traceback")

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "humbug.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")

from django.core.management import execute_from_command_line

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import datetime
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = "humbug.settings"
os.environ['DJANGO_SETTINGS_MODULE'] = "zproject.settings"
sys.path.append('/home/humbug/humbug-deployments/current')
sys.path.append('/home/humbug/humbug-deployments/current/zerver')

Expand Down
2 changes: 1 addition & 1 deletion tools/check-all
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ node_modules
""".split()

exclude_files = """
humbug/test_settings.py
zproject/test_settings.py
tools/jslint/jslint.js
""".split()

Expand Down
2 changes: 1 addition & 1 deletion tools/minify-js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ prev_deploy = options.prev_deploy
# We have to pull out JS_SPECS, defined in our settings file, so we know what
# JavaScript source files to minify (and what output files to create).
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'humbug.settings'
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
from django.conf import settings

os.chdir(settings.DEPLOY_ROOT)
Expand Down
2 changes: 1 addition & 1 deletion tools/run-dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
manage_args = ''
if options.test:
base_port = 9981
manage_args = '--settings=humbug.test_settings'
manage_args = '--settings=zproject.test_settings'

proxy_port = base_port
django_port = base_port+1
Expand Down
2 changes: 1 addition & 1 deletion tools/test-backend
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ cd "$(dirname "$0")"/..
./zerver/tests/generate-fixtures
# "-u" uses unbuffered IO, which is important when wrapping it in
# something like subprocess (as tools/review does)
/usr/bin/env python -u ./manage.py test "$target" --settings=humbug.test_settings "$@"
/usr/bin/env python -u ./manage.py test "$target" --settings=zproject.test_settings "$@"
2 changes: 1 addition & 1 deletion tools/update-prod-static
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import sys

# We need settings so we can figure out where the prod-static directory is.
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'humbug.settings'
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
from django.conf import settings

parser = optparse.OptionParser()
Expand Down
2 changes: 1 addition & 1 deletion zerver/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.utils.safestring import mark_safe
from django.contrib.auth.forms import SetPasswordForm

from humbug import settings
from zproject import settings
from zerver.models import Realm, get_user_profile_by_email, UserProfile
from zerver.lib.actions import do_change_password

Expand Down
2 changes: 1 addition & 1 deletion zerver/lib/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# out from bots without having to import pika code all over our codebase.
class SimpleQueueClient(object):
def __init__(self):
self.log = logging.getLogger('humbug.queue')
self.log = logging.getLogger('zulip.queue')
self.queues = set()
self.channel = None
self.consumers = defaultdict(set)
Expand Down
2 changes: 1 addition & 1 deletion zerver/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import time

logger = logging.getLogger('humbug.requests')
logger = logging.getLogger('zulip.requests')

def async_request_stop(request):
request._time_stopped = time.time()
Expand Down
2 changes: 1 addition & 1 deletion zerver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def bail(msg):
try:
settings.TEST_SUITE
except:
bail('Test suite only runs correctly with --settings=humbug.test_settings')
bail('Test suite only runs correctly with --settings=zproject.test_settings')

# Even though we don't use pygments directly in this file, we need
# this import.
Expand Down
12 changes: 6 additions & 6 deletions zerver/tests/generate-fixtures
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function migration_status {
./manage.py migrate --list | sed 's/*/ /' > "$1"
}

template_grep_error_code=$(echo "SELECT 1 from pg_database WHERE datname='humbug_test_template';" | python manage.py dbshell --settings=humbug.test_settings | grep -q "1 row"; echo $?)
template_grep_error_code=$(echo "SELECT 1 from pg_database WHERE datname='humbug_test_template';" | python manage.py dbshell --settings=zproject.test_settings | grep -q "1 row"; echo $?)

if [ $template_grep_error_code == "0" ]; then
migration_status zerver/fixtures/available-migrations
Expand All @@ -26,15 +26,15 @@ mkdir -p zerver/fixtures
rm -f zerver/lib/time.pyc


echo "DROP SCHEMA humbug CASCADE; CREATE SCHEMA humbug;" | python manage.py dbshell --settings=humbug.test_settings
python manage.py syncdb --noinput --settings=humbug.test_settings
python manage.py migrate --settings=humbug.test_settings --all
echo "DROP SCHEMA humbug CASCADE; CREATE SCHEMA humbug;" | python manage.py dbshell --settings=zproject.test_settings
python manage.py syncdb --noinput --settings=zproject.test_settings
python manage.py migrate --settings=zproject.test_settings --all
migration_status "zerver/fixtures/migration-status"

# This next line can be simplified to "-n0" once we fix our app with 0 messages.
python manage.py populate_db --settings=humbug.test_settings --test-suite -n2 \
python manage.py populate_db --settings=zproject.test_settings --test-suite -n2 \
--threads=1 --huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
python manage.py dumpdata --settings=humbug.test_settings \
python manage.py dumpdata --settings=zproject.test_settings \
zerver.UserProfile zerver.Stream zerver.Recipient \
zerver.Subscription zerver.Message zerver.Huddle zerver.Realm \
zerver.UserMessage zerver.Client \
Expand Down
Empty file added zproject/__init__.py
Empty file.
File renamed without changes.
60 changes: 60 additions & 0 deletions zproject/backends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from zerver.models import UserProfile, get_user_profile_by_id, \
get_user_profile_by_email

from openid.consumer.consumer import SUCCESS

class EmailAuthBackend(object):
"""
Email Authentication Backend
Allows a user to sign in using an email/password pair rather than
a username/password pair.
"""

def authenticate(self, username=None, password=None):
""" Authenticate a user based on email address as the user name. """
if username is None or password is None:
# Return immediately. Otherwise we will look for a SQL row with
# NULL username. While that's probably harmless, it's needless
# exposure.
return None

try:
user_profile = get_user_profile_by_email(username)
if user_profile.check_password(password):
return user_profile
except UserProfile.DoesNotExist:
return None

def get_user(self, user_profile_id):
""" Get a UserProfile object from the user_profile_id. """
try:
return get_user_profile_by_id(user_profile_id)
except UserProfile.DoesNotExist:
return None

# Adapted from http://djangosnippets.org/snippets/2183/ by user Hangya (September 1, 2010)

class GoogleBackend(object):
def authenticate(self, openid_response):
if openid_response is None:
return None
if openid_response.status != SUCCESS:
return None

google_email = openid_response.getSigned('http://openid.net/srv/ax/1.0', 'value.email')

try:
user_profile = get_user_profile_by_email(google_email)
except UserProfile.DoesNotExist:
# create a new user, or send a message to admins, etc.
return None

return user_profile

def get_user(self, user_profile_id):
""" Get a UserProfile object from the user_profile_id. """
try:
return get_user_profile_by_id(user_profile_id)
except UserProfile.DoesNotExist:
return None
12 changes: 6 additions & 6 deletions humbug/settings.py → zproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,23 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

AUTHENTICATION_BACKENDS = ('humbug.backends.EmailAuthBackend',
'humbug.backends.GoogleBackend',
AUTHENTICATION_BACKENDS = ('zproject.backends.EmailAuthBackend',
'zproject.backends.GoogleBackend',
'guardian.backends.ObjectPermissionBackend')
ANONYMOUS_USER_ID = None

AUTH_USER_MODEL = "zerver.UserProfile"

TEST_RUNNER = 'zerver.tests.Runner'

ROOT_URLCONF = 'humbug.urls'
ROOT_URLCONF = 'zproject.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'humbug.wsgi.application'
WSGI_APPLICATION = 'zproject.wsgi.application'

INSTALLED_APPS = (
'django.contrib.auth',
'humbug.authhack',
'zproject.authhack',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
Expand Down Expand Up @@ -532,7 +532,7 @@
'level': 'INFO',
'propagate': False,
},
'humbug.requests': {
'zulip.requests': {
'handlers': ['console', 'file'],
'level': 'INFO',
'propagate': False,
Expand Down
2 changes: 1 addition & 1 deletion humbug/test_settings.py → zproject/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
}
}

LOGGING['loggers']['humbug.requests']['level'] = 'CRITICAL'
LOGGING['loggers']['zulip.requests']['level'] = 'CRITICAL'
File renamed without changes.
2 changes: 1 addition & 1 deletion humbug/wsgi.py → zproject/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "humbug.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
Expand Down

0 comments on commit 7b9305b

Please sign in to comment.