コード例 #1
0
 def get_custom_libraries(self, request):
     if request.user.is_authenticated:
         lib_sets = LibrarySet.objects.filter(
             Q(user=request.user) & Q(default=False))
         queryset = Library.objects.filter(library_set__in=lib_sets)
         return Response(LibrarySerializer(queryset, many=True).data)
     return Response()
コード例 #2
0
ファイル: serializers.py プロジェクト: akshat2602/eSim-Cloud
class SaveListSerializer(serializers.ModelSerializer):
    base64_image = Base64ImageField(max_length=None, use_url=True)
    esim_libraries = LibrarySerializer(many=True, required=False)
    project_id = serializers.CharField(read_only=True,
                                       source='project.project_id')
    project_version = serializers.CharField(read_only=True,
                                            source='project.active_version')
    project_branch = serializers.CharField(read_only=True,
                                           source='project.active_branch')
    is_reported = serializers.BooleanField(read_only=True,
                                           source='project.is_reported')
    lti_id = serializers.SerializerMethodField()

    class Meta:
        model = StateSave
        fields = ('save_time', 'save_id', 'name', 'description', 'shared',
                  'base64_image', 'create_time', 'version', 'branch',
                  'esim_libraries', 'project_id', 'project_version',
                  'project_branch', 'is_reported', 'id', 'lti_id')

    def get_lti_id(self, obj):
        save_id = obj.save_id
        ltis = lticonsumer.objects.filter(model_schematic__save_id=save_id)
        if ltis.exists():
            return ltis[0].id
        else:
            return None
コード例 #3
0
class SaveListSerializer(serializers.ModelSerializer):
    base64_image = Base64ImageField(max_length=None, use_url=True)
    esim_libraries = LibrarySerializer(many=True, required=False)

    class Meta:
        model = StateSave
        fields = ('save_time', 'save_id', 'name', 'description', 'shared',
                  'base64_image', 'create_time', 'esim_libraries')
コード例 #4
0
ファイル: serializers.py プロジェクト: akshat2602/eSim-Cloud
class GallerySerializer(serializers.ModelSerializer):

    media = Base64ImageField(max_length=None, use_url=True)
    esim_libraries = LibrarySerializer(many=True, required=False)

    class Meta:
        model = Gallery
        fields = ('save_id', 'data_dump', 'name', 'description', 'media',
                  'shared', 'esim_libraries')
コード例 #5
0
 def default(self, request):
     return Response(
         LibrarySerializer(Library.objects.filter(
             Q(library_set__default=True)),
                           many=True).data)