Skip to content

Commit

Permalink
refactor: fix parler deprecation warning
Browse files Browse the repository at this point in the history
Please change apiscopetranslation.master to a
parler.fields.TranslationsForeignKey field to
support translations in data migrations.

Refs: HP-2441
  • Loading branch information
charn committed Jul 31, 2024
1 parent 9f62c0b commit 22268a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions oidc_apis/migrations/0004_alter_apiscopetranslation_master.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.14 on 2024-07-31 11:37

from django.db import migrations
import django.db.models.deletion
import parler.fields


class Migration(migrations.Migration):

dependencies = [
("oidc_apis", "0003_api_backchannel_logout_url"),
]

operations = [
migrations.AlterField(
model_name="apiscopetranslation",
name="master",
field=parler.fields.TranslationsForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="translations",
to="oidc_apis.apiscope",
verbose_name="API scope",
),
),
]
4 changes: 2 additions & 2 deletions oidc_apis/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.utils.translation import gettext_lazy as _
from multiselectfield import MultiSelectField
from oidc_provider.models import Client
from parler.fields import TranslatedField
from parler.fields import TranslatedField, TranslationsForeignKey
from parler.managers import TranslatableQuerySet
from parler.models import TranslatableModel, TranslatedFieldsModel

Expand Down Expand Up @@ -193,7 +193,7 @@ def _get_required_scopes(cls, scopes):


class ApiScopeTranslation(TranslatedFieldsModel):
master = models.ForeignKey(
master = TranslationsForeignKey(
ApiScope, related_name='translations', null=True,
on_delete=models.CASCADE,
verbose_name=_("API scope"))
Expand Down

0 comments on commit 22268a4

Please sign in to comment.