remove deprecated django.db.backends.postgresql_psycopg2
This commit is contained in:
parent
6680fbb644
commit
e89c1742fb
@ -192,7 +192,7 @@ class RecipeAdmin(admin.ModelAdmin):
|
|||||||
def created_by(obj):
|
def created_by(obj):
|
||||||
return obj.created_by.get_user_display_name()
|
return obj.created_by.get_user_display_name()
|
||||||
|
|
||||||
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2', 'django.db.backends.postgresql']:
|
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql':
|
||||||
actions = [rebuild_index]
|
actions = [rebuild_index]
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from recipes import settings
|
|||||||
|
|
||||||
# TODO consider creating a simpleListRecipe API that only includes minimum of recipe info and minimal filtering
|
# TODO consider creating a simpleListRecipe API that only includes minimum of recipe info and minimal filtering
|
||||||
class RecipeSearch():
|
class RecipeSearch():
|
||||||
_postgres = settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2', 'django.db.backends.postgresql']
|
_postgres = settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql'
|
||||||
|
|
||||||
def __init__(self, request, **params):
|
def __init__(self, request, **params):
|
||||||
self._request = request
|
self._request = request
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.postgres.search import SearchVector
|
from django.contrib.postgres.search import SearchVector
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django_scopes import scopes_disabled
|
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django_scopes import scopes_disabled
|
||||||
|
|
||||||
from cookbook.managers import DICTIONARY
|
from cookbook.managers import DICTIONARY
|
||||||
from cookbook.models import Recipe, Step
|
from cookbook.models import Recipe, Step
|
||||||
@ -14,7 +14,7 @@ class Command(BaseCommand):
|
|||||||
help = _('Rebuilds full text search index on Recipe')
|
help = _('Rebuilds full text search index on Recipe')
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
if settings.DATABASES['default']['ENGINE'] not in ['django.db.backends.postgresql_psycopg2', 'django.db.backends.postgresql']:
|
if settings.DATABASES['default']['ENGINE'] != 'django.db.backends.postgresql':
|
||||||
self.stdout.write(self.style.WARNING(_('Only Postgresql databases use full text search, no index to rebuild')))
|
self.stdout.write(self.style.WARNING(_('Only Postgresql databases use full text search, no index to rebuild')))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -9,7 +9,7 @@ from django.utils import translation
|
|||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
|
|
||||||
from cookbook.managers import DICTIONARY
|
from cookbook.managers import DICTIONARY
|
||||||
from cookbook.models import (Index, PermissionModelMixin, Recipe, Step, SearchFields)
|
from cookbook.models import Index, PermissionModelMixin, Recipe, SearchFields, Step
|
||||||
|
|
||||||
|
|
||||||
def allSearchFields():
|
def allSearchFields():
|
||||||
@ -21,7 +21,7 @@ def nameSearchField():
|
|||||||
|
|
||||||
|
|
||||||
def set_default_search_vector(apps, schema_editor):
|
def set_default_search_vector(apps, schema_editor):
|
||||||
if settings.DATABASES['default']['ENGINE'] not in ['django.db.backends.postgresql_psycopg2', 'django.db.backends.postgresql']:
|
if settings.DATABASES['default']['ENGINE'] != 'django.db.backends.postgresql':
|
||||||
return
|
return
|
||||||
language = DICTIONARY.get(translation.get_language(), 'simple')
|
language = DICTIONARY.get(translation.get_language(), 'simple')
|
||||||
with scopes_disabled():
|
with scopes_disabled():
|
||||||
|
@ -16,8 +16,7 @@ from cookbook.models import (Food, MealPlan, PropertyType, Recipe, SearchFields,
|
|||||||
Step, Unit, UserPreference)
|
Step, Unit, UserPreference)
|
||||||
|
|
||||||
SQLITE = True
|
SQLITE = True
|
||||||
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql':
|
||||||
'django.db.backends.postgresql']:
|
|
||||||
SQLITE = False
|
SQLITE = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,8 +10,7 @@ from django_scopes import scopes_disabled
|
|||||||
from cookbook.models import Food, Ingredient
|
from cookbook.models import Food, Ingredient
|
||||||
from cookbook.tests.factories import MealPlanFactory, RecipeFactory, StepFactory, UserFactory
|
from cookbook.tests.factories import MealPlanFactory, RecipeFactory, StepFactory, UserFactory
|
||||||
|
|
||||||
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql':
|
||||||
'django.db.backends.postgresql']:
|
|
||||||
from django.db.backends.postgresql.features import DatabaseFeatures
|
from django.db.backends.postgresql.features import DatabaseFeatures
|
||||||
DatabaseFeatures.can_defer_constraint_checks = False
|
DatabaseFeatures.can_defer_constraint_checks = False
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ from cookbook.tests.factories import (CookLogFactory, FoodFactory, IngredientFac
|
|||||||
# TODO makenow with above filters
|
# TODO makenow with above filters
|
||||||
# TODO test search food/keywords including/excluding children
|
# TODO test search food/keywords including/excluding children
|
||||||
LIST_URL = 'api:recipe-list'
|
LIST_URL = 'api:recipe-list'
|
||||||
sqlite = settings.DATABASES['default']['ENGINE'] not in [
|
sqlite = settings.DATABASES['default']['ENGINE'] != 'django.db.backends.postgresql'
|
||||||
'django.db.backends.postgresql_psycopg2', 'django.db.backends.postgresql']
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -186,8 +186,7 @@ class FuzzyFilterMixin(ViewSetMixin, ExtendedRecipeMixin):
|
|||||||
fuzzy = True
|
fuzzy = True
|
||||||
|
|
||||||
if query is not None and query not in ["''", '']:
|
if query is not None and query not in ["''", '']:
|
||||||
if fuzzy and (settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
if fuzzy and (settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql'):
|
||||||
'django.db.backends.postgresql']):
|
|
||||||
if self.request.user.is_authenticated and any(
|
if self.request.user.is_authenticated and any(
|
||||||
[self.model.__name__.lower() in x for x in self.request.user.searchpreference.unaccent.values_list('field', flat=True)]):
|
[self.model.__name__.lower() in x for x in self.request.user.searchpreference.unaccent.values_list('field', flat=True)]):
|
||||||
self.queryset = self.queryset.annotate(trigram=TrigramSimilarity('name__unaccent', query))
|
self.queryset = self.queryset.annotate(trigram=TrigramSimilarity('name__unaccent', query))
|
||||||
|
@ -16,12 +16,13 @@ from django.utils import timezone
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
|
|
||||||
from cookbook.forms import (CommentForm, Recipe, SearchPreferenceForm, SpaceCreateForm, SpaceJoinForm, User,
|
from cookbook.forms import (CommentForm, Recipe, SearchPreferenceForm, SpaceCreateForm,
|
||||||
UserCreateForm, UserPreference)
|
SpaceJoinForm, User, UserCreateForm, UserPreference)
|
||||||
from cookbook.helper.permission_helper import group_required, has_group_permission, share_link_valid, switch_user_active_space
|
from cookbook.helper.permission_helper import (group_required, has_group_permission,
|
||||||
from cookbook.models import (Comment, CookLog, InviteLink, SearchFields, SearchPreference, ShareLink,
|
share_link_valid, switch_user_active_space)
|
||||||
Space, ViewLog, UserSpace)
|
from cookbook.models import (Comment, CookLog, InviteLink, SearchFields, SearchPreference,
|
||||||
from cookbook.tables import (CookLogTable, ViewLogTable)
|
ShareLink, Space, UserSpace, ViewLog)
|
||||||
|
from cookbook.tables import CookLogTable, ViewLogTable
|
||||||
from cookbook.version_info import VERSION_INFO
|
from cookbook.version_info import VERSION_INFO
|
||||||
from recipes.settings import PLUGINS
|
from recipes.settings import PLUGINS
|
||||||
|
|
||||||
@ -219,10 +220,10 @@ def shopping_settings(request):
|
|||||||
if not sp:
|
if not sp:
|
||||||
sp = SearchPreferenceForm(user=request.user)
|
sp = SearchPreferenceForm(user=request.user)
|
||||||
fields_searched = (
|
fields_searched = (
|
||||||
len(search_form.cleaned_data['icontains'])
|
len(search_form.cleaned_data['icontains'])
|
||||||
+ len(search_form.cleaned_data['istartswith'])
|
+ len(search_form.cleaned_data['istartswith'])
|
||||||
+ len(search_form.cleaned_data['trigram'])
|
+ len(search_form.cleaned_data['trigram'])
|
||||||
+ len(search_form.cleaned_data['fulltext'])
|
+ len(search_form.cleaned_data['fulltext'])
|
||||||
)
|
)
|
||||||
if search_form.cleaned_data['preset'] == 'fuzzy':
|
if search_form.cleaned_data['preset'] == 'fuzzy':
|
||||||
sp.search = SearchPreference.SIMPLE
|
sp.search = SearchPreference.SIMPLE
|
||||||
@ -278,8 +279,7 @@ def shopping_settings(request):
|
|||||||
search_form = SearchPreferenceForm()
|
search_form = SearchPreferenceForm()
|
||||||
|
|
||||||
# these fields require postgresql - just disable them if postgresql isn't available
|
# these fields require postgresql - just disable them if postgresql isn't available
|
||||||
if not settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
if not settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql':
|
||||||
'django.db.backends.postgresql']:
|
|
||||||
sp.search = SearchPreference.SIMPLE
|
sp.search = SearchPreference.SIMPLE
|
||||||
sp.trigram.clear()
|
sp.trigram.clear()
|
||||||
sp.fulltext.clear()
|
sp.fulltext.clear()
|
||||||
@ -309,10 +309,7 @@ def system(request):
|
|||||||
if not request.user.is_superuser:
|
if not request.user.is_superuser:
|
||||||
return HttpResponseRedirect(reverse('index'))
|
return HttpResponseRedirect(reverse('index'))
|
||||||
|
|
||||||
postgres = False if (
|
postgres = settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql'
|
||||||
settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql_psycopg2' # noqa: E501
|
|
||||||
or settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql' # noqa: E501
|
|
||||||
) else True
|
|
||||||
|
|
||||||
secret_key = False if os.getenv('SECRET_KEY') else True
|
secret_key = False if os.getenv('SECRET_KEY') else True
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ spec:
|
|||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
backup.velero.io/backup-volumes: media,static
|
backup.velero.io/backup-volumes: media,static
|
||||||
labels:
|
labels:
|
||||||
app: recipes
|
app: recipes
|
||||||
tier: frontend
|
tier: frontend
|
||||||
@ -35,7 +35,7 @@ spec:
|
|||||||
name: recipes
|
name: recipes
|
||||||
key: secret-key
|
key: secret-key
|
||||||
- name: DB_ENGINE
|
- name: DB_ENGINE
|
||||||
value: django.db.backends.postgresql_psycopg2
|
value: django.db.backends.postgresql
|
||||||
- name: POSTGRES_HOST
|
- name: POSTGRES_HOST
|
||||||
value: recipes-postgresql
|
value: recipes-postgresql
|
||||||
- name: POSTGRES_PORT
|
- name: POSTGRES_PORT
|
||||||
@ -162,7 +162,7 @@ spec:
|
|||||||
- name: GUNICORN_MEDIA
|
- name: GUNICORN_MEDIA
|
||||||
value: "0"
|
value: "0"
|
||||||
- name: DB_ENGINE
|
- name: DB_ENGINE
|
||||||
value: django.db.backends.postgresql_psycopg2
|
value: django.db.backends.postgresql
|
||||||
- name: POSTGRES_HOST
|
- name: POSTGRES_HOST
|
||||||
value: recipes-postgresql
|
value: recipes-postgresql
|
||||||
- name: POSTGRES_PORT
|
- name: POSTGRES_PORT
|
||||||
|
Loading…
Reference in New Issue
Block a user