示例#1
0
def index():
	form = CreateAccountForm()

	if form.validate_on_submit():

		#instantiate the API
		api = API()

		#Create the new MCC account
		account = api.create_account(form.Company.data, form.Status.data)

		#Add the admin user to the account
		api.add_user(account, form.Email.data, form.First_Name.data, form.Last_Name.data)

		#Add the Platform. The ID of the dropdown is different from the ID in the services
		#listing.
		if form.Platform.data == '3':
			api.update_services(account, 1)
		if form.Platform.data == '8':
			api.update_services(account, 3)
		if form.Platform.data == '14':
			api.update_services(account, 19)	

		#Enable any features
		if form.Adv_Reporting.data:
			api.update_services(account, 7)
		if form.EPA.data:
			api.update_services(account, 10)
		if form.Rules_Engine.data:
			api.update_services(account, 36)

		#Set the delivery region
		api.update_delivery_network(account, form.Delivery_Region.data)

		#Add the origin to the account
		if form.Platform.data == '3':
			origin = api.add_origin_http_large(account, form.Origin.data)
		if form.Platform.data == '8':
			origin = api.add_origin_http_small(account, form.Origin.data)
		if form.Platform.data == '14':
			origin = api.add_origin_adn(account, form.Origin.data)

		#Add Cname to the account
		api.add_edge_cname(account, form.Cname.data, form.Platform.data, origin)

		return render_template('success.html', account=account)

	return render_template('index.html', form=form)