2019-07-11 10:12:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.utils.encoding import iri_to_uri
|
|
|
|
|
2020-09-27 11:47:13 +00:00
|
|
|
from rest_framework.serializers import BooleanField
|
|
|
|
|
2019-07-11 10:12:14 +00:00
|
|
|
|
|
|
|
class HttpResponseTemporaryRedirect(HttpResponse):
|
|
|
|
status_code = 307
|
|
|
|
|
|
|
|
def __init__(self, redirect_to):
|
|
|
|
HttpResponse.__init__(self)
|
|
|
|
self['Location'] = iri_to_uri(redirect_to)
|
2020-06-22 09:04:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_remote_addr(request):
|
|
|
|
return request.META.get("HTTP_X_FORWARDED_HOST") or request.META.get("REMOTE_ADDR")
|
2020-09-27 11:47:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_true(value):
|
|
|
|
return value in BooleanField.TRUE_VALUES
|