Exemple #1
0
    def save(self):
        cleaned_data = self.cleaned_data
        tracking_number = cleaned_data.get('tracking_number', '')        

        shipment_provider = get_shipment_provider(tracking_number)
        shipment_handler = get_shipment_handler(shipment_provider)

        shipment = shipment_handler.create_shipment(tracking_number, self.user)

        return shipment
Exemple #2
0
    def clean_tracking_number(self):
        cleaned_data = self.cleaned_data
        tracking_number = cleaned_data.get('tracking_number', '')

        shipment_provider = get_shipment_provider(tracking_number)

        if shipment_provider == None:
            raise ValidationError("Not a valid %s tracking number." % "/".join(dict(SHIPMENT_SERVICE_PROVIDER_CHOICES).values()))

        try:
            shipment_handler = get_shipment_handler(shipment_provider)
        except Exception, e:
            raise ValidationError(str(e))