def processCurrencies(request): r = { 'success': True, 'total_currencies': 0, 'created_currencies': 0, 'updated_currencies': 0 } cm = CurrencyManager() data = cm.getCurrencies() for c in data: try: localCurrency = Currency.objects.get(code=c['code']) r['updated_currencies'] += 1 except: localCurrency = Currency() r['created_currencies'] += 1 localCurrency.dateUpdated = django.utils.timezone.now() localCurrency.code = c['code'] localCurrency.usd = c['usd'] localCurrency.eur = c['eur'] localCurrency.save() #try: # lwfCurrency = Currency.objects.get( # code='LWF' # ) # r['updated_currencies'] += 1 #except: # lwfCurrency = Currency() # r['created_currencies'] += 1 #btcCurrency = Currency().getCurrency("BTC") #lwdUsd = (btcCurrency.usd * 0.000009148) #lwfEur = (btcCurrency.eur * 0.000009148) #lwfCurrency.dateUpdated = django.utils.timezone.now() #lwfCurrency.code = 'LWF' #lwfCurrency.usd = lwdUsd #lwfCurrency.eur = lwfEur #lwfCurrency.save() try: paypalBcCurrency = Currency.objects.get(code='PPBC') r['updated_currencies'] += 1 except: paypalBcCurrency = Currency() r['created_currencies'] += 1 paypalBcCurrency.dateUpdated = django.utils.timezone.now() paypalBcCurrency.code = 'PPBC' paypalBcCurrency.usd = 1 btcCurrency = Currency().getCurrency("BTC") paypalBcCurrency.eur = 1 * btcCurrency.eur / btcCurrency.usd paypalBcCurrency.save() r['total_currencies'] = len(Currency.objects.all()) return Response(r)
confirmed=False) except Exception, ex: return Response({ 'success': False, 'error': 'withdrawRequest.notfound' }) try: profile = Profile.objects.get(user=withdrawRequest.user) wallet = Wallet.objects.get(profile=profile) freezedCurrency = Currency().getCurrency( withdrawRequest.requestedCurrency) # NOW SET REAL USD/EUR VALUES WHEN WITHDRAW WAS REQUESTED!!! freezedCurrency.usd = withdrawRequest.freezedUsd freezedCurrency.eur = withdrawRequest.freezedEur if withdrawRequest.requestedAmount > wallet.credit: return Response({'success': False, 'error': 'credit.insufficient'}) # CREATE TRANSACTION withdrawTransaction = TransactionManager.createWithdrawTransaction( withdrawRequest.requestedAmount, wallet.id, freezedCurrency, withdrawRequest.requestedCcAddress) withdrawRequest.transaction = withdrawTransaction withdrawRequest.confirmed = True withdrawRequest.save() adminNotification = Notification() adminNotification.email = True