Exemplo n.º 1
0
    def define_auth_chain(self,
                          prod_order_sno=None,
                          root_order_sno=None,
                          prod_order_scaffold=False,
                          session=None):
        prod_order_sno = prod_order_sno or None
        if prod_order_sno is not None:
            if not serialnos.serialno_exists(sno=prod_order_sno,
                                             session=session):
                raise AuthChainNotValidError
            if not prod_order_scaffold:
                from tendril.production.order import ProductionOrder
                prod_order = ProductionOrder(prod_order_sno)
                if len(prod_order.indent_snos) and \
                        self.root_indent_sno not in prod_order.indent_snos:
                    raise AuthChainNotValidError
            self._prod_order_sno = prod_order_sno

        if root_order_sno is not None:
            if not serialnos.serialno_exists(sno=root_order_sno,
                                             session=session):
                raise AuthChainNotValidError
            self._root_order_sno = root_order_sno

        parents = self.auth_parent_snos
        if len(parents) == 0:
            raise AuthChainNotValidError
Exemplo n.º 2
0
 def _check_new(self, sno):
     exists = serialnos.serialno_exists(sno=sno)
     if self.new is True and exists:
         raise ValidationError(self._message +
                               " Already exists.")
     elif self.new is False and not exists:
         raise ValidationError(self._message +
                               " Does not exist.")
Exemplo n.º 3
0
 def validate_sno(form, field):
     sno = field.data.strip()
     if form.orig_cardname.data and not sno:
         raise ValidationError("Specify Serial No.")
     if form.target_cardname.data and not sno:
         raise ValidationError("Specify Serial No.")
     if not sno:
         return
     if not serialnos.serialno_exists(sno=sno):
         raise ValidationError("S.No. not recognized.")
Exemplo n.º 4
0
 def validate_sno(form, field):
     sno = field.data.strip()
     if form.orig_cardname.data and not sno:
         raise ValidationError("Specify Serial No.")
     if form.target_cardname.data and not sno:
         raise ValidationError("Specify Serial No.")
     if not sno:
         return
     if not serialnos.serialno_exists(sno=sno):
         raise ValidationError("S.No. not recognized.")
Exemplo n.º 5
0
    def define_auth_chain(self,  prod_order_sno=None, root_order_sno=None,
                          prod_order_scaffold=False, session=None):
        prod_order_sno = prod_order_sno or None
        if prod_order_sno is not None:
            if not serialnos.serialno_exists(sno=prod_order_sno,
                                             session=session):
                raise AuthChainNotValidError
            if not prod_order_scaffold:
                from tendril.production.order import ProductionOrder
                prod_order = ProductionOrder(prod_order_sno)
                if len(prod_order.indent_snos) and \
                        self.root_indent_sno not in prod_order.indent_snos:
                    raise AuthChainNotValidError
            self._prod_order_sno = prod_order_sno

        if root_order_sno is not None:
            if not serialnos.serialno_exists(sno=root_order_sno,
                                             session=session):
                raise AuthChainNotValidError
            self._root_order_sno = root_order_sno

        parents = self.auth_parent_snos
        if len(parents) == 0:
            raise AuthChainNotValidError
Exemplo n.º 6
0
 def _check_new(self, sno):
     exists = serialnos.serialno_exists(sno=sno)
     if self.new is True and exists:
         raise ValidationError(self._message + " Already exists.")
     elif self.new is False and not exists:
         raise ValidationError(self._message + " Does not exist.")