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

Commit

Permalink
Rename accounts/ to general-ledger-accounts/
Browse files Browse the repository at this point in the history
We're not worrying about subledgers yet.
  • Loading branch information
chadwhitacre committed Sep 21, 2015
1 parent f1b5256 commit 544429d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "templates/api.html" %}
{% block subnav %}
{% set current_page = request.path.raw.split('/')[4] %}
{% set nav_base = '/api/v2/accounts' %}
{% set nav_base = '/api/v2/general-ledger-accounts' %}
{% set pages = [ ('/', _('Listing'))
, ('/number', _('Detail'))
] %}
Expand Down
2 changes: 1 addition & 1 deletion templates/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% set current_page = request.path.raw.split('/')[3] %}
{% set nav_base = "/api/v2" %}
{% set pages = [ ('/', _('Overview'))
, ('/accounts/', _('Accounts'))
, ('/general-ledger-accounts/', _('GL Accounts'))
, ('/database/', _('Database'))
] %}
{% include "templates/nav.html" %}
Expand Down
2 changes: 1 addition & 1 deletion tests/py/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def browse(self, setup=None, **kw):
.replace('/%endpoint', '/public') \
.replace('/about/me/%sub', '/about/me') \
.replace('/dashboard/%index', '') \
.replace('/v2/accounts/%number', '/v2/accounts/100')
.replace('/v2/general-ledger-accounts/%number', '/v2/accounts/100')
assert '/%' not in url
if 'index' in url.split('/')[-1]:
url = url.rsplit('/', 1)[0] + '/'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ def setUp(self):
self.db.run("INSERT INTO accounts VALUES ('100', 'Cash')")

def load(self, number):
return json.loads(self.client.GET('/api/v2/accounts/'+number, auth_as='admin').body)
return json.loads(self.client.GET('/api/v2/general-ledger-accounts/'+number, auth_as='admin').body)


def test_can_list_accounts(self):
actual = json.loads(self.client.GET('/api/v2/accounts/', auth_as='admin').body)
actual = json.loads(self.client.GET('/api/v2/general-ledger-accounts/', auth_as='admin').body)
assert actual == [{"number": "100", "name": "Cash"}]

def test_can_get_one_account(self):
assert self.load('100') == {"number": "100", "name": "Cash"}

def test_401_for_anon(self):
assert self.client.GxT('/api/v2/accounts/').code == 401
assert self.client.GxT('/api/v2/accounts/100').code == 401
assert self.client.GxT('/api/v2/general-ledger-accounts/').code == 401
assert self.client.GxT('/api/v2/general-ledger-accounts/100').code == 401

def test_403_for_non_admin(self):
self.make_participant('alice')
assert self.client.GxT('/api/v2/accounts/', auth_as='alice').code == 403
assert self.client.GxT('/api/v2/accounts/100', auth_as='alice').code == 403
assert self.client.GxT('/api/v2/general-ledger-accounts/', auth_as='alice').code == 403
assert self.client.GxT('/api/v2/general-ledger-accounts/100', auth_as='alice').code == 403

def test_can_change_name(self):
self.client.hit( 'PUT'
, '/api/v2/accounts/100'
, '/api/v2/general-ledger-accounts/100'
, data={'number': '100', 'name': 'Cash'}
, auth_as='admin'
)
assert self.load('100') == {"number": "100", "name": "Cash"}

