コード例 #1
0
 def get(self,request,location_id, format=None):
     try:
         queryset= Metadata.objects.filter(LOCATION=location_id)
         locations = MetadataSerializer(queryset, many=True)
         return Response(locations.data,status= status.HTTP_201_CREATED)
     except:
         raise
コード例 #2
0
 def get(self,request,location_id,department_id, format=None):
     try:
         queryset= Metadata.objects.filter(Q(LOCATION=location_id)& Q(DEPARTMENT=department_id))
         departments = MetadataSerializer(queryset, many=True)
         return Response(departments.data,status= status.HTTP_201_CREATED)
     except:
         raise
コード例 #3
0
 def retrieve(self, request, pk=None):
     try:
         tmp = Metadata.objects.get(id=pk)
         if not tmp.is_active:
             return Response(status=423)
         return Response(MetadataSerializer(tmp).data)
     except ObjectDoesNotExist:
         return Response(RESOURCE_NOT_FOUND, status=404)
コード例 #4
0
 def get(self,request,location_id,department_id,category_id, format=None):
     try:
         if "Ê" in department_id:
             department_id = department_id.replace("Ê",'')
         if "Ê" in category_id:
             category_id = category_id.replace("Ê",'')
         print(department_id,category_id)
         queryset= Metadata.objects.filter(Q(LOCATION=location_id) & Q(DEPARTMENT=department_id)&Q(CATEGORY= category_id))
         category = MetadataSerializer(queryset, many=True)
         return Response(category.data,status= status.HTTP_201_CREATED)
     except:
         raise
コード例 #5
0
 def post(self, request, location_id,format=None):
     serializer = MetadataSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
コード例 #6
0
 def get(self, request,format=None):
     location = Metadata.objects.all()
     print("requet is successded--------->")
     serializer = MetadataSerializer(location, many=True)
     return Response(serializer.data)
コード例 #7
0
ファイル: views.py プロジェクト: isabella232/discovery-5
 def get(self, request, format=None):
     mds = MetadataSerializer(Metadata())
     return Response(mds.data)
コード例 #8
0
 def list(self, request):
     tmp = self.paginate_queryset(self.get_queryset())
     serializer = MetadataSerializer(tmp, many=True)
     return self.get_paginated_response(serializer.data)