Browse Source

jump/views.py: change behavior when trying to access an inactive hostname

Instead of displaying "host unknown" page, we're displaying a search
results page when hostname known to us bot not activated and don't
published in exported addressbook.
pull/1/head
Hidden Z 14 years ago
parent
commit
83928b6dad
  1. 7
      pyi2phosts/jump/views.py

7
pyi2phosts/jump/views.py

@ -1,6 +1,7 @@
import re import re
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.shortcuts import redirect
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from pyi2phosts.postkey.models import i2phost from pyi2phosts.postkey.models import i2phost
@ -17,11 +18,15 @@ def jumper(request, host):
'error': e, 'error': e,
}) })
try: try:
key = i2phost.objects.get(name=hostname, activated=True).b64hash h = i2phost.objects.get(name=hostname)
except i2phost.DoesNotExist: except i2phost.DoesNotExist:
return render_to_response('jump-unknown.html', { return render_to_response('jump-unknown.html', {
'title': settings.SITE_NAME, 'title': settings.SITE_NAME,
}) })
if h.activated == True:
key = h.b64hash
else:
return redirect('/search/?q=' + hostname)
# begin forming url # begin forming url
url = 'http://' + hostname url = 'http://' + hostname
# get params from requst string, e.g. from 'example.i2p/smth/1?a=b&c=d' get 'smth/1?a=b&c=d' # get params from requst string, e.g. from 'example.i2p/smth/1?a=b&c=d' get 'smth/1?a=b&c=d'

Loading…
Cancel
Save