Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Clean up #18
Browse files Browse the repository at this point in the history
Here's what I did:

 - Took out redundant getters and modified tests to expect ints
 - Standardized on 'expiration' instead of 'expiry'
 - Reverted to former FORM width, tweaking only expiration field
 - Stuck with pixels for FORM layout (a switch to em should be done as a
   whole, and #66 surely affects this)
 - Show expiration error before CVV to match order in UI
  • Loading branch information
chadwhitacre committed Feb 5, 2013
1 parent 625fbae commit ef6503e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
8 changes: 0 additions & 8 deletions gittip/billing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ def __getitem__(self, name):
out = self._get('last4')
if out:
out = "************" + out
elif name == 'expiry_month':
out = self._get('expiry_month')
elif name == 'expiry_year':
out = self._get('expiry_year')
else:
name = { 'address_1': 'address_line1'
, 'address_2': 'address_line2'
Expand Down Expand Up @@ -240,10 +236,6 @@ def __getitem__(self, name):
out = self._get('last_four')
if out:
out = "************" + unicode(out)
elif name == 'expiry_month':
out = self._get('expiration_month')
elif name == 'expiry_year':
out = self._get('expiration_year')
elif name == 'address_2':
out = self._get('meta', {}).get('address_2', '')
elif name == 'state':
Expand Down
12 changes: 6 additions & 6 deletions tests/test_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def test_balanced_card_basically_works(ba):
expected = { 'id': '/v1/marketplaces/M123/accounts/A123'
, 'last_four': 1234
, 'last4': '************1234'
, 'expiry_month': '10'
, 'expiry_year': '2020'
, 'expiration_month': 10
, 'expiration_year': 2020
, 'address_1': '123 Main Street'
, 'address_2': 'Box 2'
, 'state': 'Confusion'
Expand Down Expand Up @@ -64,8 +64,8 @@ def test_balanced_card_gives_class_name_instead_of_KeyError(ba):
def test_stripe_card_basically_works(sc):
active_card = {}
active_card['last4'] = '1234'
active_card['expiry_month'] = 10
active_card['expiry_year'] = 2020
active_card['expiration_month'] = 10
active_card['expiration_year'] = 2020
active_card['address_line1'] = "123 Main Street"
active_card['address_line2'] = "Box 2"
active_card['address_state'] = "Confusion"
Expand All @@ -77,8 +77,8 @@ def test_stripe_card_basically_works(sc):

expected = { 'id': 'deadbeef'
, 'last4': '************1234'
, 'expiry_month': '10'
, 'expiry_year': '2020'
, 'expiration_month': 10
, 'expiration_year': 2020
, 'address_1': '123 Main Street'
, 'address_2': 'Box 2'
, 'state': 'Confusion'
Expand Down
12 changes: 6 additions & 6 deletions www/assets/%version/gittip.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ PRE {
FORM.special {
}
FORM.special .half {
width: 156px;
width: 150px;
}
FORM.special .full {
clear: both;
Expand Down Expand Up @@ -231,7 +231,7 @@ FORM.special LABEL {
}
FORM.special INPUT {
font: normal 11pt/14pt Arial, sans-serif;
width: 312px;
width: 292px;
margin: 0;
padding: 3px;
border: 1px solid #CCBAAD;
Expand All @@ -243,7 +243,7 @@ FORM.special INPUT.disabled {
}

FORM.special .half INPUT {
width: 145px;
width: 137px;
}
FORM.special .right.half LABEL,
FORM.special .right.half INPUT {
Expand All @@ -258,10 +258,10 @@ FORM.special .float {
FORM.special .city INPUT { width: 137px; }
FORM.special .state INPUT { width: 43px; }
FORM.special .zip INPUT { width: 75px; }
FORM.special .card_number INPUT { width: 145px; }
FORM.special .card_number INPUT { width: 137px; }
FORM.special .cvv INPUT { width: 43px; }
FORM.special .expiry .expiry_month { width: 2em; }
FORM.special .expiry .expiry_year { width: 3em; margin-left: 1px; }
FORM.special INPUT.expiration_month { width: 24px; }
FORM.special INPUT.expiration_year { width: 39px; margin-left: 1px ! important; }
FORM.special .not-first LABEL,
FORM.special .not-first INPUT {
margin-left: 10px;
Expand Down
18 changes: 9 additions & 9 deletions www/assets/%version/gittip.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,28 +399,28 @@ Gittip.submitPaymentForm = function(e)
};
credit_card.postal_code = val('zip');

credit_card.expiration_month= val('expiry_month');
credit_card.expiration_year = val('expiry_year');
credit_card.expiration_month = val('expiration_month');
credit_card.expiration_year = val('expiration_year');

if (!balanced.card.isCardNumberValid(credit_card.card_number))
{
$('BUTTON#save').text('Save');
Gittip.showFeedback(null, ["Your card number is bad."]);
}
else if (!balanced.card.isExpiryValid( credit_card.expiration_month
, credit_card.expiration_year
))
{
$('BUTTON#save').text('Save');
Gittip.showFeedback(null, ["Your expiration date is bad."]);
}
else if (!balanced.card.isSecurityCodeValid( credit_card.card_number
, credit_card.security_code
))
{
$('BUTTON#save').text('Save');
Gittip.showFeedback(null, ["Your CVV is bad."]);
}
else if (!balanced.card.isExpiryValid( credit_card.expiration_month
, credit_card.expiration_year
))
{
$('BUTTON#save').text('Save');
Gittip.showFeedback(null, ["Your Expiration date is bad."]);
}
else
{
balanced.card.create(credit_card, Gittip.paymentsResponseHandler);
Expand Down
10 changes: 5 additions & 5 deletions www/credit-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h2 class="first">Credit Card</h2>
overflow: hidden;
}
FORM {
width: 320px;
width: 300px;
}
{% if status == "missing" %}
#delete {
Expand Down Expand Up @@ -138,10 +138,10 @@ <h3>Required</h3>
<input id="card_number" />
</div>

<div class="float expiry not-first">
<label for="expiry_month">Expiration</label>
<input class="expiry_month" id="expiry_month" placeholder="MM"/>
<input class="expiry_year" id="expiry_year" placeholder="YYYY"/>
<div class="float expiration not-first">
<label for="expiration_month">Expiration</label>
<input class="expiration_month" id="expiration_month" placeholder="MM"/>
<input class="expiration_year" id="expiration_year" placeholder="YYYY"/>
</div>

<div class="float cvv not-first">
Expand Down

0 comments on commit ef6503e

Please sign in to comment.