mirror of https://github.com/zulip/zulip.git
Rename Django project to zproject.
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)
This commit is contained in:
parent
44057cb31b
commit
7b9305b06f
|
@ -1,60 +0,0 @@
|
|||
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
|
|
@ -0,0 +1 @@
|
|||
../zproject/backends.py
|
|
@ -7,7 +7,7 @@ if __name__ == "__main__":
|
|||
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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ node_modules
|
|||
""".split()
|
||||
|
||||
exclude_files = """
|
||||
humbug/test_settings.py
|
||||
zproject/test_settings.py
|
||||
tools/jslint/jslint.js
|
||||
""".split()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -33,7 +33,7 @@ base_port = 9991
|
|||
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
|
||||
|
|
|
@ -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 "$@"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError
|
|||
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
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from zerver.lib.utils import statsd
|
|||
# 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)
|
||||
|
|
|
@ -11,7 +11,7 @@ from zerver.exceptions import RateLimited
|
|||
import logging
|
||||
import time
|
||||
|
||||
logger = logging.getLogger('humbug.requests')
|
||||
logger = logging.getLogger('zulip.requests')
|
||||
|
||||
def async_request_stop(request):
|
||||
request._time_stopped = time.time()
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
@ -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 \
|
||||
|
|
|
@ -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
|
|
@ -153,8 +153,8 @@ MIDDLEWARE_CLASSES = (
|
|||
'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
|
||||
|
||||
|
@ -162,14 +162,14 @@ 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',
|
||||
|
@ -532,7 +532,7 @@ LOGGING = {
|
|||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'humbug.requests': {
|
||||
'zulip.requests': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
|
@ -46,4 +46,4 @@ CACHES['database'] = {
|
|||
}
|
||||
}
|
||||
|
||||
LOGGING['loggers']['humbug.requests']['level'] = 'CRITICAL'
|
||||
LOGGING['loggers']['zulip.requests']['level'] = 'CRITICAL'
|
|
@ -15,7 +15,7 @@ framework.
|
|||
"""
|
||||
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
|
Loading…
Reference in New Issue