@@ -450,14 +450,14 @@ class RestoreSuccessDataSerializer(serializers.Serializer):
450450 """
451451 learning_package_id = serializers .IntegerField (source = "lp_restored_data.id" )
452452 title = serializers .CharField (source = "lp_restored_data.title" )
453- # archive_org_code and archive_package_code may be None when archive_package_ref cannot be parsed
454- # as {prefix}:{org_code}:{package_code} (previously this raised ValueError in openedx-core).
455- org = serializers . CharField ( source = "lp_restored_data.archive_org_code" , allow_null = True )
456- slug = serializers . CharField ( source = "lp_restored_data.archive_package_code" , allow_null = True )
457-
458- # The `key` is a unique temporary key assigned to the learning package during the restore process,
459- # whereas the `archive_key` is the original key of the learning package from the backup.
460- # The temporary learning package key is replaced with a standard key once it is added to a content library.
453+ org = serializers . SerializerMethodField ()
454+ slug = serializers . SerializerMethodField ()
455+
456+ # The `package_ref` is a unique temporary key assigned to the learning
457+ # package during the restore process, whereas the `archive_package_ref` is
458+ # the original key of the learning package from the backup. The temporary
459+ # learning package_ref is replaced with a standard key once it is added to a
460+ # content library.
461461 key = serializers .CharField (source = "lp_restored_data.package_ref" )
462462 archive_key = serializers .CharField (source = "lp_restored_data.archive_package_ref" )
463463
@@ -472,6 +472,18 @@ class RestoreSuccessDataSerializer(serializers.Serializer):
472472 created_at = serializers .DateTimeField (source = "backup_metadata.created_at" , format = DATETIME_FORMAT )
473473 created_by = serializers .SerializerMethodField ()
474474
475+ def get_org (self , obj ) -> str :
476+ """
477+ The org code/slug, as parsed from archive_package_ref, or "unknown" if unparseable.
478+ """
479+ return obj ["lp_restored_data" ]["archive_org_code" ] or "unknown"
480+
481+ def get_slug (self , obj ) -> str :
482+ """
483+ The library code/slug, as parsed from archive_package_ref, or "unknown" if unparseable.
484+ """
485+ return obj ["lp_restored_data" ]["archive_package_code" ] or "unknown"
486+
475487 def get_created_by (self , obj ):
476488 """
477489 Get the user information of the archive creator, if available.
0 commit comments