From fe1935c4b7412598c5a2e4577e016ad031ae8fe6 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 21 Sep 2015 19:52:40 -0400 Subject: [PATCH] Rename accounts/ to general-ledger-accounts/ We're not worrying about subledgers yet. --- ....html => api-general-ledger-accounts.html} | 2 +- templates/api.html | 2 +- ....py => test_v2_general-ledger-accounts.py} | 24 +++++++++---------- .../%number.spt | 16 ++++++------- .../index.spt | 4 ++-- www/api/v2/index.spt | 4 ++-- 6 files changed, 26 insertions(+), 26 deletions(-) rename templates/{api-accounts.html => api-general-ledger-accounts.html} (82%) rename tests/py/{test_v2_accounts.py => test_v2_general-ledger-accounts.py} (78%) rename www/api/v2/{accounts => general-ledger-accounts}/%number.spt (84%) rename www/api/v2/{accounts => general-ledger-accounts}/index.spt (91%) diff --git a/templates/api-accounts.html b/templates/api-general-ledger-accounts.html similarity index 82% rename from templates/api-accounts.html rename to templates/api-general-ledger-accounts.html index b91110def6..2619ef7f7b 100644 --- a/templates/api-accounts.html +++ b/templates/api-general-ledger-accounts.html @@ -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')) ] %} diff --git a/templates/api.html b/templates/api.html index edef484985..4c1de9d30b 100644 --- a/templates/api.html +++ b/templates/api.html @@ -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" %} diff --git a/tests/py/test_v2_accounts.py b/tests/py/test_v2_general-ledger-accounts.py similarity index 78% rename from tests/py/test_v2_accounts.py rename to tests/py/test_v2_general-ledger-accounts.py index a5f6f524f5..af31368873 100644 --- a/tests/py/test_v2_accounts.py +++ b/tests/py/test_v2_general-ledger-accounts.py @@ -12,28 +12,28 @@ 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' ) @@ -41,7 +41,7 @@ def test_can_change_name(self): 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 @@ -54,7 +54,7 @@ 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' ) @@ -62,7 +62,7 @@ def test_can_save_new_account(self): 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 @@ -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 diff --git a/www/api/v2/accounts/%number.spt b/www/api/v2/general-ledger-accounts/%number.spt similarity index 84% rename from www/api/v2/accounts/%number.spt rename to www/api/v2/general-ledger-accounts/%number.spt index d4c392ef31..5abe577acd 100644 --- a/www/api/v2/accounts/%number.spt +++ b/www/api/v2/general-ledger-accounts/%number.spt @@ -44,15 +44,15 @@ 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 @@ -60,10 +60,10 @@ description of the accounts format. ## 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\"} @@ -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\" \\ diff --git a/www/api/v2/accounts/index.spt b/www/api/v2/general-ledger-accounts/index.spt similarity index 91% rename from www/api/v2/accounts/index.spt rename to www/api/v2/general-ledger-accounts/index.spt index 2e847a8014..9549fec620 100644 --- a/www/api/v2/accounts/index.spt +++ b/www/api/v2/general-ledger-accounts/index.spt @@ -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 diff --git a/www/api/v2/index.spt b/www/api/v2/index.spt index a171b9446f..d42e652501 100644 --- a/www/api/v2/index.spt +++ b/www/api/v2/index.spt @@ -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