mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-02-09 13:24:22 +00:00
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.
This commit is contained in:
parent
59beb95606
commit
83928b6dad
@ -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…
x
Reference in New Issue
Block a user