~sircmpwn/names.sr.ht

0548ebf98875713ffc015d7e06378ac652fa1c78 — Drew DeVault 1 year, 10 months ago d8e28b0
Check for paid accounts in next step
M names/blueprints/web.py => names/blueprints/web.py +28 -1
@@ 1,11 1,13 @@
import re
from flask import Blueprint, render_template, request, redirect, url_for
from flask import Blueprint, render_template, request, redirect, url_for, abort
from flask_login import current_user
from jinja2 import Markup
from names.pygments import ZoneLexer
from names.types import User
from pygments import highlight
from pygments.formatters import HtmlFormatter
from srht.flask import loginrequired
from srht.oauth import UserType
from srht.validation import Validation

# TODO: Make OpenSRS integration optional


@@ 65,6 67,31 @@ def create_domain_GET(domain):
                transfer_email=transfer_email,
                suggestions=suggestions)

@web.route("/create/<domain>", methods=["POST"])
@loginrequired
def create_domain_POST(domain):
    valid = Validation(request)
    permitted_users = [
        UserType.active_paying,
        UserType.active_free,
        UserType.admin,
    ]
    if "purchase" in valid:
        if current_user.user_type not in permitted_users:
            return render_template("need-paid-account.html")
        # TODO: Check for contacts
        return render_template("purchase-domain.html")
    elif "transfer" in valid:
        if current_user.user_type not in permitted_users:
            return render_template("need-paid-account.html")
        # TODO: Check for contacts
        return render_template("transfer-domain.html")
    elif "configure" in valid:
        # TODO: Configure domain
        pass
    else:
        abort(400)

@web.route("/mockup")
def mockup():
    with open("/home/sircmpwn/sr.ht.zone") as f:

M names/templates/create-domain.html => names/templates/create-domain.html +7 -7
@@ 20,15 20,15 @@
    <blockquote class="alert alert-warning">
      <strong>Where does this price come from?</strong> We can buy this domain
      at wholesale prices for ${{"{:.02f}".format(market_price / 100.0)}}, then
      we add our payment processing fees to bring our total to
      we add our payment processor's fees to bring the total to
      ${{"{:.02f}".format(our_price / 100.0)}}. If you pay for more than 1
      year, we only charge procesisng fees once. Because you have a paid
      year, we only charge processing fees once. Because you have a paid
      {{cfg("sr.ht", "site-name")}} account, we don't charge a markup.
    </blockquote>
    <button class="btn btn-primary">
    <button class="btn btn-primary" name="purchase">
      Purchase this domain {{icon("caret-right")}}
    </button>
    <button class="btn btn-default">
    <button class="btn btn-default" name="configure">
      Configure nameservers {{icon("caret-right")}}
    </button>
    {% else %}


@@ 44,10 44,10 @@
      Alternatively, you can use our nameservers for free.
    </p>

    <button class="btn btn-primary">
    <button class="btn btn-primary" name="transfer">
      Transfer this domain {{icon("caret-right")}}
    </button>
    <button class="btn btn-default">
    <button class="btn btn-default" name="configure">
      Configure nameservers {{icon("caret-right")}}
    </button>
    {% else %} {# if transferable #}


@@ 55,7 55,7 @@
      wish.
    </p>

    <button class="btn btn-primary">
    <button class="btn btn-primary" name="configure">
      Configure nameservers {{icon("caret-right")}}
    </button>
    <a class="btn btn-default" href="{{url_for('names.web.index')}}">

A names/templates/need-paid-account.html => names/templates/need-paid-account.html +32 -0
@@ 0,0 1,32 @@
{% extends "layout.html" %}
{% block content %}
<div class="row">
  <div class="col-md-12">
    <h3>
      Paid {{cfg("sr.ht", "site-name")}} account needed to continue
    </h3>
    <p>
      Domain registration is only available to paid accounts. This allows us to
      avoid charging you a markup for our domains - you pay what we pay, plus
      our payment processor's fees. Please fill out your billing information on
      your profile, then refresh this page to continue.
    </p>
    {% if current_user.user_type.value == "active_delinquent" %}
    <div class="alert alert-danger">
      <strong>Note</strong>:
      You are seeing this page because your account is paid, but your payment
      is past due.
    </div>
    {% endif %}
    <a
      href="{{get_origin('meta.sr.ht', external=True)}}/billing/initial"
      class="btn btn-primary"
      target="_blank"
    >Continue to billing {{icon('caret-right')}}</a>
    <a
      href="{{url_for("names.web.index")}}"
      class="btn btn-default"
    >Cancel {{icon('caret-right')}}</a>
  </div>
</div>
{% endblock %}