Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
9bd40b0191
|
|
@ -43,11 +43,6 @@ class SignupSerializer(serializers.ModelSerializer):
|
||||||
if account_models.User.objects.filter(username__iexact=value).exists():
|
if account_models.User.objects.filter(username__iexact=value).exists():
|
||||||
raise serializers.ValidationError()
|
raise serializers.ValidationError()
|
||||||
|
|
||||||
else:
|
|
||||||
value = utils_methods.username_random()
|
|
||||||
while account_models.User.objects.filter(username__iexact=value).exists():
|
|
||||||
value = utils_methods.username_random()
|
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def validate_email(self, value):
|
def validate_email(self, value):
|
||||||
|
|
@ -67,6 +62,13 @@ class SignupSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
"""Overridden create method"""
|
"""Overridden create method"""
|
||||||
|
|
||||||
|
username = validated_data.get('username')
|
||||||
|
if not username:
|
||||||
|
username = utils_methods.username_random()
|
||||||
|
while account_models.User.objects.filter(username__iexact=username).exists():
|
||||||
|
username = utils_methods.username_random()
|
||||||
|
|
||||||
obj = account_models.User.objects.make(
|
obj = account_models.User.objects.make(
|
||||||
username=validated_data.get('username'),
|
username=validated_data.get('username'),
|
||||||
password=validated_data.get('password'),
|
password=validated_data.get('password'),
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,9 @@ class CustomFacetedSearchFilterBackend(FacetedSearchFilterBackend):
|
||||||
tag_facets = []
|
tag_facets = []
|
||||||
preserve_ids = []
|
preserve_ids = []
|
||||||
facet_name = '_filter_' + __field
|
facet_name = '_filter_' + __field
|
||||||
all_tag_categories = TagCategoryDocument.search() \
|
all_tag_categories = list(TagCategoryDocument.search() \
|
||||||
.filter('term', public=True) \
|
.filter('term', public=True) \
|
||||||
.filter(Q('term', value_type=TagCategory.LIST) | Q('match', index_name='wine-color'))
|
.filter(Q('term', value_type=TagCategory.LIST) | Q('match', index_name='wine-color'))[0:1000])
|
||||||
for category in all_tag_categories:
|
for category in all_tag_categories:
|
||||||
tags_to_remove = list(map(lambda t: str(t.id), category.tags))
|
tags_to_remove = list(map(lambda t: str(t.id), category.tags))
|
||||||
qs = queryset.__copy__()
|
qs = queryset.__copy__()
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import re
|
||||||
import string
|
import string
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
@ -14,6 +12,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.gis.geos import Point
|
from django.contrib.gis.geos import Point
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
from django.utils.timezone import datetime
|
from django.utils.timezone import datetime
|
||||||
|
from PIL import Image
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
|
|
||||||
|
|
@ -58,9 +57,14 @@ def username_validator(username: str) -> bool:
|
||||||
|
|
||||||
def username_random():
|
def username_random():
|
||||||
"""Generate random username"""
|
"""Generate random username"""
|
||||||
return '{letters}{digits}'.format(
|
username = list('{letters}{digits}'.format(
|
||||||
letters=''.join([random.choice(string.ascii_lowercase) for _ in range(5)]),
|
letters=''.join([random.choice(string.ascii_lowercase) for _ in range(4)]),
|
||||||
digits=random.randrange(100, 1000)
|
digits=random.randrange(100, 1000)
|
||||||
|
))
|
||||||
|
random.shuffle(username)
|
||||||
|
return '{first}{username}'.format(
|
||||||
|
first=random.choice(string.ascii_lowercase),
|
||||||
|
username=''.join(username)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user