예제 #1
0
def createNewAddress(request, provider_id, account_identifier):
    '''
    Create a new address for the account of account_identifier
    '''

    # set the request in the connector object
    connector.request = request

    provider_id = int(provider_id)
    wallet = getWalletByProviderId(connector, provider_id)
    if request.method == 'POST':
        account = wallet.getAccountByIdentifier(account_identifier)
        if account:
            new_address = connector.getNewAddress(account['provider_id'],
                                                  account['name'])
            messages.success(request,
                             'New address "%s" created for account "%s"' %
                             (new_address, account['name']),
                             extra_tags="success")
            events.addEvent(
                request, 'New address "%s" created for account "%s"' %
                (new_address, account['name']), 'info')
        return HttpResponseRedirect(
            reverse('accounts:details_with_addresses',
                    kwargs={
                        'provider_id': provider_id,
                        'account_identifier': account_identifier,
                        'page': 1
                    }))
예제 #2
0
def create(request):
    '''
    Handler for POST of create account form
    '''
    
    # set the request in the connector object
    connector.request = request
    
    if request.method == 'POST': 
        
        # we have a POST request
        form = forms.CreateAccountForm(request.POST)

        if form.is_valid(): 
            new_account_name = form.cleaned_data['account_name']
            provider_id = form.cleaned_data['provider_id']
            
            # all ok, create account
            new_address = connector.getNewAddress(provider_id, new_account_name)
            
            if new_address:
                messages.success(request, 'New account created with one address (%s)' % new_address, extra_tags="success")
                events.addEvent(request, 'Created new account with address "%s"' % (new_address), 'info')
                
            return HttpResponseRedirect(reverse('accounts:index'))

    else:
        form = forms.CreateAccountForm()
    
    context = getAddAccountFormContext(account_name="", form=form)
    return render(request, 'accounts/add.html', context)
예제 #3
0
def createNewAddress(request, provider_id, account_identifier):
    '''
    Create a new address for the account of account_identifier
    '''
    
    # set the request in the connector object
    connector.request = request
    
    provider_id = int(provider_id)
    wallet = getWalletByProviderId(connector, provider_id)
    if request.method == 'POST': 
        account = wallet.getAccountByIdentifier(account_identifier)
        if account:
            new_address = connector.getNewAddress(account['provider_id'], account['name'])
            messages.success(request, 'New address "%s" created for account "%s"' % (new_address, account['name']), extra_tags="success")
            events.addEvent(request, 'New address "%s" created for account "%s"' % (new_address, account['name']), 'info')
        return HttpResponseRedirect(reverse('accounts:details_with_addresses', kwargs={'provider_id': provider_id, 'account_identifier': account_identifier, 'page': 1}))
예제 #4
0
def create(request):
    '''
    Handler for POST of create account form
    '''

    # set the request in the connector object
    connector.request = request

    if request.method == 'POST':

        # we have a POST request
        form = forms.CreateAccountForm(request.POST)

        if form.is_valid():
            new_account_name = form.cleaned_data['account_name']
            provider_id = form.cleaned_data['provider_id']

            # all ok, create account
            new_address = connector.getNewAddress(provider_id,
                                                  new_account_name)

            if new_address:
                messages.success(request,
                                 'New account created with one address (%s)' %
                                 new_address,
                                 extra_tags="success")
                events.addEvent(
                    request,
                    'Created new account with address "%s"' % (new_address),
                    'info')

            return HttpResponseRedirect(reverse('accounts:index'))

    else:
        form = forms.CreateAccountForm()

    context = getAddAccountFormContext(account_name="", form=form)
    return render(request, 'accounts/add.html', context)