def test_bad_name_is_400(self):
response = self.client.hit( 'PUT'
, '/api/v2/accounts/100'
, '/api/v2/general-ledger-accounts/100'
, data={'number': '100', 'name': 'Cash!'}
, auth_as='admin'
, raise_immediately=False
Expand All @@ -54,15 +54,15 @@ def test_bad_name_is_400(self):
def test_can_save_new_account(self):
assert raises(Response, self.load, '101').value.code == 404
self.client.hit( 'PUT'
, '/api/v2/accounts/101'
, '/api/v2/general-ledger-accounts/101'
, data={'number': '101', 'name': 'Accounts Receivable'}
, auth_as='admin'
)
assert self.load('101') == {"number": "101", "name": "Accounts Receivable"}

def test_inserting_a_duplicate_name_is_400(self):
response = self.client.hit( 'PUT'
, '/api/v2/accounts/101'
, '/api/v2/general-ledger-accounts/101'
, data={'number': '101', 'name': 'Cash'}
, auth_as='admin'
, raise_immediately=False
Expand All @@ -76,12 +76,12 @@ def test_inserting_a_duplicate_name_is_400(self):

def test_updating_a_duplicate_name_is_400(self):
self.client.hit( 'PUT'
, '/api/v2/accounts/101'
, '/api/v2/general-ledger-accounts/101'
, data={'number': '101', 'name': 'Accounts Receivable'}
, auth_as='admin'
)
response = self.client.hit( 'PUT'
, '/api/v2/accounts/101'
, '/api/v2/general-ledger-accounts/101'
, data={'number': '101', 'name': 'Cash'}
, auth_as='admin'
, raise_immediately=False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ if number:
raise Response(404)

banner = _("API")
title = _("Account Detail")
title = _("GL Account Detail")
[---] application/json via json_dump
out
[---] text/html
{% extends "templates/api-accounts.html" %}
{% extends "templates/api-general-ledger-accounts.html" %}
{% block content %}{{ markdown.render("""

See the chart of [`accounts`](/api/v2/accounts/) documentation for a
description of the accounts format.
See the [GL accounts](/api/v2/general-ledger-accounts/) documentation for a
description of the account format.

## Role Required

`admin`

## GET

Returns a single account.
Returns a single GL account.

```bash
$ curl \"https://gratipay.com/api/v2/accounts/100\" \\
$ curl \"https://gratipay.com/api/v2/general-ledger-accounts/100\" \\
-H \"Accept: application/json\" \\
-u \"$user_id:$api_key\"
{\"number\": \"100\": \"name\": \"Cash\"}
Expand All @@ -72,10 +72,10 @@ $ curl \"https://gratipay.com/api/v2/accounts/100\" \\

## PUT

Upserts a single account, returning the account.
Upserts a GL single account, returning the account.

```bash
$ curl \"https://gratipay.com/api/v2/accounts/101\" \\
$ curl \"https://gratipay.com/api/v2/general-ledger-accounts/101\" \\
-H \"Accept: application/json\" \\
-u \"$user_id:$api_key\" \\
-X \"PUT\" \\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ title = _("General Ledger Accounts")
[---] application/json via json_dump
website.db.all('SELECT * FROM accounts ORDER BY number ASC LIMIT 128')
[---] text/html
{% extends "templates/api-accounts.html" %}
{% extends "templates/api-general-ledger-accounts.html" %}
{% block content %}{{ markdown.render("""

Gratipay's general ledger accounts are in the `general_ledger_accounts`
Gratipay's general ledger (GL) accounts are in the `general_ledger_accounts`
database table, which uses the [continuant
pattern](/api/v2/database/continuants). The essential property for GL
account continuants is `id`. Our convention is to encode the type of account in
Expand Down Expand Up @@ -49,7 +49,7 @@ $ curl \"https://gratipay.com/api/v2/accounts/\" \\

## Drill-Down

[`/api/v2/accounts/%number`](/api/v2/accounts/number)
[`/api/v2/general-ledger-accounts/%number`](/api/v2/general-ledger-accounts/number)

""") }}
{% endblock %}
4 changes: 2 additions & 2 deletions www/api/v2/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ the [postgres.py](http://postgres-py.readthedocs.org/) client library.

Here are the resources currently exposed in this API:

- [`accounts/`](/api/v2/accounts/)—our chart of accounts, requires the
`admin` role
- [`general-ledger-accounts/`](/api/v2/general-ledger-accounts/)—our
general ledger chart of accounts, requires the `admin` role

""" )}}{% endblock %}
[---] application/json via json_dump
Expand Down

0 comments on commit 544429d

Please sign in to comment.