def do_create_account(): form = AccountForm(request.form) account = Account() form.populate_obj(account) if form.validate_on_submit(): account.save() return redirect(url_for("app_blueprint.show_accounts")) return render_template("account.html", form=form), 400
def create_account(email="*****@*****.**"): account = Account() account.email = email account.default_subscription_price = 12500 account.first_name = "Bob" account.last_name = "Aol.com" account.save() return account
def do_expire_subscription(account_id, subscription_id): account = Account.get_by_id(account_id) subscription = Subscription.get_by_id(subscription_id) subscription.expire_subscription() return redirect( url_for("app_blueprint.show_account", account_id=account.id))
def show_account(account_id): account = Account.get_by_id(account_id) subscriptions = account.get_subscriptions(active_only=True) form = AccountForm(obj=account) return render_template("account.html", form=form, account=account, subscriptions=subscriptions)
def show_subscription(account_id, subscription_id): account = Account.get_by_id(account_id) subscription = Subscription.get_by_id(subscription_id) form = SubscriptionForm(obj=subscription) return render_template("subscription.html", form=form, account=account, subscription=subscription)
def do_save_subscription(account_id, subscription_id): account = Account.get_by_id(account_id) subscription = Subscription.get_by_id(subscription_id) form = SubscriptionForm(request.form) form.populate_obj(subscription) if form.validate_on_submit(): subscription.save() return redirect( url_for("app_blueprint.show_account", account_id=account.id)) return render_template("subscription.html", form=form, account=account, subscription=subscription), 400
def do_export_accounts(): si = StringIO.StringIO() cw = csv.writer(si) accounts = Account.query.all() cw.writerow(Account.get_fields()) for account in accounts: cw.writerow(account.get_field_values()) output = make_response(si.getvalue()) output.headers[ "Content-Disposition"] = "attachment; filename={}-accounts.csv".format( datetime.datetime.today().isoformat()) output.headers["Content-type"] = "text/csv" return output
def do_create_subscription(account_id): form = SubscriptionForm(request.form) # All subscriptions are active when created. form.status.data = SubscriptionStatuses.active account = Account.get_by_id(account_id) subscription = Subscription() form.populate_obj(subscription) if form.validate_on_submit(): subscription.add_to_mailing_list() subscription.save() return redirect( url_for("app_blueprint.show_account", account_id=account.id)) return render_template("subscription.html", account=account, form=form), 400
def do_work(self, subscription): gtm_email.send_conversion_email( Account.get_by_id(subscription.account_id), subscription)
def do_delete_account(account_id): account = Account.get_by_id(account_id) account.delete() return redirect(url_for("app_blueprint.show_accounts"))
def show_create_subscription(account_id): account = Account.get_by_id(account_id) form = SubscriptionForm(request.form) return render_template("subscription.html", account=account, form=form)