def api_account_new(username): if request.method == 'POST': f = request.form if username and 'email' in f and 'name' in f and 'consent' in f and 'password' in f: account = Account.query.filter_by(username=username).first() if not account: newAccount = Account(username) newAccount.name = f['name'] newAccount.email = f['email'] newAccount.consent = f['consent'] newAccount.password = f['password'] newAccount.created_at = datetime.now() newAccount.icon_url = f.get('icon_url', newAccount.icon_url) db.session.add(newAccount) db.session.commit() return success(newAccount.to_hash()) return error("Username %s is already taken" % username) return error("Username is not specified") else: return error("the request to add [%s] must be done through a post" % username)
print "create site: %s" % site db.session.commit() created_at = datetime.date(2014,3,1) if not deployment: n = account_sheet.cell('A1').value for i in range(2,2+n): id = account_sheet.cell('A' + str(i)).value username = account_sheet.cell('B' + str(i)).value account = Account(username) account.name = account_sheet.cell('C' + str(i)).value account.email = account_sheet.cell('D' + str(i)).value account.password = account_sheet.cell('E' + str(i)).value account.consent = account_sheet.cell('F' + str(i)).value account.icon_url = account_sheet.cell('G' + str(i)).value created_at += datetime.timedelta(days=1) account.created_at = created_at account.modified_at = created_at if id: print "create account: %s" % account db.session.add(account) db.session.commit() else: account = Account("default") created_at += datetime.timedelta(days=1) account.created_at = created_at account.modified_at = created_at db.session.add(account) db.session.commit()