mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
Geo coding: Use always-ascii cache keys
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||||
# <https://www.gnu.org/licenses/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ logger = logging.getLogger(__name__)
|
|||||||
class GeoCodeView(LoginRequiredMixin, View):
|
class GeoCodeView(LoginRequiredMixin, View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
q = self.request.GET.get('q')
|
q = self.request.GET.get('q')
|
||||||
cd = cache.get('geocode:{}'.format(q))
|
cache_key = 'geocode:{}'.format(hashlib.sha256(q.encode()).hexdigest())
|
||||||
|
cd = cache.get(cache_key)
|
||||||
if cd:
|
if cd:
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'success': True,
|
'success': True,
|
||||||
@@ -61,7 +63,7 @@ class GeoCodeView(LoginRequiredMixin, View):
|
|||||||
'results': []
|
'results': []
|
||||||
}, status=200)
|
}, status=200)
|
||||||
|
|
||||||
cache.set('geocode:{}'.format(q), res, timeout=3600 * 6)
|
cache.set(cache_key, res, timeout=3600 * 6)
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'success': True,
|
'success': True,
|
||||||
'results': res
|
'results': res
|
||||||
|
|||||||
Reference in New Issue
Block a user