~sircmpwn/names.sr.ht

4d9f61e946045340bc2b18bbc65f7eebfa151d8f — Drew DeVault 5 months ago b317fe9
Populate validation summaries for new-contact.html
2 files changed, 51 insertions(+), 7 deletions(-)

M names/blueprints/contacts.py
M names/templates/new-contact.html
M names/blueprints/contacts.py => names/blueprints/contacts.py +11 -2
@@ 1,5 1,7 @@
from flask import Blueprint, render_template
import iso3166
from flask import Blueprint, render_template, request
from srht.oauth import loginrequired
from srht.validation import Validation

contacts = Blueprint("names.contacts", __name__)



@@ 11,4 13,11 @@ def contacts_GET():
@contacts.route("/contacts/new")
@loginrequired
def new_GET():
    return render_template("new-contact.html")
    return render_template("new-contact.html",
            iso3166=iso3166)

@contacts.route("/contacts/new", methods=["POST"])
@loginrequired
def new_POST():
    valid = Validation(request)
    return "thanks"

M names/templates/new-contact.html => names/templates/new-contact.html +40 -5
@@ 16,7 16,6 @@
    </p>
  </div>
</div>
{# TODO: Add validation messages for all fields #}
<form method="POST">
  {{csrf_token()}}
  <div class="row">


@@ 31,7 30,6 @@
        maxlength="64"
        required
        value="{{first_name or ""}}" />
      {{valid.summary("first_name")}}
    </div>
    <div class="col-md-4 form-group">
      <label for="last_name">Last Name</label>


@@ 45,6 43,10 @@
        required
        value="{{last_name or ""}}" />
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("first_name")}}
      {{valid.summary("last_name")}}
    </div>
    <div class="col-md-8 offset-md-2 form-group">
      <label for="org_name">Organization Name</label>
      <input


@@ 57,6 59,9 @@
        required
        value="{{org_name or ""}}" />
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("org_name")}}
    </div>
    <div class="col-md-8 offset-md-2 form-group">
      <label for="email">Email address</label>
      <input


@@ 69,6 74,9 @@
        required
        value="{{post_code or current_user.email}}" />
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("email")}}
    </div>
    <div class="col-md-8 offset-md-2 form-group">
      <label for="address_1">Address</label>
      <input


@@ 101,6 109,11 @@
        maxlength="64"
        value="{{address_3 or ""}}" />
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("address_1")}}
      {{valid.summary("address_2")}}
      {{valid.summary("address_3")}}
    </div>
    <div class="col-md-4 offset-md-2 form-group">
      <label for="city">City</label>
      <input


@@ 124,6 137,10 @@
        maxlength="32"
        value="{{state or ""}}" />
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("city")}}
      {{valid.summary("state")}}
    </div>
    <div class="col-md-4 offset-md-2 form-group">
      <label for="post_code">Post code</label>
      <input


@@ 138,7 155,6 @@
    </div>
    <div class="col-md-4 form-group">
      <label for="country">Country</label>
      {# TODO: Populate dropdown #}
      <select
        name="country"
        id="country"


@@ 146,9 162,20 @@
        placeholder="Country"
        required
      >
        <option value="US">United States of America</option>
      {% for c in iso3166.countries %}
        <option
          value="{{c.alpha2}}"
          {% if (not country and c.alpha2 == "US") or c.alpha2 == country %}
          selected
          {% endif %}
        >{{c.name}}</option>
      {% endfor %}
      </select>
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("post_code")}}
      {{valid.summary("country")}}
    </div>
    <div class="col-md-4 offset-md-2 form-group">
      <label for="phone">Phone number</label>
      <input


@@ 171,6 198,10 @@
        maxlength="32"
        value="{{fax or ""}}" />
    </div>
    <div class="col-md-8 offset-md-2">
      {{valid.summary("phone_number")}}
      {{valid.summary("fax_number")}}
    </div>
  </div>
  <div class="row">
    <details class="extra-details col-md-8 offset-md-2">


@@ 180,7 211,7 @@
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            {# TODO: Dropdown #}
            {# TODO: Dropdown? #}
            <label for="text">Language preference</label>
            <input
              type="text"


@@ 205,6 236,10 @@
              value="{{vat or ""}}" />
          </div>
        </div>
        <div class="col-md-12">
          {{valid.summary("language")}}
          {{valid.summary("vat")}}
        </div>
      </div>
    </details>
  </div>