Automatic linting

This commit is contained in:
Github-actions
2024-03-12 13:48:58 +00:00
parent f9abd9dc8b
commit 2712addc46
13 changed files with 59 additions and 28 deletions

View File

@@ -1,9 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
# Local
from .celery_configuration import app

View File

@@ -37,6 +37,7 @@ from wger.core.models import (
WeightUnit,
)
logger = logging.getLogger(__name__)

View File

@@ -4,14 +4,34 @@ from django.db import migrations, models
def update_language_full_name(apps, schema_editor):
mapper = {'de': 'German', 'en': 'English', 'bg': 'Bulgarian', 'es': 'Spanish', 'ru': 'Russian',
'nl': 'Dutch', 'pt': 'Portuguese', 'el': 'Greek', 'cs': 'Czech', 'sv': 'Swedish',
'no': 'Norwegian', 'fr': 'French', 'it': 'Italian', 'pl': 'Polish', 'uk': 'Ukrainian',
'tr': 'Turkish', 'ar': 'Arabic', 'az': 'Azerbaijani', 'eo': 'Esperanto',
'fa': 'Persian', 'he': 'Hebrew', 'hr': 'Croatian', 'id': 'Indonesian',
'zh': 'Chinese', }
mapper = {
'de': 'German',
'en': 'English',
'bg': 'Bulgarian',
'es': 'Spanish',
'ru': 'Russian',
'nl': 'Dutch',
'pt': 'Portuguese',
'el': 'Greek',
'cs': 'Czech',
'sv': 'Swedish',
'no': 'Norwegian',
'fr': 'French',
'it': 'Italian',
'pl': 'Polish',
'uk': 'Ukrainian',
'tr': 'Turkish',
'ar': 'Arabic',
'az': 'Azerbaijani',
'eo': 'Esperanto',
'fa': 'Persian',
'he': 'Hebrew',
'hr': 'Croatian',
'id': 'Indonesian',
'zh': 'Chinese',
}
Language = apps.get_model("core", "Language")
Language = apps.get_model('core', 'Language')
for language in Language.objects.all():
language.full_name_en = mapper.get(language.short_name, 'English')
language.save()
@@ -26,8 +46,11 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='language',
name='full_name_en',
field=models.CharField(default='english', max_length=30,
verbose_name='Language full name in English', ),
field=models.CharField(
default='english',
max_length=30,
verbose_name='Language full name in English',
),
preserve_default=False,
),
migrations.RunPython(

View File

@@ -42,6 +42,7 @@ from wger.utils.generic_views import (
WgerFormMixin,
)
logger = logging.getLogger(__name__)

View File

@@ -91,6 +91,7 @@ from wger.utils.constants import (
from wger.utils.db import is_postgres_db
from wger.utils.language import load_language
logger = logging.getLogger(__name__)
@@ -351,9 +352,9 @@ def search(request):
# Postgres uses a full-text search
if is_postgres_db():
query = (
query.annotate(similarity=TrigramSimilarity("name", q))
query.annotate(similarity=TrigramSimilarity('name', q))
.filter(Q(similarity__gt=0.15) | Q(alias__alias__icontains=q))
.order_by("-similarity", "name")
.order_by('-similarity', 'name')
)
else:
query = query.filter(Q(name__icontains=q) | Q(alias__alias__icontains=q))
@@ -383,7 +384,7 @@ def search(request):
},
}
results.append(result_json)
response["suggestions"] = results
response['suggestions'] = results
return Response(response)

View File

@@ -14,16 +14,16 @@ class Migration(migrations.Migration):
BtreeGinExtension(),
TrigramExtension(),
migrations.AddIndex(
model_name="exercise",
model_name='exercise',
index=django.contrib.postgres.indexes.GinIndex(
fields=["name"],
name="exercises_e_name_ac11f4_gin",
fields=['name'],
name='exercises_e_name_ac11f4_gin',
),
),
migrations.AddIndex(
model_name="alias",
model_name='alias',
index=django.contrib.postgres.indexes.GinIndex(
fields=["alias"], name="exercises_a_alias_227e38_gin"
fields=['alias'], name='exercises_a_alias_227e38_gin'
),
),
]

View File

@@ -108,7 +108,7 @@ class Exercise(AbstractLicenseModel, AbstractHistoryMixin, models.Model):
ordering = [
'name',
]
indexes = (GinIndex(fields=["name"]),)
indexes = (GinIndex(fields=['name']),)
def get_absolute_url(self):
"""

View File

@@ -63,7 +63,7 @@ class Alias(models.Model):
"""Edit history"""
class Meta:
indexes = (GinIndex(fields=["alias"]),)
indexes = (GinIndex(fields=['alias']),)
def __str__(self):
"""

View File

@@ -296,6 +296,7 @@ def handle_deleted_entries(
style_fn=lambda x: x,
):
if not print_fn:
def print_fn(_):
return None

View File

@@ -78,6 +78,7 @@ from wger.utils.db import is_postgres_db
from wger.utils.language import load_language
from wger.utils.viewsets import WgerOwnerObjectModelViewSet
logger = logging.getLogger(__name__)
@@ -224,9 +225,9 @@ def search(request):
# Postgres uses a full-text search
if is_postgres_db():
query = (
query.annotate(similarity=TrigramSimilarity("name", term))
query.annotate(similarity=TrigramSimilarity('name', term))
.filter(similarity__gt=0.15)
.order_by("-similarity", "name")
.order_by('-similarity', 'name')
)
else:
query = query.filter(name__icontains=term)

View File

@@ -7,14 +7,14 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("nutrition", "0019_alter_image_license_author_and_more"),
('nutrition', '0019_alter_image_license_author_and_more'),
]
operations = [
migrations.AddIndex(
model_name="ingredient",
model_name='ingredient',
index=django.contrib.postgres.indexes.GinIndex(
fields=["name"], name="nutrition_i_search__f274b7_gin"
fields=['name'], name='nutrition_i_search__f274b7_gin'
),
),
]

View File

@@ -67,6 +67,7 @@ from wger.utils.models import (
# Local
from .ingredient_category import IngredientCategory
logger = logging.getLogger(__name__)
@@ -243,9 +244,9 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
# Metaclass to set some other properties
class Meta:
ordering = [
"name",
'name',
]
indexes = (GinIndex(fields=["name"]),)
indexes = (GinIndex(fields=['name']),)
#
# Django methods

View File

@@ -13,6 +13,7 @@ middleware here, or combine a Django application with an application of another
framework.
"""
# Standard Library
import os