Пример #1
0
def render_search_results():
    form = SourcingIdentSearch()
    if form.validate_on_submit():
        ident = form.ident.data
        qty = form.qty.data

        if not qty:
            qty = electronics_qty.get_compliant_qty(ident, 1)
            form.qty.data = qty
        try:
            qty = int(qty)
        except ValueError:
            qty = Length(qty)

        vl = []
        for vname in form.vendors.data:
            v = get_vendor_by_name(vname)
            if not v:
                raise ValueError
            vl.append(v)

        try:
            vsi = get_sourcing_information(ident,
                                           qty,
                                           avendors=vl,
                                           allvendors=True,
                                           get_all=form.get_all.data)
        except SourcingException:
            vsi = []

        symbol = get_symbol(ident)

        stage = {
            'crumbroot':
            '/sourcing',
            'breadcrumbs': [
                Crumb(name="Sourcing", path=""),
                Crumb(name="Vendors", path="vendors/"),
                Crumb(name="Search Results", path="vendors/results")
            ],
            'isinfos':
            vsi,
            'ident':
            ident,
            'symbol':
            symbol,
        }

        return render_template('vendors_search_results.html',
                               stage=stage,
                               form=form,
                               pagetitle='Sourcing Search Results')
    else:
        return redirect(url_for('.main'))
Пример #2
0
 def indicative_sourcing_info(self):
     if self._indicative_sourcing_info is None:
         from tendril.inventory.guidelines import electronics_qty
         from tendril.sourcing.electronics import get_sourcing_information
         from tendril.sourcing.electronics import SourcingException
         iqty = electronics_qty.get_compliant_qty(self.ident, 1)
         try:
             ident = 'PCB ' + self.ident
             vsi = get_sourcing_information(ident, iqty, allvendors=True)
         except SourcingException:
             vsi = []
         self._indicative_sourcing_info = vsi
     return self._indicative_sourcing_info
Пример #3
0
 def indicative_cost(self):
     if self.isinfo is not None:
         qty = electronics_qty.get_compliant_qty(self.ident, self.quantity)
         ubprice, nbprice = self.isinfo.vpart.get_price(qty)
         if ubprice is not None:
             price = ubprice
         elif nbprice is not None:
             price = nbprice
         else:
             price = self.isinfo.ubprice
         effprice = self.isinfo.vpart.get_effective_price(price)
         return effprice.extended_price(self.uquantity, allow_partial=True)
     else:
         return None
Пример #4
0
 def sourcing_info_qty(self, qty):
     from tendril.inventory.guidelines import electronics_qty
     from tendril.sourcing.electronics import get_sourcing_information
     from tendril.sourcing.electronics import SourcingException
     if fpiswire(self.device):
         iqty = Length(qty)
     else:
         iqty = qty
     iqty = electronics_qty.get_compliant_qty(self.ident, iqty)
     try:
         vsi = get_sourcing_information(self.ident, iqty, allvendors=True)
     except SourcingException:
         vsi = []
     return vsi
Пример #5
0
 def indicative_sourcing_info(self):
     if self._indicative_sourcing_info is None:
         from tendril.inventory.guidelines import electronics_qty
         from tendril.sourcing.electronics import get_sourcing_information
         from tendril.sourcing.electronics import SourcingException
         iqty = electronics_qty.get_compliant_qty(self.ident, 1)
         try:
             ident = 'PCB ' + self.ident
             vsi = get_sourcing_information(ident, iqty,
                                            allvendors=True)
         except SourcingException:
             vsi = []
         self._indicative_sourcing_info = vsi
     return self._indicative_sourcing_info
Пример #6
0
    def indicative_sourcing_info(self):
        if self._indicative_sourcing_info is None:
            from tendril.inventory.guidelines import electronics_qty
            from tendril.sourcing.electronics import get_sourcing_information
            from tendril.sourcing.electronics import SourcingException

            if fpiswire(self.device):
                iqty = Length("1m")
            else:
                iqty = 1
            iqty = electronics_qty.get_compliant_qty(self.ident, iqty)
            try:
                vsi = get_sourcing_information(self.ident, iqty, allvendors=True)
            except SourcingException:
                vsi = []
            self._indicative_sourcing_info = vsi
        return self._indicative_sourcing_info
Пример #7
0
def render_search_results():
    form = SourcingIdentSearch()
    if form.validate_on_submit():
        ident = form.ident.data
        qty = form.qty.data

        if not qty:
            qty = electronics_qty.get_compliant_qty(ident, 1)
            form.qty.data = qty
        try:
            qty = int(qty)
        except ValueError:
            qty = Length(qty)

        vl = []
        for vname in form.vendors.data:
            v = get_vendor_by_name(vname)
            if not v:
                raise ValueError
            vl.append(v)

        try:
            vsi = get_sourcing_information(
                ident, qty, avendors=vl, allvendors=True,
                get_all=form.get_all.data
            )
        except SourcingException:
            vsi = []

        symbol = get_symbol(ident)

        stage = {'crumbroot': '/sourcing',
                 'breadcrumbs': [
                     Crumb(name="Sourcing", path=""),
                     Crumb(name="Vendors", path="vendors/"),
                     Crumb(name="Search Results", path="vendors/results")],
                 'isinfos': vsi,
                 'ident': ident,
                 'symbol': symbol,
                 }

        return render_template('vendors_search_results.html', stage=stage,
                               form=form, pagetitle='Sourcing Search Results')
    else:
        return redirect(url_for('.main'))
Пример #8
0
 def sourcing_info_qty(self, qty):
     # TODO Complete Migration
     try:
         from tendril.inventory.guidelines import electronics_qty
         from tendril.sourcing.electronics import get_sourcing_information
         from tendril.sourcing.electronics import SourcingException
     except ImportError:
         return []
     if fpiswire(self.device) and not isinstance(qty, Length):
         iqty = Length(qty)
     else:
         iqty = qty
     iqty = electronics_qty.get_compliant_qty(self.ident, iqty)
     try:
         vsi = get_sourcing_information(self.ident, iqty, allvendors=True)
     except SourcingException:
         vsi = []
     return vsi