Ejemplo n.º 1
0
 def set_ip_for_object(self, instance, **kwargs):
     opts = get_meta(instance)
     model = (opts.app_label, opts.model_name)
     if model in SET_IP_MODELS:
         request = get_current_request()
         if request:
             instance.ip_address = get_client_ip(request)
Ejemplo n.º 2
0
	def set_ip_for_object(self, instance, **kwargs):
		opts = get_meta(instance)
		model = (opts.app_label, opts.model_name)
		if model in SET_IP_MODELS:
			request = get_current_request()
			if request:
				instance.ip_address = get_client_ip(request)
Ejemplo n.º 3
0
def replace_file_urls(val, moves):
	host = ''
	req = get_current_request()
	if req is not None:
		host = req.scheme + '://' + req.get_host()
	for src, dst in moves:
		src_dir = '/'.join(src.split('/')[:-1])
		dst_dir = '/'.join(dst.split('/')[:-1])
		val = re.sub('(' + re.escape(host) + ')?' + re.escape(settings.MEDIA_URL + src_dir), settings.MEDIA_URL + dst_dir, val)
	return val
Ejemplo n.º 4
0
def replace_file_urls(val, moves):
    host = ""
    req = get_current_request()
    if req is not None:
        host = req.scheme + "://" + req.get_host()
    for src, dst in moves:
        src_dir = "/".join(src.split("/")[:-1])
        dst_dir = "/".join(dst.split("/")[:-1])
        val = re.sub(
            "(" + re.escape(host) + ")?" + re.escape(settings.MEDIA_URL + src_dir), settings.MEDIA_URL + dst_dir, val
        )
    return val
Ejemplo n.º 5
0
def replace_file_urls(val, moves):
    host = ''
    req = get_current_request()
    if req is not None:
        host = req.scheme + '://' + req.get_host()
    for src, dst in moves:
        src_dir = '/'.join(src.split('/')[:-1])
        dst_dir = '/'.join(dst.split('/')[:-1])
        val = re.sub(
            '(' + re.escape(host) + ')?' +
            re.escape(settings.MEDIA_URL + src_dir),
            settings.MEDIA_URL + dst_dir, val)
    return val