Fix Image resize + Partial API fix
This commit is contained in:
parent
8c57eb8096
commit
b280647c35
2 changed files with 8 additions and 5 deletions
|
|
@ -114,7 +114,7 @@ class ImageForm(forms.Form):
|
||||||
frame = frame.crop((x, y, x + w, y + h))
|
frame = frame.crop((x, y, x + w, y + h))
|
||||||
frame = frame.resize(
|
frame = frame.resize(
|
||||||
(settings.PIC_WIDTH, settings.PIC_RATIO * settings.PIC_WIDTH),
|
(settings.PIC_WIDTH, settings.PIC_RATIO * settings.PIC_WIDTH),
|
||||||
Image.ANTIALIAS,
|
Image.Resampling.LANCZOS,
|
||||||
)
|
)
|
||||||
frames.append(frame)
|
frames.append(frame)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,11 +160,13 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = super().get_queryset().distinct()
|
queryset = super().get_queryset().distinct()
|
||||||
|
|
||||||
# Sqlite doesn't support ORDER BY in subqueries
|
# Sqlite doesn't support ORDER BY in subqueries
|
||||||
queryset = queryset.order_by("name") \
|
queryset = queryset.order_by("name") \
|
||||||
if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' else queryset
|
if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' else queryset
|
||||||
|
|
||||||
alias = self.request.query_params.get("alias", None)
|
alias = self.request.query_params.get("alias", None)
|
||||||
|
|
||||||
# Check if this is a valid regex. If not, we won't check regex
|
# Check if this is a valid regex. If not, we won't check regex
|
||||||
try:
|
try:
|
||||||
re.compile(alias)
|
re.compile(alias)
|
||||||
|
|
@ -174,13 +176,14 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
|
||||||
suffix = '__iregex' if valid_regex else '__istartswith'
|
suffix = '__iregex' if valid_regex else '__istartswith'
|
||||||
alias_prefix = '^' if valid_regex else ''
|
alias_prefix = '^' if valid_regex else ''
|
||||||
queryset = queryset.prefetch_related('note')
|
queryset = queryset.prefetch_related('note')
|
||||||
|
|
||||||
if alias:
|
if alias:
|
||||||
# We match first an alias if it is matched without normalization,
|
# We match first an alias if it is matched without normalization,
|
||||||
# then if the normalized pattern matches a normalized alias.
|
# then if the normalized pattern matches a normalized alias.
|
||||||
queryset = queryset.filter(
|
queryset = queryset.filter(
|
||||||
**{f'name{suffix}': alias_prefix + alias}
|
**{f'name{suffix}': alias_prefix + alias}
|
||||||
).union(
|
)
|
||||||
|
""".union(
|
||||||
queryset.filter(
|
queryset.filter(
|
||||||
Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
||||||
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
||||||
|
|
@ -191,12 +194,12 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
|
||||||
& ~Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
& ~Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
||||||
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
||||||
),
|
),
|
||||||
all=True)
|
all=True)"""
|
||||||
|
|
||||||
queryset = queryset if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' \
|
queryset = queryset if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' \
|
||||||
else queryset.order_by("name")
|
else queryset.order_by("name")
|
||||||
|
|
||||||
return queryset.distinct()
|
return queryset#.distinct()
|
||||||
|
|
||||||
|
|
||||||
class TemplateCategoryViewSet(ReadProtectedModelViewSet):
|
class TemplateCategoryViewSet(ReadProtectedModelViewSet):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue