def register(user_type): base_url = "register_" + user_type + ".html" form = RegisterForm() if form.validate_on_submit(): if user_exists(request.form['email'], user_type, db): flash("A user with this email already exists") return render_template(base_url, form=form, user_type=user_type) account = register_user(user_type, request.form, db) if account == "IV": flash("Invalid address. Make sure it looks like: 825 West End Ave #4A, New York.") return redirect("register/%s"%user_type) create_account(user_type, account, db) return redirect(url_for('login')) if request.method=="POST": flash("Your email or password is not valid. Please try again.") return render_template(base_url, form=form, user_type=user_type)
def register_test(): if request.method == "POST": print(request.form) user_type = request.form["type"] print(user_type) form = RegisterForm() print(form) if form.validate_on_submit(): print("HELLO") if user_exists(request.form['email'], user_type, db): flash("A user with this email already exists") return render_template("register_update.html") account = register_user(user_type, request.form, db) create_account(user_type, account, db) return redirect(url_for('login')) else: return render_template("register_update.html")
def create_owner(password=None): address, key = create_account(password) data = {'address': address, 'password': password, 'key': key} with open('Owner.json', 'w') as outfile: json.dump(data, outfile) return address
def editAccount_save(request, accountID=None): if accountID == "0": accountID = None dob = request.POST.get("birth_date", None) if dob: day, month, year = dob.split("/") dob = year + "-" + month + "-" + day new_account = { "first_name": request.POST.get("first_name", ""), "last_name": request.POST.get("last_name", ""), "gender": request.POST.get("gender", "m"), "birth_date": dob, "email": request.POST.get("email", ""), "street_number": request.POST.get("street_number", ""), "city": request.POST.get("city", ""), "zipcode": request.POST.get("zipcode", ""), "phone": request.POST.get("phone", ""), "country": request.POST.get("country", "uk"), "utm_campaign": request.POST.get("utm_campaign", ""), "utm_source": request.POST.get("utm_source", ""), "utm_medium": request.POST.get("utm_medium", ""), "tr_language": request.POST.get("tr_language", "en_EN"), "tr_input_method": request.POST.get("tr_input_method", ""), "tr_ip_address": request.POST.get("tr_ip_address", ""), "resource_uri": request.POST.get("resource_uri", ""), "lead": request.POST.get("lead", False), "mailing_list": request.POST.get("mailing_list", 1), "tr_referral_name": request.POST.get("tr_referral", "ScottFeed"), } create_account(request, new_account, accountID) return HttpResponseRedirect("/")
#!/usr/local/bin/python import requests from utils import create_account url = 'http://api.scott-site.info/v1/account_lead/' payload = {'username':'******', 'api_key':'GET_YOUR_OWN', 'format':'json'} r = requests.get(url, params=payload) for account in r.json['objects']: create_account(None, account, updateAPI=False)