Example #1
0
def singleToggleEnable(request):
    try:
        enabled = request.data.get('enabled')
        serviceId = request.data.get('serviceId')
        user = request.user
        profile = Profile.objects.get(
            user=user,
            docVerified=True,
            ProofOfresidenceVerified=True,
            SelfIDocVerified=True
        )
        service = Service.objects.get(
            profile=profile,
            id=int(serviceId)
        )
        service.enabled = enabled
        service.save()
        return Response({'success': True})
    except Profile.DoesNotExist:
        return Response({'success': False, 'error': 'profile.notfound'})
    except Exception as e:
        p_ex(
            request,
            e,
            5,
            1,
            'Failed to toggle service id: %s' % (serviceId)
        )
        return Response({'success': False, 'errors': e.message})
Example #2
0
def closeIssue(request):
    """
    Close issue from owner
    """
    issueId = request.data.get("issueId")
    try:
        user = request.user
        profile = Profile.objects.get(user=user)
        try:
            issue = Issue.objects.get(
                id=issueId
            )
            if issue.profile != profile:
                return Response({'success': False, 'code': 'issue.notowner'})
            issue.state = issueStatus['CLOSED']
            issue.save()
            return Response({'success': True})
        except Issue.DoesNotExist:
            return Response({'success': False, 'code': 'issue.notfound'})
    except Exception as e:
        p_ex(
            request,
            e,
            3,
            1,
            'Failed to close issue id: %s' % (issueId)
        )
        return Response({'success': False, 'code': 'issue.genericerror'})
Example #3
0
def sendVerificationCodeSMS(request, verificationCode, mobileNumber):
    client = Client(settings.SMS_API_SID, settings.SMS_API_TOKEN)
    try:
        message = client.messages.create(
            to=mobileNumber,
            messaging_service_sid=settings.SMS_SERVICE_SID,
            body='Verification code: %s' % verificationCode)
        message.sid
        return True
    except Exception, ex:
        p_ex(request, ex, 3, 1, 'Failed to send sms to: %s' % (mobileNumber))
        return False
Example #4
0
def processTransactions(request):
    # FREEZE CURRENCIES VALUES
    Cm = Currency()
    btcFreezedCurrency = Cm.getCurrency("BTC")
    lwfFreezedCurrency = Cm.getCurrency("LWF")

    #lwfProcess = processLwfTransactions(lwfFreezedCurrency)

    r = {
        'success': False,
        "error": "",
        'currency_freezedate': Cm.dateUpdated,
        'BTC': {
            'currency_usd': btcFreezedCurrency.usd,
            'currency_eur': btcFreezedCurrency.eur,
            'addresses_btc_processed': 0,
            'addresses_btc_errors': [],
            'transactions_btc_created': 0,
            'transactions_btc_errors': [],
        },
        'LWF': {
            'currency_usd': lwfFreezedCurrency.usd,
            'currency_eur': lwfFreezedCurrency.eur,
            'addresses_lwf_processed': 0,
            'addresses_lwf_errors': [],
            'transactions_lwf_created': 0,
            'transactions_lwf_errors': [],
        }
    }

    # CHECK THAT ANOTHER PROCESS IS RUNNING
    previoustp = TransactionsProcess.objects.filter(dateEnd=None)
    if len(previoustp) == 0:

        logtp = TransactionsProcess()
        logtp.dateStart = django.utils.timezone.now()
        logtp.dateEnd = None
        logtp.save()
        try:

            btcProcess = processBtcTransactions(btcFreezedCurrency)

            r['BTC']['addresses_btc_processed'] = btcProcess[
                'processed_addresses']
            r['BTC']['addresses_btc_errors'] = btcProcess['errors_addresses']
            r['BTC']['transactions_btc_created'] = len(
                btcProcess['created_transactions'])
            r['BTC']['transactions_btc_errors'] = btcProcess[
                'errors_transactions']

            lwfProcess = processLwfTransactions(lwfFreezedCurrency)

            r['LWF']['addresses_lwf_processed'] = lwfProcess[
                'processed_addresses']
            r['LWF']['addresses_lwf_errors'] = lwfProcess['errors_addresses']
            r['LWF']['transactions_lwf_created'] = len(
                lwfProcess['created_transactions'])
            r['LWF']['transactions_lwf_errors'] = lwfProcess[
                'errors_transactions']

            r['success'] = True

        except Exception, ex:
            p_ex(
                request, ex, 2, 1, 'Error during transaction process: %s' %
                (traceback.format_exc()))
            r['error'] = "%s" % (traceback.format_exc())

        logtp.dateEnd = django.utils.timezone.now()
        logtp.processData = str(r)
        logtp.save()
Example #5
0
        now = django.utils.timezone.now()
        timeoutDateTime = ptp.dateStart + datetime.timedelta(
            seconds=settings.TRANSACTION_PROCESS_RESTART_TIMEOUT)

        if now > timeoutDateTime:
            # timed out, set as invalid...
            ptp.dateEnd = django.utils.timezone.now()
            ptp.processData = "{'error':'Transaction process timed out, unknown reason!'}"
            ptp.save()

            try:
                a = None
                a.fakeMethod
            except Exception, ex:
                p_ex(
                    request, ex, 2, 1,
                    'A previous process timed out for unknown reason! Transaction process unlocked!'
                )
            r['error'] = 'A previous process timed out for unknown reason! Transaction process unlocked!'
        else:
            r['error'] = 'A previous process is running!'

    return Response(r)


@api_view(['GET'])
def processNotifications(request):
    r = {
        'success': True,
        "email_notifications_processed": 0,
        "email_notifications_errors": [],
        "sms_notifications_processed": 0,
Example #6
0
        withdrawRequest.transaction = withdrawTransaction
        withdrawRequest.confirmed = True
        withdrawRequest.save()

        adminNotification = Notification()
        adminNotification.email = True
        adminNotification.user = User.objects.get(username="******")
        adminNotification.setEmailData(
            "New withdraw request confirmed",
            "notifications/email/admin_email_withdraw_request_confirmed.html",
            {
                'user': withdrawRequest.user,
                'hash': hash,
                'withdrawRequest': withdrawRequest
            })
        try:
            Thread(target=adminNotification.process, args=(),
                   kwargs={}).start()
        except Exception, ex:
            pass

        return Response({'success': True})
    except Exception, ex:
        p_ex(request, ex, 3, 1,
             'Failed to confirm withdraw request hash: %s' % (hash))
        return Response({
            'success': False,
            'error': 'withdrawRequest.genericerror'
        })
Example #7
0
    })


def sendVerificationCodeSMS(request, verificationCode, mobileNumber):
    client = Client(settings.SMS_API_SID, settings.SMS_API_TOKEN)
    try:
        message = client.messages.create(
            to=mobileNumber,
            messaging_service_sid=settings.SMS_SERVICE_SID,
            body='Verification code: %s' % verificationCode)
        message.sid
        return True
    except Exception, ex:
        p_ex(request, ex, 3, 1, 'Failed to send sms to: %s' % (mobileNumber))
        return False
    p_ex(request, ex, 3, 1, 'Failed to send sms to: %s' % (mobileNumber))
    return False


def sendRegistrationEmail(profile):
    protocol = 'http'
    if settings.FRONTEND_SSL:
        protocol = 'https'
    confirmationLink = "%s://%s:%s/signup/%s" % (
        protocol, settings.FRONTEND_HOST, settings.FRONTEND_PORT,
        str(profile.activationKey))

    # User Notification
    userNotification = Notification()
    userNotification.email = True
    userNotification.user = profile.user