Пример #1
0
def purchase_palette(user, palette):
    if isinstance(palette, basestring):
        palette = get_palette_by_name(palette_name)

    if palette in user.redis.palettes:
        raise InvalidPurchase("You've already bought this palette.")

    debit(user, palette.cost)
    user.redis.palettes.unlock(palette)
Пример #2
0
def purchase_palette(user, palette):
    if isinstance(palette, basestring):
        palette = get_palette_by_name(palette_name)

    if palette in user.redis.palettes:
        raise InvalidPurchase("You've already bought this palette.")

    debit(user, palette.cost)
    user.redis.palettes.unlock(palette)
Пример #3
0
def purchase_palette(request, username, palette_name):
    try:
        palette = models.get_palette_by_name(palette_name)
    except KeyError:
        raise ValidationError("Invalid palette name.")

    try:
        economy.purchase_palette(request.user, palette)
    except economy.InvalidPurchase as e:
        raise ServiceError(e.message)

    return {'palettes': request.user.redis.palettes}
Пример #4
0
def purchase_palette(request, username, palette_name):
    try:
        palette = models.get_palette_by_name(palette_name)
    except KeyError:
        raise ValidationError("Invalid palette name.")

    try:
        economy.purchase_palette(request.user, palette)
    except economy.InvalidPurchase as e:
        raise ServiceError(e.message)

    return {'palettes': request.user.redis.palettes}