def retail_sizes():
    us_retail_sizes = RetailSize.objects.order_by('width', 'length').filter(unit_of_measurement = 'in')

    uk_retail_sizes = RetailSize.objects.order_by('width', 'length').filter(unit_of_measurement = 'cm')

    us_size_list = [(int(size.id), display.retail_size(size)) for size in us_retail_sizes]
    uk_size_list = [(int(size.id), display.retail_size(size)) for size in uk_retail_sizes]
    size_list = us_size_list + uk_size_list
    return size_list
Exemple #2
0
def retail_sizes():
    us_retail_sizes = RetailSize.objects.order_by(
        'width', 'length').filter(unit_of_measurement='in')

    uk_retail_sizes = RetailSize.objects.order_by(
        'width', 'length').filter(unit_of_measurement='cm')

    us_size_list = [(int(size.id), display.retail_size(size))
                    for size in us_retail_sizes]
    uk_size_list = [(int(size.id), display.retail_size(size))
                    for size in uk_retail_sizes]
    size_list = us_size_list + uk_size_list
    return size_list
Exemple #3
0
def get_output_count(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)
    output_list = []
    output_dict = {}
    for entry in entries:
        coating = entry.retail_cutting_sheet.coating_id
        panel_depth = entry.retail_cutting_sheet.panel_depth_id
        if coating not in output_dict:
            output_dict[coating] = {}
        if panel_depth not in output_dict[coating]:
            output_dict[coating][panel_depth] = {}

        instructions = RetailCuttingSheetInstruction.objects.filter(retail_cutting_sheet_entry_id = entry.id)

        for instruction in instructions:
            quantity_to_cut = instruction.quantity
            outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = instruction.retail_cutting_pattern_id)
            for output in outputs:
                is_cradled = output.is_for_cradle
                retail_size = RetailSize.objects.get(id = output.retail_size_id)
                if is_cradled not in output_dict[coating][panel_depth]:
                    output_dict[coating][panel_depth][is_cradled] = {}
                output_dict[coating][panel_depth][is_cradled][output.retail_size_id] = \
                        quantity_to_cut*output.quantity if output.retail_size_id not in\
                        output_dict[coating][panel_depth][is_cradled] else \
                        output_dict[coating][panel_depth][is_cradled][output.retail_size_id] + quantity_to_cut*output.quantity
    for coating in output_dict.iterkeys():
        for panel_depth in output_dict[coating].iterkeys():
            for is_cradled in output_dict[coating][panel_depth].iterkeys():
                for retail_size, quantity in output_dict[coating][panel_depth][is_cradled].iteritems():
                    retail_size_display = display.retail_size(RetailSize.objects.get(id = retail_size))
                    output_list.append(CuttingSheetOutputQuantityDisplay(retail_size, \
                            retail_size_display, 'c' if is_cradled else 'f', coating_id, quantity))
    output_list = sort_outputs(output_list)
    return output_list
