Example #1
0
def get_account(accountType = 'normal'):
    ''''
    This method will retrieve and return Account object.
    In the event that no Account object is associated with the email,
    a new Account object will be created with the default values
    '''
    user = users.get_current_user()
    account = None
    if user:
        uemail = user.email()
        #uemail = uemail[0:uemail.find("@")]
        query = Account.gql("WHERE email = :1",uemail)
        if query.count() == 0:
            if accountType=='normal':
                account = Account(email=uemail,name=user.nickname(),payment=0.0,acc_type='normal',shareCount=0)
            else:
                account = Account(email=uemail,name=user.nickname(),payment=0.0,acc_type='share',shareCount=0)
            account.put()
        else:
            account = query.get()
        
        return account
Example #2
0
def buy_credits(request):
    
    args = request.GET
    if args.__contains__('details'):
        d = args.__getitem__('details')
        dd = d.split(",") 
        _playerId = int(dd[0])
        _money = float(dd[1])
        _cashAmt = float(dd[2])
        player = Player.get_by_id(_playerId)
        player.money += _money
        player.networth = player.money + player.money_spent
        player.put()
        email = player.email
        accQuery = Account.gql("WHERE email = :1",email)
        acc = accQuery.get()
        acc.payment += _cashAmt
        acc.put()
        ppTrxn = PayPalTransaction(email = player.email,cashAmt = _cashAmt, money = _money, status="OK",playerId = _playerId)
        ppTrxn.put()
        return redirect("/app/main.html#/theworld")
    else:
        return HttpResponse("Not enough arguments")