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
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
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)
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
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)
def get(self, request,format=None): location = Metadata.objects.all() print("requet is successded--------->") serializer = MetadataSerializer(location, many=True) return Response(serializer.data)
def get(self, request, format=None): mds = MetadataSerializer(Metadata()) return Response(mds.data)
def list(self, request): tmp = self.paginate_queryset(self.get_queryset()) serializer = MetadataSerializer(tmp, many=True) return self.get_paginated_response(serializer.data)