def building_list(request, format=None): """ List all buildings, or create a new building. """ if request.method == 'GET': buildings = Building.objects.all() serializer = BuildingSerializer(buildings, many=True) return Response(serializer.data)
def get_campus_info(request, campus_id, format=None): """ Get a list of buildings on a singlge campus """ if request.method == 'GET': buildings_on_campus = Building.objects.filter( fk_campus=campus_id).order_by('id') serializer = BuildingSerializer(buildings_on_campus, many=True) return Response(serializer.data)
def list_buildings_on_campus(request, pk_campus): """ List all buildings, located on a specific campus area """ if request.method == 'GET': buildings = Building.objects.filter(fk_campus=pk_campus) serializer = BuildingSerializer(buildings, many=True) return Response(serializer.data)
def building_detail(request, pk, format=None): """ Return all floors """ try: building = Building.objects.get(pk=pk) except Building.DoesNotExist: return HttpResponse(status=404) if request.method == 'GET': serializer = BuildingSerializer(building) return Response(serializer.data)
def building_detail(request, pk, format=None): """ Retrieve, update or delete a code snippet. """ try: building = Building.objects.get(pk=pk) except Building.DoesNotExist: return HttpResponse(status=404) if request.method == 'GET': serializer = BuildingSerializer(building) return Response(serializer.data)
def campus_buildings_list(request, campus_id, format=None, **kwargs): """ List all buildings within a single campus :param request: :param campus_id: integer :param format: :param kwargs: ?details=True returns floor data aswell :return: """ if request.method == 'GET': buildings = Building.objects.filter(fk_campus=campus_id).order_by('id') serializer = BuildingSerializer(buildings, many=True) map_name = kwargs.pop('map_name', None) details = request.GET.get('details') # print(type(details)) if details == 'True': serializer_detail = BuildingSerializer(buildings, many=True) return Response(serializer_detail.data) else: return Response(serializer.data)