~widelands-dev/widelands-website/anti_spam_3

« back to all changes in this revision

Viewing changes to wlimages/views.py

  • Committer: franku
  • Date: 2016-10-18 17:43:00 UTC
  • mfrom: (423.1.6 widelands)
  • Revision ID: somal@arcor.de-20161018174300-3ce0abpi5tfwrtfv
fixes getting the real ip address, a bug related to the update of Django

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from django.contrib.auth.decorators import login_required
2
2
from django.contrib.contenttypes.models import ContentType
3
 
from django.core.urlresolvers import reverse
4
3
from django.http import HttpResponse, HttpResponseRedirect
5
4
from django.shortcuts import get_object_or_404, render_to_response
6
5
from django.template import RequestContext
7
6
 
8
7
from models import Image
9
 
from settings import MEDIA_ROOT
10
 
from django.core.files.uploadedfile import SimpleUploadedFile
11
 
from django.conf import settings
12
 
 
 
8
from wl_utils import get_real_ip
13
9
from forms import UploadImageForm
14
10
 
15
 
 
16
 
def get_real_ip(request):
17
 
    """ Returns the real user IP, even if behind a proxy.
18
 
    Set BEHIND_PROXY to True in your settings if Django is
19
 
    running behind a proxy.
20
 
    """
21
 
    if getattr(settings, 'BEHIND_PROXY', False):
22
 
        return request.META['HTTP_X_FORWARDED_FOR']
23
 
    return request.META['REMOTE_ADDR']
24
 
 
25
11
def display( request, image, revision ):
26
12
    revision = int(revision)
27
13