def get_queryset(self): return [ serializers.ContentType(content_type=ctype.__name__) for ctype in get_content_types() ]
import json from collections import namedtuple from django.core.urlresolvers import reverse from django.contrib.auth.models import Group, User from rest_framework import serializers from hs_core.hydroshare import utils from hs_core import hydroshare from .utils import validate_json, validate_user, validate_group from hs_access_control.models import PrivilegeCodes from drf_yasg.utils import swagger_serializer_method RESOURCE_TYPES = [rtype.__name__ for rtype in utils.get_resource_types()] CONTENT_TYPES = [ctype.__name__ for ctype in utils.get_content_types()] class StringListField(serializers.ListField): child = serializers.CharField() class ResourceUpdateRequestValidator(serializers.Serializer): title = serializers.CharField(required=False) metadata = serializers.CharField(validators=[validate_json], required=False) extra_metadata = serializers.CharField(validators=[validate_json], required=False) edit_users = serializers.CharField(required=False) edit_groups = serializers.CharField(required=False) view_users = serializers.CharField(required=False) view_groups = serializers.CharField(required=False) keywords = StringListField(required=False)