Exemple #4
0
def cutting_patterns(primarySizeId, isForCradle, secondarySizeId,
                     primarySizeQuantity):
    '''
    Description
    -----------
    Returns all cutting patterns that have the retail size specified by
    retailSizeId in them.  isForCradle and desiredQuantity just go along for 
    the ride so that they are persisted into WIP
    '''

    #get all desired cutting pattern outputs which are primary
    cutting_pattern_outputs = RetailCuttingPatternOutput.objects.\
            filter(retail_size_id = primarySizeId, is_primary = True,\
            is_for_cradle = conversions.bool_map[isForCradle], retail_cutting_pattern__is_active = True).\
            order_by("retail_cutting_pattern__cutting_instructions","-retail_cutting_pattern__grade")

    patterns = []
    for output in cutting_pattern_outputs:
        quantity = output.quantity
        #get the primary output's family
        output_family = RetailCuttingPatternOutput.objects.\
                        filter(retail_cutting_pattern_id = \
                        output.retail_cutting_pattern.id)
        #check to see if secondarySize is a sibling of output
        secondary_a_sibling = False
        for sibling in output_family:
            if secondarySizeId == '' or int(
                    sibling.retail_size_id) == int(secondarySizeId):
                secondary_a_sibling = True

        if secondary_a_sibling:
            output_displays = [OutputDisplay(display.retail_size(\
                           output.retail_size), output.retail_size.id, output.quantity,\
                           'c' if output.is_for_cradle else 'f', output.is_primary)]
            output_displays += [OutputDisplay(display.retail_size(\
                           sibling.retail_size), sibling.retail_size.id, sibling.quantity,\
                           'c' if sibling.is_for_cradle else 'f', sibling.is_primary)
                           for sibling in output_family if sibling.id != output.id]
            patterns.append(CuttingPatternsDisplay\
                    (output_displays, output.retail_cutting_pattern.id, output.retail_cutting_pattern.grade, \
                    display.tercero_size(output.retail_cutting_pattern.coating_size), output.retail_cutting_pattern.coating_size, \
                    format_cutting_pattern(output.retail_cutting_pattern.cutting_instructions, output.retail_cutting_pattern.coating_size),\
                    'n/a' if not primarySizeQuantity else str(int(math.\
                    ceil(float(primarySizeQuantity)/float(output.quantity)))) + ' needed'))
    return patterns
Exemple #5
0
 def verbose_name(self):
     display_string =display.small_measurement(self.panel_depth) + " panel--" + display.retail_size(self.retail_size) +\
             "--" + self.coating.description
     if self.spray_color:
         display_string += "--" + self.spray_color.color
     if self.cradle_depth:
         display_string += "--cradled->depth: " + display.small_measurement(self.cradle_depth) +\
                 ", width: " + display.small_measurement(self.cradle_width)
     return display_string
Exemple #6
0
 def verbose_name(self):
     display_string =display.small_measurement(self.panel_depth) + " panel--" + display.retail_size(self.retail_size) +\
             "--" + self.coating.description
     if self.spray_color:
         display_string += "--" + self.spray_color.color
     if self.cradle_depth:
         display_string += "--cradled->depth: " + display.small_measurement(self.cradle_depth) +\
                 ", width: " + display.small_measurement(self.cradle_width)
     return display_string
Exemple #7
0
def cutting_patterns(primarySizeId, isForCradle, secondarySizeId, primarySizeQuantity):
    '''
    Description
    -----------
    Returns all cutting patterns that have the retail size specified by
    retailSizeId in them.  isForCradle and desiredQuantity just go along for 
    the ride so that they are persisted into WIP
    '''

    #get all desired cutting pattern outputs which are primary
    cutting_pattern_outputs = RetailCuttingPatternOutput.objects.\
            filter(retail_size_id = primarySizeId, is_primary = True,\
            is_for_cradle = conversions.bool_map[isForCradle], retail_cutting_pattern__is_active = True).\
            order_by("retail_cutting_pattern__cutting_instructions","-retail_cutting_pattern__grade")

    patterns = []
    for output in cutting_pattern_outputs:
        quantity = output.quantity
        #get the primary output's family
        output_family = RetailCuttingPatternOutput.objects.\
                        filter(retail_cutting_pattern_id = \
                        output.retail_cutting_pattern.id)
        #check to see if secondarySize is a sibling of output
        secondary_a_sibling = False
        for sibling in output_family:
            if secondarySizeId == '' or int(sibling.retail_size_id) == int(secondarySizeId):
                secondary_a_sibling = True
        
        if secondary_a_sibling:
            output_displays = [OutputDisplay(display.retail_size(\
                           output.retail_size), output.retail_size.id, output.quantity,\
                           'c' if output.is_for_cradle else 'f', output.is_primary)]
            output_displays += [OutputDisplay(display.retail_size(\
                           sibling.retail_size), sibling.retail_size.id, sibling.quantity,\
                           'c' if sibling.is_for_cradle else 'f', sibling.is_primary)
                           for sibling in output_family if sibling.id != output.id]
            patterns.append(CuttingPatternsDisplay\
                    (output_displays, output.retail_cutting_pattern.id, output.retail_cutting_pattern.grade, \
                    display.tercero_size(output.retail_cutting_pattern.coating_size), output.retail_cutting_pattern.coating_size, \
                    format_cutting_pattern(output.retail_cutting_pattern.cutting_instructions, output.retail_cutting_pattern.coating_size),\
                    'n/a' if not primarySizeQuantity else str(int(math.\
                    ceil(float(primarySizeQuantity)/float(output.quantity)))) + ' needed'))
    return patterns
