Simplified AlterModelTable by making it subclass ModelOptionOperation.
This commit is contained in:
parent
75f8264083
commit
4cf1f2f13e
|
@ -428,7 +428,14 @@ class RenameModel(ModelOperation):
|
|||
)
|
||||
|
||||
|
||||
class AlterModelTable(ModelOperation):
|
||||
class ModelOptionOperation(ModelOperation):
|
||||
def reduce(self, operation, app_label=None):
|
||||
if isinstance(operation, (self.__class__, DeleteModel)) and self.name_lower == operation.name_lower:
|
||||
return [operation]
|
||||
return super().reduce(operation, app_label=app_label)
|
||||
|
||||
|
||||
class AlterModelTable(ModelOptionOperation):
|
||||
"""Rename a model's table."""
|
||||
|
||||
def __init__(self, name, table):
|
||||
|
@ -477,18 +484,6 @@ class AlterModelTable(ModelOperation):
|
|||
self.table if self.table is not None else "(default)"
|
||||
)
|
||||
|
||||
def reduce(self, operation, app_label=None):
|
||||
if isinstance(operation, (AlterModelTable, DeleteModel)) and self.name_lower == operation.name_lower:
|
||||
return [operation]
|
||||
return super().reduce(operation, app_label=app_label)
|
||||
|
||||
|
||||
class ModelOptionOperation(ModelOperation):
|
||||
def reduce(self, operation, app_label=None):
|
||||
if isinstance(operation, (self.__class__, DeleteModel)) and self.name_lower == operation.name_lower:
|
||||
return [operation]
|
||||
return super().reduce(operation, app_label=app_label)
|
||||
|
||||
|
||||
class AlterTogetherOptionOperation(ModelOptionOperation):
|
||||
option_name = None
|
||||
|
|
Loading…
Reference in New Issue