Пример #1
0
    def __init__(self, username_str):

        self.file_list = File.objects.filter(updated_by=username_str, status=1)
        self.part_list = Part.objects.filter(is_active=True)
        self.package_list = Package.objects.filter(is_active=True)
        self.routerMaster_list = RouterMaster.objects.filter(is_active=True)
        self.order_list = Order.objects.filter()
        self.project_code = self.file_list[0].project_code

        self.CSV_name_str = settings.MEDIA_ROOT + '/' + FileManagement.find_file(
            configPart.configs.get("UPLOAD_ORDER_PART").data,
            str(self.file_list[0].file_no) + "DatabaseCSV.csv")

        self.updated_by = username_str
Пример #2
0
    def covert_data_list_to_serializer_list(file_list):

        file_return_list = []

        for file_obj in file_list:

            fileSerializer = FileSerializer()
            fileSerializer.customer_code = file_obj[0]
            fileSerializer.project_code = file_obj[1]
            fileSerializer.file_no = file_obj[2]
            fileSerializer.order_count = file_obj[3]
            fileSerializer.status = file_obj[4]
            fileSerializer.updated_by = file_obj[5]
            fileSerializer.updated_date = file_obj[6]
            fileSerializer.csv_url = FileManagement.find_file(
                configPart.configs.get("UPLOAD_ORDER_PART").data,
                file_obj[2] + ".csv")

            file_return_list.append(fileSerializer)

        return file_return_list
Пример #3
0
def get_files(request):

    try: 

        if request.method == 'GET':
      
            file_list = File.objects.filter(updated_by= request.user.username, status = 1)

            if len(file_list) > 0 :

                csv_name = FileManagement.find_file(configPart.configs.get("UPLOAD_ORDER_PART").data,file_list[0].file_no+".csv")
                serializer = serializerMapping.mapping_serializer_list(File_list_Serializer_DTO,file_list,"success",None,csv_name,None,None )

            else :

                serializer = serializerMapping.mapping_serializer_list(File_list_Serializer_DTO,[],"success",None,None,None,None )

            return Response(serializer.data,  status=status.HTTP_200_OK)

    except Exception as e:
        
        serializer = serializerMapping.mapping_serializer_list(FileSerializer,None,"Error",e,None,None,None )

        return Response(serializer.data, status=status.HTTP_200_OK)