Skip to content

Commit

Permalink
Replacing URL monkey patch with FORCE_SCRIPT_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
zemogle committed Jul 22, 2015
1 parent 3c807e9 commit 6f69a02
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 36 deletions.
1 change: 0 additions & 1 deletion neoexchange/astrometrics/ephem_subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def compute_ephem(d, orbelems, sitecode, dbg=False, perturb=True, display=False)
epochofel = datetime.strptime(orbelems['epochofel'], '%Y-%m-%d %H:%M:%S')
except TypeError:
epochofel = orbelems['epochofel']
print epochofel
epoch_mjd = datetime2mjd_utc(epochofel)
else:
epoch_mjd = orbelems['epoch']
Expand Down
9 changes: 5 additions & 4 deletions neoexchange/astrometrics/sources_subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
'''
import urllib2, os

from bs4 import BeautifulSoup
from datetime import datetime
from reqdb.requests import Request, UserRequest
from reqdb.client import SchedulerClient

from re import sub
from reqdb.client import SchedulerClient
from reqdb.requests import Request, UserRequest
import logging
import urllib2, os

logger = logging.getLogger(__name__)

def download_file(url, file_to_save):
Expand Down
2 changes: 2 additions & 0 deletions neoexchange/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

class LoginRequiredMixin(object):

#login_url = reverse('auth_login')

@classmethod
def as_view(cls, **initkwargs):
view = super(LoginRequiredMixin, cls).as_view(**initkwargs)
Expand Down
29 changes: 0 additions & 29 deletions neoexchange/neox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +0,0 @@
'''
NEO exchange: NEO observing portal for Las Cumbres Observatory Global Telescope Network
Copyright (C) 2014-2015 LCOGT
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
'''
#
# monkey patch urlresolvers.reverse,
# to be aware of the application PREFIX
#

import django.core.urlresolvers

old_reverse = django.core.urlresolvers.reverse
def myreverse(*args, **kwargs):
from django.conf import settings
try:
return settings.PREFIX + old_reverse(*args, **kwargs)
except:
return old_reverse(*args, **kwargs)
django.core.urlresolvers.reverse = myreverse
10 changes: 9 additions & 1 deletion neoexchange/neox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

PREFIX = os.environ.get('PREFIX', '')

FORCE_SCRIPT_NAME = '/neoexchange'

BASE_DIR = os.path.dirname(CURRENT_PATH)

ADMINS = (
Expand Down Expand Up @@ -105,6 +107,8 @@
},
]

LOGIN_URL = PREFIX +'/accounts/login/'

LOGIN_REDIRECT_URL = PREFIX + '/'

# GRAPPELLI_INDEX_DASHBOARD = 'neox.dashboard.CustomIndexDashboard'
Expand Down Expand Up @@ -162,7 +166,7 @@
'filters': ['require_debug_false']
},
'console': {
'level': 'DEBUG',
'level': 'ERROR',
'class': 'logging.StreamHandler',
}
},
Expand All @@ -180,6 +184,10 @@
'core' : {
'handlers' : ['file','console'],
'level' : 'DEBUG',
},
'astrometrics' : {
'handlers' : ['file','console'],
'level' : 'ERROR',
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion neoexchange/templates/admin/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="form-row">
{{ form.password.errors }}
{{ form.password.label_tag }} {{ form.password }}
<input type="hidden" name="next" value="{{ next }}" />
<input type="hidden" name="next" value="{% url 'admin:login' %}" />
</div>
{% url 'admin_password_reset' as password_reset_url %}
{% if password_reset_url %}
Expand Down

0 comments on commit 6f69a02

Please sign in to comment.