def setUp(self): formpost = {} formpost['username'] = '******' formpost['password'] = '******' formpost['reconfirm_pass'] = '******' formpost['email'] = '*****@*****.**' self.form = forms.CreateAccountForm(formpost, 'asdf')
def add(request): ''' Handler for the account create form ''' form = forms.CreateAccountForm() context = getAddAccountFormContext(form=form) context['breadcrumbs'] = misc.buildBreadcrumbs(current_section, '', 'Create') return render(request, 'accounts/add.html', context)
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)
def create_user_page(): """Create new users.""" if login.current_user.is_authenticated(): return flask.redirect(flask.url_for('.user_profile')) ok_to_create = False form = forms.CreateAccountForm() if form.validate_on_submit(): ok_to_create = True # Make sure the username is available if form.username.data: new_user = users.User.GetByUsername(form.username.data) if new_user: flask.flash( 'Username %s is not available.' % (form.username.data, ), 'error') new_user = None ok_to_create = False # Make sure the email is not in use if form.email.data: new_user = users.User.GetByEmail(form.email.data) if new_user: flask.flash( 'E-mail address %s is already in use.' % (form.email.data, ), 'error') new_user = None ok_to_create = False # Make sure the path is not in use if form.blog_path.data: new_blog = blogs.Blog.GetByPath(form.blog_path.data) if new_blog: flask.flash( 'Blog path %s is not available' % (form.blog_path.data, ), 'error') new_blog = None ok_to_create = False if ok_to_create: # First create and persist the user. new_user = users.User(form.username.data, form.email.data, form.name.data, form.password.data) new_user.Persist() # Now create and persist the blog. new_blog = blogs.Blog(form.blog_path.data, form.blog_name.data, new_user) new_blog.Persist() flask.flash('Account Created. Please Log In') return flask.redirect(flask.url_for('.login_page')) # Something failed. Let the user try again. return flask.render_template('create.html', form=form)
def createAccount(): account_form = forms.CreateAccountForm() # set payment address account_form.payment_address.text = metallic.getReceiveAddress() # handle button presses if account_form.validate_on_submit(): # for testing purposes, pay for the account manually # use any address from your test blockchain that has a balance of at least a few Eth. public_key = "0xB753e2f771BF4C1C92eE4143e8cbe2F6aE2E4024" private_key = "a751fc02ac56ad329589b24778ef57173dc1a2d58d008693f43dd5e2b97db94f" transfer(public_key, private_key, metallic.getReceiveAddress(), 0.02) #create account metallic.addAccount(account_form.username.data, account_form.public_address.data, account_form.currency.data, date.today().strftime("%d/%m/%Y")) # verify the username was added print("Username Successfully added!" if metallic.username_exists( account_form.username.data) else "Failed to add username!") # tell the user what happened flash("Account Created.", 'success') # payment verified, reroute to home return redirect(url_for('home')) # 1 gwei = 1 / 1,000,000,000 ETH or 0.000000001 ETH estimated_gas = metallic.estimateGasToAddAccount("test", "test", "test", "test") gas_price = 47 total_eth = int(estimated_gas) * gas_price * 0.000000001 print(str(total_eth)) # render the page return render_template('createAccount.html', title="Create Account", account_form=account_form, estimated_gas=str(total_eth))
def login(): form = forms.CreateAccountForm() return render_template('login.html', form=form)