Skip to content

Commit

Permalink
Migrate to polymorphic manytomany field
Browse files Browse the repository at this point in the history
  • Loading branch information
hipek8 committed Oct 2, 2024
1 parent 7337de1 commit 84d3361
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/ralph/operations/migrations/0013_auto_20241002_1122.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2024-10-02 11:22
from __future__ import unicode_literals

from django.db import migrations
import ralph.lib.polymorphic.fields


class Migration(migrations.Migration):

dependencies = [
('operations', '0012_auto_20211206_1347'),
]

operations = [
migrations.AlterField(
model_name='operation',
name='base_objects',
field=ralph.lib.polymorphic.fields.PolymorphicManyToManyField(blank=True, related_name='operations', to='assets.BaseObject', verbose_name='objects'),
),
]
3 changes: 2 additions & 1 deletion src/ralph/operations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
NamedMixin,
TaggableMixin
)
from ralph.lib.polymorphic.fields import PolymorphicManyToManyField


class OperationStatus(AdminAbsoluteUrlMixin, NamedMixin, models.Model):
Expand Down Expand Up @@ -96,7 +97,7 @@ class Operation(AdminAbsoluteUrlMixin, TaggableMixin, models.Model):
resolved_date = models.DateTimeField(
null=True, blank=True, verbose_name=_('resolved date'),
)
base_objects = models.ManyToManyField(
base_objects = PolymorphicManyToManyField(
BaseObject, related_name='operations', verbose_name=_('objects'),
blank=True,
)
Expand Down
21 changes: 21 additions & 0 deletions src/ralph/supports/migrations/0010_auto_20241002_1122.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2024-10-02 11:22
from __future__ import unicode_literals

from django.db import migrations
import ralph.lib.polymorphic.fields


class Migration(migrations.Migration):

dependencies = [
('supports', '0009_auto_20240506_1633'),
]

operations = [
migrations.AlterField(
model_name='support',
name='base_objects',
field=ralph.lib.polymorphic.fields.PolymorphicManyToManyField(related_name='_support_base_objects_+', through='supports.BaseObjectsSupport', to='assets.BaseObject'),
),
]
3 changes: 2 additions & 1 deletion src/ralph/supports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NamedMixin,
PriceMixin
)
from ralph.lib.polymorphic.fields import PolymorphicManyToManyField
from ralph.lib.polymorphic.models import PolymorphicQuerySet


Expand Down Expand Up @@ -131,7 +132,7 @@ class Support(
default=None,
null=True,
)
base_objects = models.ManyToManyField(
base_objects = PolymorphicManyToManyField(
BaseObject,
related_name='+',
through='BaseObjectsSupport',
Expand Down

0 comments on commit 84d3361

Please sign in to comment.