allow user.url to be accessed without the server running

Reduces the number of different ways we need to build the same URLs.
This commit is contained in:
Min RK
2016-03-09 09:30:50 +01:00
parent c6c699ea89
commit 922956def2
4 changed files with 5 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ class LoginHandler(BaseHandler):
if user: if user:
if not next_url: if not next_url:
if user.running: if user.running:
next_url = user.server.base_url next_url = user.url
else: else:
next_url = self.hub.server.base_url next_url = self.hub.server.base_url
# set new login cookie # set new login cookie

View File

@@ -75,10 +75,7 @@ class SpawnHandler(BaseHandler):
self.finish(self._render_form()) self.finish(self._render_form())
else: else:
# not running, no form. Trigger spawn. # not running, no form. Trigger spawn.
# Creating the URL manually since the server does not self.redirect(user.url)
# exist yet
url = url_path_join(self.base_url, 'user', quote(user.name))
self.redirect(url)
@web.authenticated @web.authenticated
@gen.coroutine @gen.coroutine

View File

@@ -186,10 +186,10 @@ class User(HasTraits):
if self.settings.get('subdomain_host'): if self.settings.get('subdomain_host'):
return '{host}{path}'.format( return '{host}{path}'.format(
host=self.host, host=self.host,
path=self.server.base_url, path=self.base_url,
) )
else: else:
return self.server.base_url return self.base_url
@gen.coroutine @gen.coroutine
def spawn(self, options=None): def spawn(self, options=None):

View File

@@ -10,7 +10,7 @@
{% endif %} {% endif %}
<a id="start" class="btn btn-lg btn-success" <a id="start" class="btn btn-lg btn-success"
{% if user.running %} {% if user.running %}
href="{{ user.server.base_url }}" href="{{ user.url }}"
{% else %} {% else %}
href="{{base_url}}spawn" href="{{base_url}}spawn"
{% endif %} {% endif %}