def mindtouch_namespace_redirect(request, namespace, slug):
 new_locale = new_slug = None
 if (namespace in ('Talk', 'Project', 'Project_talk')):
  (locale, _, doc_slug) = slug.partition('/')
  new_locale = settings.MT_TO_KUMA_LOCALE_MAP.get(locale, 'en-US')
  new_slug = ('%s:%s' % (namespace, doc_slug))
 elif (namespace == 'User'):
  new_slug = ('%s:%s' % (namespace, slug))
  try:
   rev = Revision.objects.filter(document__slug=new_slug).latest('created')
   new_locale = rev.document.locale
  except Revision.DoesNotExist:
   new_locale = 'en-US'
 else:
  new_locale = 'en-US'
  new_slug = ('%s:%s' % (namespace, slug))
 if new_locale:
  new_url = ('/%s/docs/%s' % (request.LANGUAGE_CODE, new_slug))
 return redirect(new_url, permanent=True)

def mindtouch_namespace_redirect ( request , namespace , slug ) : new_locale = new_slug = None if ( namespace in ( 'Talk' , 'Project' , 'Project_talk' ) ) : ( locale , _ , doc_slug ) = slug . partition ( '/' ) new_locale = settings . MT_TO_KUMA_LOCALE_MAP . get ( locale , 'en-US' ) new_slug = ( '%s:%s' % ( namespace , doc_slug ) ) elif ( namespace == 'User' ) : new_slug = ( '%s:%s' % ( namespace , slug ) ) try : rev = Revision . objects . filter ( document__slug = new_slug ) . latest ( 'created' ) new_locale = rev . document . locale except Revision . DoesNotExist : new_locale = 'en-US' else : new_locale = 'en-US' new_slug = ( '%s:%s' % ( namespace , slug ) ) if new_locale : new_url = ( '/%s/docs/%s' % ( request . LANGUAGE_CODE , new_slug ) ) return redirect ( new_url , permanent = True )
for urls in special namespaces .