Exemple #8
0
def review_instructions(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)

    instructions = RetailCuttingSheetInstruction.objects.filter(retail_cutting_sheet_entry_id__in = \
                        entries).order_by('retail_cutting_pattern__cutting_instructions')
    output_list = []
    for instruction in instructions:
        cutting_pattern = RetailCuttingPattern.objects.get(id = \
                                instruction.retail_cutting_pattern_id)
        coating_size_id = instruction.retail_cutting_pattern.coating_size.id
        instruction_string = instruction.retail_cutting_pattern.cutting_instructions
        quantity = instruction.quantity
        cutting_pattern_id = instruction.retail_cutting_pattern_id
        outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                            cutting_pattern_id)
        cutting_pattern = RetailCuttingPattern.objects.get(
            id=cutting_pattern_id)
        outputString = ''
        for output in outputs:
            retail_size_display = display.retail_size(
                RetailSize.objects.get(id=output.retail_size_id))
            outputString = outputString + retail_size_display + \
                (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

        tercero = CoatingSize.objects.get(id=coating_size_id)
        terceroDisplay = ''
        total_tercero_quantity = 0
        terceroDisplay = ', ' + instruction.retail_cutting_pattern.grade + \
                            ' (' + str(quantity) + '), '
        terceroDisplay = display.tercero_size(tercero) + terceroDisplay
        if (len(terceroDisplay) > 2):
            terceroDisplay = terceroDisplay[:(len(terceroDisplay) - 2)]
        coating_description = Coating.objects.filter(
            id=coating_id)[0].description
        panel_depth = PanelDepth.objects.get(id=panel_depth_id)
        firstI = cutting_pattern.cutting_instructions.index('I')
        instructionIndent = ''
        for i in range(0, firstI + 8):
            instructionIndent = instructionIndent + ' '
        pattern_display_string = cutting_pattern.cutting_instructions.replace(
            '___', '<br/>' + instructionIndent)
        pattern_display_string = pattern_display_string.replace(' ', '&nbsp')
        pattern_display_string = pattern_display_string.replace('->', '-&gt')
        output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description,\
                display.small_measurement(panel_depth), terceroDisplay, outputString,\
                pattern_display_string, \
                instruction.id, quantity, cutting_pattern.id))
    return output_list
Exemple #9
0
def create_cutting_sheet_output(sheet_data, coating_id, panel_depth_id):
    output_list = []
    for instruction, instruction_data in sheet_data.iteritems():
        for coating_size_id, data in instruction_data.iteritems():
            outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                    data['pattern_id'])
            cutting_pattern = RetailCuttingPattern.objects.get(
                id=data['pattern_id'])

            outputString = ''
            for output in outputs:
                retail_size_display = display.retail_size(
                    RetailSize.objects.get(id=output.retail_size_id))
                outputString = outputString + retail_size_display + \
                        (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

            tercero = CoatingSize.objects.get(
                id=cutting_pattern.coating_size_id)
            terceroDisplay = ''
            total_tercero_quantity = 0
            for grade, quantity in data.iteritems():
                if grade is not 'pattern_id':
                    terceroDisplay = terceroDisplay +  grade + \
                            ' (' + str(quantity) + '), '
                    total_tercero_quantity = total_tercero_quantity + quantity
            terceroDisplay = display.tercero_size(tercero) + ' (' + str(
                total_tercero_quantity) + '), Grades: ' + terceroDisplay
            if (len(terceroDisplay) > 2):
                terceroDisplay = terceroDisplay[:(len(terceroDisplay) - 2)]
            coating_description = Coating.objects.filter(
                id=coating_id)[0].description
            panel_depth = PanelDepth.objects.get(id=panel_depth_id)
            instructionIndent = ''
            firstI = cutting_pattern.cutting_instructions.index('I')
            for i in range(0, firstI + 8):
                instructionIndent = instructionIndent + '&nbsp;'
            pattern_display_string = cutting_pattern.cutting_instructions.replace(
                '___', '<br/>' + instructionIndent)
            pattern_display_string = pattern_display_string.replace(
                ' ', '&nbsp')
            pattern_display_string = pattern_display_string.replace(
                '->', '-&gt')
            output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description, \
                    display.small_measurement(panel_depth), terceroDisplay, outputString, \
                    pattern_display_string, 0, 33, cutting_pattern.id))
    return output_list
Exemple #10
0
def get_recipes_for_packs(item, sku):
    '''
    Description
    -----------
    Gets and returns the recipe for a pack whose item is specified by sku
    '''

    description = item.description
    packs = Pack.objects.filter(item__id=item.id)
    recipes = []
    for pack in packs:
        retail_size = RetailSize.objects.get(
            itemrecipe__pack__item__id=item.id)
        retail_size = display.retail_size(retail_size)

        panel_depth = PanelDepth.objects.get(
            itemrecipe__pack__item__id=item.id)
        panel_depth = display.small_measurement(panel_depth)
        case_quantity = item.case_quantity
        pack_quantity = Pack.objects.get(item__id=item.id).pack_quantity
        try:
            cradle_depth = CradleDepth.objects.get(
                itemrecipe__pack__item__id=item.id)
            cradle_width = CradleWidth.objects.get(
                itemrecipe__pack__item__id=item.id)
            cradle_depth = display.small_measurement(cradle_depth)
            cradle_width = display.small_measurement(cradle_width)
        except:
            cradle_width = 'n/a'
            cradle_depth = 'n/a'

        coating = Coating.objects.get(
            itemrecipe__pack__item__id=item.id).description
        if coating == 'Pastelbord':
            spray_color = SprayColor.objects.get(
                itemrecipe__pack__item__id=item.id).color
        else:
            spray_color = 'n/a'

        recipe = RecipeDisplay(sku, description, retail_size, panel_depth,
                               cradle_depth, cradle_width, spray_color,
                               coating, case_quantity, pack_quantity)
        recipes.append(recipe)

    return recipes
Exemple #11
0
def create_recipe_strings(recipes):
    recipe_strings = []
    for recipe in recipes:
        retail_size = RetailSize.objects.get(pk=recipe.retail_size_id)
        coating = Coating.objects.get(pk=recipe.coating_id)
        panel_depth = PanelDepth.objects.get(pk=recipe.panel_depth_id)
        recipe_string = display.retail_size(retail_size) + "__" + coating.description + "__" + \
                display(panel_depth)
        if coating.description == 'Pastelbord':
            spray = SprayColor.objects.get(pk=recipe.spray_color_id)
            recipe_string += "__" + spray.color
        if recipe.cradle_depth:
            cradle_depth = CradleDepth.objects.get(pk=recipe.cradle_depth_id)
            cradle_width = CradleWidth.objects.get(pk=recipe.cradle_width_id)
            recipe_string += "__cradle_width__" + display(cradle_width) + \
                    "__cradle_depth__" + display(cradle_depth)
        recipe_strings.append({'id': recipe.id, 'recipe': recipe_string})
    return recipe_strings
Exemple #12
0
def review_instructions(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)

    instructions = RetailCuttingSheetInstruction.objects.filter(retail_cutting_sheet_entry_id__in = \
                        entries).order_by('retail_cutting_pattern__cutting_instructions')
    output_list = []
    for instruction in instructions:
        cutting_pattern = RetailCuttingPattern.objects.get(id = \
                                instruction.retail_cutting_pattern_id)
        coating_size_id = instruction.retail_cutting_pattern.coating_size.id
        instruction_string = instruction.retail_cutting_pattern.cutting_instructions
        quantity = instruction.quantity
        cutting_pattern_id = instruction.retail_cutting_pattern_id
        outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                            cutting_pattern_id)
        cutting_pattern = RetailCuttingPattern.objects.get(id = cutting_pattern_id)
        outputString = ''
        for output in outputs:
            retail_size_display = display.retail_size(RetailSize.objects.get(id = output.retail_size_id))
            outputString = outputString + retail_size_display + \
                (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

        tercero = CoatingSize.objects.get(id = coating_size_id)
        terceroDisplay = ''
        total_tercero_quantity = 0
        terceroDisplay = ', ' + instruction.retail_cutting_pattern.grade + \
                            ' (' + str(quantity) + '), '
        terceroDisplay = display.tercero_size(tercero) + terceroDisplay
        if (len(terceroDisplay) > 2):
            terceroDisplay = terceroDisplay[:(len(terceroDisplay)-2)]
        coating_description = Coating.objects.filter(id = coating_id)[0].description
        panel_depth = PanelDepth.objects.get(id = panel_depth_id)
        firstI = cutting_pattern.cutting_instructions.index('I')
        instructionIndent = ''
        for i in range(0,firstI + 8):
            instructionIndent = instructionIndent + '&nbsp;'
        pattern_display_string = cutting_pattern.cutting_instructions.replace('___', '<br/>' + instructionIndent)
        pattern_display_string = pattern_display_string.replace(' ', '&nbsp')
        pattern_display_string = pattern_display_string.replace('->', '-&gt')
        output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description,\
                display.small_measurement(panel_depth), terceroDisplay, outputString,\
                pattern_display_string, \
                instruction.id, quantity, cutting_pattern.id))
    return output_list
Exemple #13
0
def get_output_count(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)
    output_list = []
    output_dict = {}
    for entry in entries:
        coating = entry.retail_cutting_sheet.coating_id
        panel_depth = entry.retail_cutting_sheet.panel_depth_id
        if coating not in output_dict:
            output_dict[coating] = {}
        if panel_depth not in output_dict[coating]:
            output_dict[coating][panel_depth] = {}

        instructions = RetailCuttingSheetInstruction.objects.filter(
            retail_cutting_sheet_entry_id=entry.id)

        for instruction in instructions:
            quantity_to_cut = instruction.quantity
            outputs = RetailCuttingPatternOutput.objects.filter(
                retail_cutting_pattern_id=instruction.retail_cutting_pattern_id
            )
            for output in outputs:
                is_cradled = output.is_for_cradle
                retail_size = RetailSize.objects.get(id=output.retail_size_id)
                if is_cradled not in output_dict[coating][panel_depth]:
                    output_dict[coating][panel_depth][is_cradled] = {}
                output_dict[coating][panel_depth][is_cradled][output.retail_size_id] = \
                        quantity_to_cut*output.quantity if output.retail_size_id not in\
                        output_dict[coating][panel_depth][is_cradled] else \
                        output_dict[coating][panel_depth][is_cradled][output.retail_size_id] + quantity_to_cut*output.quantity
    for coating in output_dict.iterkeys():
        for panel_depth in output_dict[coating].iterkeys():
            for is_cradled in output_dict[coating][panel_depth].iterkeys():
                for retail_size, quantity in output_dict[coating][panel_depth][
                        is_cradled].iteritems():
                    retail_size_display = display.retail_size(
                        RetailSize.objects.get(id=retail_size))
                    output_list.append(CuttingSheetOutputQuantityDisplay(retail_size, \
                            retail_size_display, 'c' if is_cradled else 'f', coating_id, quantity))
    output_list = sort_outputs(output_list)
    return output_list
Exemple #14
0
def get_recipe_for_single(item, sku):
    '''
    Description
    -----------
    Gets and returns recipe for items that do not have packs
    '''

    description = item.description
    retail_size = RetailSize.objects.get(itemrecipe__item__id=item.id)
    retail_size = display.retail_size(retail_size)

    panel_depth = PanelDepth.objects.get(itemrecipe__item__id=item.id)
    panel_depth = display.small_measurement(panel_depth)
    case_quantity = item.case_quantity
    try:
        pack_quantity = Pack.objects.get(item__id=item.id).pack_quantity
    except:
        pack_quantity = 1

    try:
        cradle_depth = CradleDepth.objects.get(itemrecipe__item__id=item.id)
        cradle_depth = display.small_measurement(cradle_depth)
        cradle_width = CradleWidth.objects.get(itemrecipe__item__id=item.id)
        cradle_width = display.small_measurement(cradle_width)
    except:
        cradle_width = 'n/a'
        cradle_depth = 'n/a'

    coating = Coating.objects.get(itemrecipe__item__id=item.id).description
    if coating == 'Pastelbord':
        spray_color = SprayColor.objects.get(
            itemrecipe__item__id=item.id).color
    else:
        spray_color = 'n/a'

    recipe = RecipeDisplay(sku, description, retail_size, panel_depth,
                           cradle_depth, cradle_width, spray_color, coating,
                           case_quantity, pack_quantity)
    return recipe
Exemple #15
0
def create_cutting_sheet_output(sheet_data, coating_id, panel_depth_id):
    output_list = []
    for instruction, instruction_data in sheet_data.iteritems():
        for coating_size_id, data in instruction_data.iteritems():
            outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                    data['pattern_id'])
            cutting_pattern = RetailCuttingPattern.objects.get(id = data['pattern_id'])

            outputString = ''
            for output in outputs:
                retail_size_display = display.retail_size(RetailSize.objects.get(id = output.retail_size_id))
                outputString = outputString + retail_size_display + \
                        (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

            tercero = CoatingSize.objects.get(id = cutting_pattern.coating_size_id)
            terceroDisplay = ''
            total_tercero_quantity = 0
            for grade, quantity in data.iteritems():
                if grade is not 'pattern_id':
                    terceroDisplay = terceroDisplay +  grade + \
                            ' (' + str(quantity) + '), '
                    total_tercero_quantity = total_tercero_quantity + quantity
            terceroDisplay = display.tercero_size(tercero) + ' (' + str(total_tercero_quantity) + '), Grades: ' + terceroDisplay
            if (len(terceroDisplay) > 2):
                terceroDisplay = terceroDisplay[:(len(terceroDisplay)-2)]
            coating_description = Coating.objects.filter(id = coating_id)[0].description
            panel_depth = PanelDepth.objects.get(id = panel_depth_id)
            instructionIndent = ''
            firstI = cutting_pattern.cutting_instructions.index('I')
            for i in range(0, firstI + 8):
                instructionIndent = instructionIndent + '&nbsp;'
            pattern_display_string = cutting_pattern.cutting_instructions.replace('___', '<br/>' + instructionIndent)
            pattern_display_string = pattern_display_string.replace(' ', '&nbsp')
            pattern_display_string = pattern_display_string.replace('->', '-&gt')
            output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description, \
                    display.small_measurement(panel_depth), terceroDisplay, outputString, \
                    pattern_display_string, 0, 33, cutting_pattern.id))
    return output_list
Exemple #16
0
def cutting_patterns(isForCradle, retailSizeId, desiredQuantity):
    '''
    Description
    -----------
    Returns all cutting patterns that have the retail size specified by
    retailSizeId in them.  isForCradle and desiredQuantity just go along for 
    the ride so that they are persisted into WIP
    '''

    #get all desired cutting pattern outputs
    cutting_pattern_outputs = RetailCuttingPatternOutput.objects.\
            filter(retail_size_id = retailSizeId,\
            retail_cutting_pattern__is_for_cradle = conversions.bool_map[isForCradle])

    primary_cuts = []
    secondary_cuts = []
    for output in cutting_pattern_outputs:
        quantity = output.quantity
        #get the outputs for the current output's cutting pattern and create \
        #display for family
        output_family = RetailCuttingPatternOutput.objects.\
                        filter(retail_cutting_pattern_id = \
                        output.retail_cutting_pattern.id)
        output_displays = [OutputDisplay(display.retail_size(\
                           sibling.retail_size), sibling.retail_size.id, sibling.quantity, 'flat')\
                           for sibling in output_family]
        if output.is_primary:
            primary_cuts.append(CuttingPatternsDisplay\
                    (output_displays, output.retail_cutting_pattern.id,
                    output.retail_cutting_pattern.
                    cutting_instructions, math.ceil(int(desiredQuantity)/quantity)))
        else:
            secondary_cuts.append(CuttingPatternsDisplay(\
                    output_displays, output.retail_cutting_pattern.id,
                    output.retail_cutting_pattern.\
                    cutting_instructions, math.ceil(int(desiredQuantity)/quantity)))
    return primary_cuts + secondary_cuts
Exemple #17
0
def cutting_patterns(isForCradle, retailSizeId, desiredQuantity):
    '''
    Description
    -----------
    Returns all cutting patterns that have the retail size specified by
    retailSizeId in them.  isForCradle and desiredQuantity just go along for 
    the ride so that they are persisted into WIP
    '''

    #get all desired cutting pattern outputs
    cutting_pattern_outputs = RetailCuttingPatternOutput.objects.\
            filter(retail_size_id = retailSizeId,\
            retail_cutting_pattern__is_for_cradle = conversions.bool_map[isForCradle])

    primary_cuts = []
    secondary_cuts = []
    for output in cutting_pattern_outputs:
        quantity = output.quantity
        #get the outputs for the current output's cutting pattern and create \
        #display for family
        output_family = RetailCuttingPatternOutput.objects.\
                        filter(retail_cutting_pattern_id = \
                        output.retail_cutting_pattern.id)
        output_displays = [OutputDisplay(display.retail_size(\
                           sibling.retail_size), sibling.retail_size.id, sibling.quantity, 'flat')\
                           for sibling in output_family]
        if output.is_primary:
            primary_cuts.append(CuttingPatternsDisplay\
                    (output_displays, output.retail_cutting_pattern.id,
                    output.retail_cutting_pattern.
                    cutting_instructions, math.ceil(int(desiredQuantity)/quantity)))
        else:
            secondary_cuts.append(CuttingPatternsDisplay(\
                    output_displays, output.retail_cutting_pattern.id,
                    output.retail_cutting_pattern.\
                    cutting_instructions, math.ceil(int(desiredQuantity)/quantity)))
    return primary_cuts + secondary_cuts
Exemple #18
0
 def __unicode__(self):
     return display.retail_size(self)
Exemple #19
0
def coating_cut_sizes():
    coat_cut_sizes = CoatingSize.objects.order_by('width', 'length')
    size_list = [(int(size.id), display.retail_size(size))
                 for size in coat_cut_sizes]
    return size_list
Exemple #20
0
 def __unicode__(self):
     return display.retail_size(self)
def coating_cut_sizes():
    coat_cut_sizes = CoatingSize.objects.order_by('width', 'length')
    size_list = [(int(size.id), display.retail_size(size)) for size in coat_cut_sizes]
    return size_list