Ejemplo n.º 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'))
Ejemplo n.º 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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 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

            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
Ejemplo n.º 6
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'))
Ejemplo n.º 7
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
Ejemplo n.º 8
0
    def __init__(self, order, ident, rqty, shortage):
        self._order = order
        self._ident = ident
        self._rqty = rqty
        self._resqty = rqty - shortage
        self._shortage = shortage
        # TODO
        # Have a module level order instance here instead of leaving it to
        # sourcing.electronics, and get rid of this circular import problem.
        from tendril.sourcing import electronics

        try:
            self._sources = electronics.get_sourcing_information(  # noqa
                self.ident, self.gl_compl_qty, avendors=self._order._allowed_vendors, allvendors=True
            )
            self._selsource = self._sources[0]
            for vsinfo in self._sources:
                if self.get_eff_acq_price(vsinfo) < self.get_eff_acq_price(self._selsource):
                    self._selsource = vsinfo
        except electronics.SourcingException:  # noqa
            self._sources = None
            self._selsource = None
Ejemplo n.º 9
0
 def __init__(self, order, ident, rqty, shortage):
     self._order = order
     self._ident = ident
     self._rqty = rqty
     self._resqty = rqty - shortage
     self._shortage = shortage
     # TODO
     # Have a module level order instance here instead of leaving it to
     # sourcing.electronics, and get rid of this circular import problem.
     from tendril.sourcing import electronics
     try:
         self._sources = electronics.get_sourcing_information(  # noqa
             self.ident, self.gl_compl_qty,
             avendors=self._order._allowed_vendors,
             allvendors=True
         )
         self._selsource = self._sources[0]
         for vsinfo in self._sources:
             if self.get_eff_acq_price(vsinfo) < \
                     self.get_eff_acq_price(self._selsource):
                 self._selsource = vsinfo
     except electronics.SourcingException:  # noqa
         self._sources = None
         self._selsource = None