Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def do_save_account(account_id):
    account = Account.get_by_id(account_id)

    form = AccountForm(request.form)
    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, account=account), 400
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
 def do_work(self, subscription):
     gtm_email.send_conversion_email(
         Account.get_by_id(subscription.account_id), subscription)
Ejemplo n.º 8
0
def do_delete_account(account_id):
    account = Account.get_by_id(account_id)
    account.delete()
    return redirect(url_for("app_blueprint.show_accounts"))
Ejemplo n.º 9
0
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)