Esempio n. 1
0
def addprops(request):
    data = request.data
    response =  OrderedDict()
    try:
        serializer = UserPropsSerializer(data=data)
        if serializer.is_valid():
            serializer.save()
            response['result'] = 'success'
        else:
            response['result'] = 'failed'
    except Exception,e:
        response['result'] = str(e)
Esempio n. 2
0
def addmobilestar(request):
    data = request.data
    uid = int(data['uid'])
    count = int(data['count'])
    sid = int(data['sid'])
    ssid = int(data['ssid'])
    user_props = {}
    user_props["uid"] = uid
    user_props["propid"] = 140066
    user_props["amount"] = count
    user_props["type"] = 2
    log.info("[addmobilestar] data=%s",str(data))
    response =  OrderedDict()
    addSeqId = str(uid) + "_" + str(time.time()) 
    ret = 0
    try:
        key = request.META['HTTP_KEY']
        checktoken(uid,key.strip())
        #if int(uid)<>int(request.data['uid']):
        #    raise Exception,"Permission Denied"
        prop_amount = UserProps.objects.filter(uid=uid,type=2,last_modify__gt=datetime.datetime.now().date()).aggregate(Sum("amount"))
        if prop_amount['amount__sum']>=30:
            raise Exception,"out of limit"
        #ret = add_mobilestar_props(uid,sid,ssid,count,addSeqId)
        propId = 140066
        appid = TAppId.VipPk
        expand = ''
        addType = 2
        activityId = 177
        useAfterAdd = False
        ret=vipdef.thriftFactory.execute(TTurnoverService, 'addGiftBagActivity',uid, propId, count, addSeqId, appid, addType, expand, sid, ssid, useAfterAdd, activityId)
        if ret==1:
            serializer = UserPropsSerializer(data=user_props)
            if serializer.is_valid():
                serializer.save()
            response['result'] = 'success'
        else:
            response['result'] = 'failed'
    except AppVersion.DoesNotExist,e:
         response['result'] = 'invalid verison'