annotate sat_website/views/whereami.py @ 160:ff48d544bfdd default tip

gallery: replaced <video> tag by <img> for videos thumbnails
author Goffi <goffi@goffi.org>
date Sun, 23 Sep 2018 16:41:30 +0200
parents b101828faa0e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
2 """
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
3 SàT website: Salut à Toi's presentation website
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
4 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org)
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
5
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
6 This file is part of SàT website.
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
7
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
8 SàT website is free software: you can redistribute it and/or modify
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
11 (at your option) any later version.
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
12
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
13 Foobar is distributed in the hope that it will be useful,
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
16 GNU Affero General Public License for more details.
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
17
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
18 You should have received a copy of the GNU Affero General Public License
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
19 along with SàT website. If not, see <http://www.gnu.org/licenses/>.
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
20 """
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
21
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
22 from django.views import View
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
23 from django.http.response import HttpResponse
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
24
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
25
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
26 class WhereAmIView(View):
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
27
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
28 def get(self, request):
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
29 """Return the client IP address"""
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
30 x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
31 if x_forwarded_for:
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
32 ip = x_forwarded_for.split(',')[0]
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
33 else:
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
34 ip = request.META.get('REMOTE_ADDR')
b101828faa0e split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
diff changeset
35 return HttpResponse(ip)