get-changed_object: accept ModelInstanceWrapper

This commit is contained in:
Laura Klünder 2017-07-07 15:02:50 +02:00
parent 56f30ec3c0
commit 369a1b558b

View file

@ -20,7 +20,7 @@ from rest_framework.exceptions import PermissionDenied
from c3nav.editor.models.changedobject import ChangedObject from c3nav.editor.models.changedobject import ChangedObject
from c3nav.editor.utils import is_created_pk from c3nav.editor.utils import is_created_pk
from c3nav.editor.wrappers import ModelWrapper from c3nav.editor.wrappers import ModelInstanceWrapper, ModelWrapper
from c3nav.mapdata.models import LocationSlug, MapUpdate from c3nav.mapdata.models import LocationSlug, MapUpdate
from c3nav.mapdata.models.locations import LocationRedirect from c3nav.mapdata.models.locations import LocationRedirect
from c3nav.mapdata.utils.models import get_submodels from c3nav.mapdata.utils.models import get_submodels
@ -317,6 +317,8 @@ class ChangeSet(models.Model):
return r return r
def get_changed_object(self, obj) -> ChangedObject: def get_changed_object(self, obj) -> ChangedObject:
if isinstance(obj, ModelInstanceWrapper):
obj = obj._obj
model = obj.__class__ model = obj.__class__
pk = obj.pk pk = obj.pk
if pk is None: if pk is None: