From 784311b1782070f4aeb15033929d35eca42c675e Mon Sep 17 00:00:00 2001 From: Rakib Hasan Date: Mon, 9 Jan 2017 08:06:56 -0500 Subject: [PATCH 1/4] added command line option for nsot sites add, --parent, which allows a user to create a site nested in another site --- pynsot/commands/cmd_sites.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pynsot/commands/cmd_sites.py b/pynsot/commands/cmd_sites.py index bf31472..6b3ce47 100644 --- a/pynsot/commands/cmd_sites.py +++ b/pynsot/commands/cmd_sites.py @@ -66,8 +66,14 @@ def cli(ctx): help='The name of the Site.', required=True, ) +@click.option( + '-p', + '--parent', + metavar='PARENT', + help='ID of parent site' +) @click.pass_context -def add(ctx, description, name): +def add(ctx, description, name, parent): """ Add a new Site. From e327553ef0e994000a74a75de6b46a7110b7784c Mon Sep 17 00:00:00 2001 From: Rakib Hasan Date: Tue, 10 Jan 2017 23:58:18 -0500 Subject: [PATCH 2/4] added -p/--parent option to update --- pynsot/commands/cmd_sites.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pynsot/commands/cmd_sites.py b/pynsot/commands/cmd_sites.py index 6b3ce47..7128dee 100644 --- a/pynsot/commands/cmd_sites.py +++ b/pynsot/commands/cmd_sites.py @@ -187,15 +187,20 @@ def remove(ctx, id): metavar='NAME', help='The name of the Site.', ) +@click.option( + '-p', + '--parent', + type=int +) @click.pass_context -def update(ctx, description, id, name): +def update(ctx, description, id, name, parent): """ Update a Site. When updating a Site you must provide the unique ID (-i/--id) and at least - one of the -n/--name or -d/--description arguments. + one of the -n/--name, -p/--parent or -d/--description arguments. """ - if name is None and description is None: + if name is None and description is None and parent is None: msg = 'You must supply at least one of -n/--name or -d/--description' raise click.UsageError(msg) From e89687288841becafdc9995ff82ff5f08dd97721 Mon Sep 17 00:00:00 2001 From: Rakib Hasan Date: Thu, 12 Jan 2017 00:20:45 -0500 Subject: [PATCH 3/4] added a field to display fields so that nsot sites list can display parents of sites --- pynsot/commands/cmd_sites.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pynsot/commands/cmd_sites.py b/pynsot/commands/cmd_sites.py index 7128dee..a795812 100644 --- a/pynsot/commands/cmd_sites.py +++ b/pynsot/commands/cmd_sites.py @@ -30,6 +30,7 @@ ('id', 'ID'), ('name', 'Name'), ('description', 'Description'), + ('parent', 'Parent'), ) @@ -190,7 +191,8 @@ def remove(ctx, id): @click.option( '-p', '--parent', - type=int + metavar='PARENT', + help='ID of parent site' ) @click.pass_context def update(ctx, description, id, name, parent): From 4b7bbbe81244412afe6f2ce537608bfa53371d22 Mon Sep 17 00:00:00 2001 From: Rakib Hasan Date: Thu, 12 Jan 2017 23:24:13 -0500 Subject: [PATCH 4/4] added parent to site test fixture --- tests/fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index 68c677b..bd6a9c1 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -85,7 +85,7 @@ def client(config): @pytest.fixture def site(client): """Returns a Site object.""" - return client.sites.post({'name': 'Foo', 'description': 'Foo site.'}) + return client.sites.post({'name': 'Foo', 'description': 'Foo site.', 'parent': ''}) @pytest.fixture