fix metadata copy methods
@@ -212,12 +212,14 @@ class SupportedResTypes(AbstractMetaDataElement):
@classmethod
def _add_supported_res_type(cls, meta_instance, supported_res_types):
-
for res_type in supported_res_types:
# there are two possibilities for res_type_str values:
# list of string (during normal create or update) or
# integer (during creating new version of the resource)
- if isinstance(res_type, int):
+ if isinstance(res_type, SupportedResTypeChoices):
+ meta_instance.supported_res_types.add(res_type)
+
+ elif isinstance(res_type, int):
# "copy res" or "create a new version"
qs = SupportedResTypeChoices.objects.filter(id=res_type)
if not qs.exists():
@@ -387,7 +389,9 @@ class SupportedSharingStatus(AbstractMetaDataElement):
# there are two possibilities for res_type_str values:
# list of string (during normal create or update) or
# integer (during creating new version of the resource)
- if isinstance(sharing_status, int):
+ if isinstance(sharing_status, SupportedSharingStatusChoices):
+ meta_instance.sharing_status.add(sharing_status)
+ elif isinstance(sharing_status, int):
# "copy res" or "create a new version"
qs = SupportedSharingStatusChoices.objects.filter(id=sharing_status)
if not qs.exists():
