Beispiel #1
0
class CredentialAutocompleteSerializer(HaystackSerializerMixin,
                                       CredentialSerializer):
    names = CredentialNameSerializer(many=True)

    class Meta(CredentialSerializer.Meta):
        fields = ("id", "names", "inactive")
        status_fields = {
            "inactive": None,
            "latest": "true",
            "revoked": "false"
        }
Beispiel #2
0
class CredentialSearchSerializer(HaystackSerializerMixin,
                                 CredentialSerializer):
    addresses = CredentialAddressSerializer(many=True)
    attributes = CredentialAttributeSerializer(many=True)
    credential_set = CredentialSetSerializer()
    credential_type = CredentialTypeSerializer()
    names = CredentialNameSerializer(many=True)
    topic = CredentialNamedTopicSerializer()
    related_topics = CredentialNamedTopicSerializer(many=True)

    class Meta(CredentialSerializer.Meta):
        fields = (
            "id",
            "create_timestamp",
            "update_timestamp",
            "effective_date",
            "inactive",
            "latest",
            "revoked",
            "revoked_date",
            "credential_id",
            "credential_set",
            "credential_type",
            "addresses",
            "attributes",
            "names",
            "topic",
            "related_topics",
        )
        # used by ExactFilter
        exact_fields = (
            "credential_set_id",
            "credential_type_id",
            "topic_credential_type_id",
            "issuer_id",
            "schema_name",
            "schema_version",
            "topic_id",
            "topic_type",
            "credential_id",
        )
        # used by HaystackFilter
        search_fields = ("location", "effective_date", "revoked_date", "score")
        # used by StatusFilter
        status_fields = {
            "inactive": "false",
            "latest": "true",
            "revoked": "false"
        }
Beispiel #3
0
class CredentialSerializer(ModelSerializer):
    attributes = CredentialAttributeSerializer(many=True)
    names = CredentialNameSerializer(many=True)

    class Meta:
        model = Credential
        fields = (
            "id",
            "credential_type",
            "credential_id",
            "credential_def_id",
            "effective_date",
            "inactive",
            "latest",
            "revoked",
            "revoked_date",
            "revoked_by",
            "attributes",
            "names",
        )
        read_only_fields = fields