def get_badgrapp_redirect(self): badgrapp = self.current_object.cached_badgrapp if not badgrapp.public_pages_redirect: badgrapp = BadgrApp.objects.get_current(request=None) # use the default badgrapp redirect = badgrapp.public_pages_redirect if not redirect: redirect = 'https://{}/public/'.format(badgrapp.cors) else: if not redirect.endswith('/'): redirect += '/' path = self.request.path stripped_path = re.sub(r'^/public/', '', path) query_string = self.request.META.get('QUERY_STRING', None) ret = '{redirect}{path}{query}'.format( redirect=redirect, path=stripped_path, query='?'+query_string if query_string else '') return ret
def get_badgrapp_redirect(self): badgrapp = self.current_object.cached_badgrapp badgrapp = BadgrApp.cached.get(pk=badgrapp.pk) # ensure we have latest badgrapp information if not badgrapp.public_pages_redirect: badgrapp = BadgrApp.objects.get_current(request=None) # use the default badgrapp redirect = badgrapp.public_pages_redirect if not redirect: redirect = 'https://{}/public/'.format(badgrapp.cors) else: if not redirect.endswith('/'): redirect += '/' path = self.request.path stripped_path = re.sub(r'^/public/', '', path) query_string = self.request.META.get('QUERY_STRING', None) ret = '{redirect}{path}{query}'.format( redirect=redirect, path=stripped_path, query='?'+query_string if query_string else '') return ret