MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / PluginRepoSerializer

Class PluginRepoSerializer

apps/plugins/serializers.py:56–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56class PluginRepoSerializer(serializers.ModelSerializer):
57 registry_url = serializers.SerializerMethodField()
58 plugin_count = serializers.SerializerMethodField()
59
60 class Meta:
61 model = PluginRepo
62 fields = [
63 "id",
64 "name",
65 "url",
66 "is_official",
67 "enabled",
68 "public_key",
69 "signature_verified",
70 "registry_url",
71 "plugin_count",
72 "last_fetched",
73 "last_fetch_status",
74 "created_at",
75 "updated_at",
76 ]
77 read_only_fields = ["id", "name", "is_official", "signature_verified", "registry_url", "plugin_count", "last_fetched", "last_fetch_status", "created_at", "updated_at"]
78
79 def get_registry_url(self, obj):
80 manifest = (obj.cached_manifest or {}).get("manifest", obj.cached_manifest or {})
81 return manifest.get("registry_url", "") or ""
82
83 def get_plugin_count(self, obj):
84 manifest = (obj.cached_manifest or {}).get("manifest", obj.cached_manifest or {})
85 plugins = manifest.get("plugins", [])
86 return len(plugins) if isinstance(plugins, list) else 0

Callers 4

getMethod · 0.85
postMethod · 0.85
putMethod · 0.85
postMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected