Example #1
0
def advanced_search():
    params = request.args.to_dict()
    users = User.query.all()
    projects = Project.query.all()
    materials = Material.query.all()
    material_specs = MaterialSpecification.query.all()
    hardware_types = HardwareType.query.all()
    criticalities = Criticality.query.all()
    vendors = Company.get_all_with_pri_on_top()

    variables = {
        'users': users,
        'projects': projects,
        'vendors': vendors,
        'materials': materials,
        'material_specs': material_specs,
        'hardware_types': hardware_types,
        'criticalities': criticalities,
        'column_names': ADVANCED_SEARCH_COLUMNS,
        'record_type':
        params['record_type'] if 'record_type' in params else 'design',
        'Design':
        Design,  # TODO: Consider making these globally accessible if needed
        'VendorPart': VendorPart,
        'Product': Product,
        'VendorProduct': VendorProduct,
        'Procedure': Procedure,
        'Anomaly': Anomaly,
        'ECO': ECO,
        'Specification': Specification
    }
    return render_template('backend/advanced_search.html', **variables)
Example #2
0
def view_product(design_number, part_identifier, serial_number):
    product = Product.get_product_by_product_number(design_number, part_identifier, serial_number)
    serial_numbers = Product.get_serial_numbers_for_design_number_and_part_identifier(product.part.design.design_number, product.part.part_identifier)
    projects = Project.query.all()
    companies = Company.get_all_with_pri_on_top()
    hardware_types = HardwareType.query.all()
    users = User.query.all()
    dispositions = Disposition.query.all()
    components_array = arrange_product_components(product)  # Group installed components so can show them grouped on page
    extra_components_array = arrange_extra_product_components(product)
    installed_ins = defaultdict(list)
    for pc in product.get_installed_ins():
        installed_ins[pc.parent.product_number].append(pc)
    variables = {
        'product': product,
        'projects': projects,
        'hardware_types': hardware_types,
        'users': users,
        'serial_numbers': serial_numbers,
        'components_array': components_array,
        'extra_components_array': extra_components_array,
        'dispositions': dispositions,
        'companies': companies,
        'installed_ins': installed_ins
    }
    return render_template('product/view_product.html', **variables)
Example #3
0
def view_vendor_part(part_number):
    """View existing vendor part."""
    vendor_part = VendorPart.get_by_part_number(part_number)
    projects = Project.query.all()
    materials = Material.query.all()
    users = User.query.all()
    vendors = Company.get_all_with_pri_on_top()
    variables = {
        'vendor_part': vendor_part,
        'projects': projects,
        'materials': materials,
        'vendors': vendors,
        'users': users
    }
    return render_template('vendorpart/view_vendor_part.html', **variables)
Example #4
0
def view_vendor_product(part_number, serial_number):
    vendor_product = VendorProduct.get_vendor_product_by_product_number(part_number, serial_number)
    index = 1
    back_index = -1
    product_number = part_number + '-' + serial_number
    product_number_parts = product_number.split('-')
    max_index = len(product_number.split('-'))
    while not vendor_product:
        # Probably due to a dash in serial_number causing the above match to fail. Do some magic and try again
        part_number = '-'.join(product_number_parts[0:max_index - index])
        serial_number = '-'.join(product_number_parts[back_index:])
        vendor_product = VendorProduct.get_vendor_product_by_product_number(part_number, serial_number)
        index += 1
        back_index -= 1
        if index == max_index:
            break  # TODO: Make this error gracefully rather than nastily
    serial_numbers = VendorProduct.get_serial_numbers_for_vendor_part(vendor_product.vendor_part)
    projects = Project.query.all()
    companies = Company.get_all_with_pri_on_top()
    hardware_types = HardwareType.query.all()
    users = User.query.all()
    dispositions = Disposition.query.all()
    installed_ins = defaultdict(list)
    for pc in vendor_product.get_installed_ins():
        installed_ins[pc.parent.product_number].append(pc)
    variables = {
        'vendor_product': vendor_product,
        'serial_numbers': serial_numbers,
        'projects': projects,
        'hardware_types': hardware_types,
        'users': users,
        'companies': companies,
        'dispositions': dispositions,
        'installed_ins': installed_ins
    }
    return render_template('vendorproduct/view_vendor_product.html', **variables)
Example #5
0
def get_vendors():
    return Company.get_all_with_pri_on_top()