Esempio n. 1
0
def get_gsx_connection(request):
    act = GsxAccount.get_default_account()
    user = User.objects.get(pk=request.session['checkin_user'])
    location = Location.objects.get(pk=request.session['checkin_location'])
    return act.connect(user, location)
Esempio n. 2
0
def get_gsx_connection(request):
    act = GsxAccount.get_default_account()
    user = User.objects.get(pk=request.session['checkin_user'])
    location = Location.objects.get(pk=request.session['checkin_location'])
    return act.connect(user, location)
Esempio n. 3
0
    def from_gsx(cls, sn, device=None, cached=True, user=None):
        """
        Initialize new Device with warranty info from GSX
        Or update existing one
        """
        sn = sn.upper()
        cache_key = 'device-%s' % sn

        # Only cache unsaved devices
        if cached and device is None:
            if cache.get(cache_key):
                return cache.get(cache_key)

        arg = gsxws.validate(sn)

        if arg not in ("serialNumber", "alternateDeviceId",):
            raise ValueError(_(u"Invalid input for warranty check: %s") % sn)

        product = gsxws.Product(sn)

        if user and user.location:
            ship_to = user.location.gsx_shipto
        else:
            gsx_act = GsxAccount.get_default_account()
            ship_to = gsx_act.ship_to

        wty = product.warranty(ship_to=ship_to)
        model = product.model()

        if device is None:
            # serialNumber may sometimes come back empty
            serial_number = wty.serialNumber or sn
            device = Device(sn=serial_number)

        from servo.lib.utils import empty

        if empty(device.notes):
            device.notes = wty.notes or ''
            device.notes += wty.csNotes or ''

        device.has_onsite = product.has_onsite
        device.is_vintage = product.is_vintage
        device.description = product.description
        device.fmip_active = product.fmip_is_active

        device.slug = slugify(device.description)
        device.configuration = wty.configDescription or ''
        device.purchase_country = countries.by_name(wty.purchaseCountry)

        device.config_code = model.configCode
        device.product_line = model.productLine.replace(" ", "")
        device.parts_and_labor_covered = product.parts_and_labor_covered

        device.sla_description = wty.slaGroupDescription or ''
        device.contract_start_date = wty.contractCoverageStartDate
        device.contract_end_date = wty.contractCoverageEndDate
        device.onsite_start_date = wty.onsiteStartDate
        device.onsite_end_date = wty.onsiteEndDate

        if wty.estimatedPurchaseDate:
            device.purchased_on = wty.estimatedPurchaseDate

        device.image_url = wty.imageURL or ''
        device.manual_url = wty.manualURL or ''
        device.exploded_view_url = wty.explodedViewURL or ''

        if wty.warrantyStatus:
            device.set_wty_status(wty.warrantyStatus)

        if product.is_ios:
            ad = device.get_activation()
            device.imei = ad.imeiNumber or ''
            device.unlocked = product.is_unlocked(ad)
            device.applied_activation_policy = ad.appliedActivationDetails or ''
            device.initial_activation_policy = ad.initialActivationPolicyDetails or ''
            device.next_tether_policy = ad.nextTetherPolicyDetails or ''

        cache.set(cache_key, device)

        return device