diff --git a/accounts/models.py b/accounts/models.py index 94016d9b3..addce2d5b 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -20,9 +20,9 @@ import datetime import os +import pytz import random -import pytz from django.conf import settings from django.contrib.admin.utils import NestedObjects from django.contrib.auth.models import User @@ -37,6 +37,7 @@ from django.templatetags.static import static from django.urls import reverse from django.utils.encoding import smart_str +from django.utils.http import urlquote from django.utils.timezone import now from psycopg2.errors import ForeignKeyViolation @@ -223,10 +224,10 @@ def get_absolute_url(self): return reverse('account', args=[smart_str(self.user.username)]) def get_user_sounds_in_search_url(self): - return f'{reverse("sounds-search")}?f=username:"{ self.user.username }"&s=Date+added+(newest+first)&g=0' + return f'{reverse("sounds-search")}?f=username:"{ urlquote(self.user.username) }"&s=Date+added+(newest+first)&g=0' def get_user_packs_in_search_url(self): - return f'{reverse("sounds-search")}?f=username:"{ self.user.username }"&s=Date+added+(newest+first)&g=1&dp=1' + return f'{reverse("sounds-search")}?f=username:"{ urlquote(self.user.username) }"&s=Date+added+(newest+first)&g=1&dp=1' def get_latest_packs_for_profile_page(self): latest_pack_ids = Pack.objects.select_related().filter(user=self.user, num_sounds__gt=0).exclude(is_deleted=True) \ diff --git a/geotags/views.py b/geotags/views.py index 208faa279..2155b5294 100644 --- a/geotags/views.py +++ b/geotags/views.py @@ -30,6 +30,7 @@ from django.http import Http404, HttpResponse from django.shortcuts import get_object_or_404, render from django.urls import reverse +from django.utils.http import urlquote from django.views.decorators.cache import cache_page from django.views.decorators.clickjacking import xframe_options_exempt from accounts.models import Profile @@ -210,7 +211,7 @@ def for_user(request, username): 'pack': None, 'sound': None, 'url': reverse('geotags-for-user-barray', args=[username]), - 'query_search_page_url': reverse('sounds-search') + f'?f=username:{username}&mm=1' + 'query_search_page_url': reverse('sounds-search') + f'?f=username:{urlquote(username)}&mm=1' }) return render(request, 'geotags/geotags.html', tvars)