From 9ea8dca4e3e706cf381137b90014922328e8ff32 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 19 Jan 2018 16:16:45 -0500 Subject: [PATCH 1/5] Evaluate device_id rather than pulling entire device (DB optimization) --- netbox/templates/dcim/inc/interface.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index b0c35a0e9..99fb76a7d 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -114,7 +114,7 @@ {% endif %} {% endif %} - + {% endif %} @@ -124,7 +124,7 @@ {% else %} - + {% endif %} From 7341ae087cf57672e21662b4dba9a22f83275bde Mon Sep 17 00:00:00 2001 From: John Anderson Date: Mon, 22 Jan 2018 10:43:19 -0500 Subject: [PATCH 2/5] added statement and exaple for using ForeignKey ID's in write actions --- docs/api/examples.md | 27 ++++++++++++++++++++++++++- docs/api/overview.md | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/api/examples.md b/docs/api/examples.md index 4ec2f0f33..1fe60707a 100644 --- a/docs/api/examples.md +++ b/docs/api/examples.md @@ -90,7 +90,7 @@ $ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0 "id": 16, "name": "My New Site", "slug": "my-new-site", - "region": null, + "region": 5, "tenant": null, "facility": "", "asn": null, @@ -102,6 +102,31 @@ $ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0 "comments": "" } ``` +Note that in this example we are creating a site bound to a region with the ID of 5. For write api actions (`POST`, `PUT`, and `PATCH`) the integer ID value is for `ForeignKey` (related model) relationships, instead of the nested representation that is used in the `GET` action. + +### Creating a new site with an existing region + +Send a `POST` rquest as before to the site list endpoint, but this time include a value for an existing region. + +``` +$ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/ --data '{"name": "My New Site", "slug": "my-new-site"}' +{ + "id": 16, + "name": "My New Site", + "slug": "my-new-site", + "region": 5, + "tenant": null, + "facility": "", + "asn": null, + "physical_address": "", + "shipping_address": "", + "contact_name": "", + "contact_phone": "", + "contact_email": "", + "comments": "" +} +``` +Note that in this example we are creating a site bound to a region with the ID of 5. For write api actions (`POST`, `PUT`, and `PATCH`) the integer ID value is used for `ForeignKey` (related model) relationships, instead of the nested representation that is used in the `GET` (list) action. ### Modify an existing site diff --git a/docs/api/overview.md b/docs/api/overview.md index db9c1de4d..ba7e11bbf 100644 --- a/docs/api/overview.md +++ b/docs/api/overview.md @@ -104,7 +104,7 @@ The base serializer is used to represent the default view of a model. This inclu } ``` -Related objects (e.g. `ForeignKey` fields) are represented using a nested serializer. A nested serializer provides a minimal representation of an object, including only its URL and enough information to construct its name. +Related objects (e.g. `ForeignKey` fields) are represented using a nested serializer. A nested serializer provides a minimal representation of an object, including only its URL and enough information to construct its name. When performing write api actions (`POST`, `PUT`, and `PATCH`), any `ForeignKey` relationships do not use the nested serializer, instead you will pass just the integer ID of the related model. When a base serializer includes one or more nested serializers, the hierarchical structure precludes it from being used for write operations. Thus, a flat representation of an object may be provided using a writable serializer. This serializer includes only raw database values and is not typically used for retrieval, except as part of the response to the creation or updating of an object. From 53998e0fff394e3410a932afb16fe500468a89ed Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 22 Jan 2018 16:04:19 -0500 Subject: [PATCH 3/5] Closes #1828: Added warning about media directory permissions --- docs/installation/netbox.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/installation/netbox.md b/docs/installation/netbox.md index 530456a56..10dff7f3a 100644 --- a/docs/installation/netbox.md +++ b/docs/installation/netbox.md @@ -88,6 +88,13 @@ Resolving deltas: 100% (1495/1495), done. Checking connectivity... done. ``` +!!! warning + Ensure that the media directory (`/opt/netbox/netbox/media/` in this example) and all its subdirectories are writable by the user account as which NetBox runs. If the NetBox process does not have permission to write to this directory, attempts to upload files (e.g. image attachments) will fail. (The appropriate user account will vary by platform.) + + ``` + # chown -R netbox:netbox /opt/netbox/netbox/media/ + ``` + ## Install Python Packages Install the required Python packages using pip. (If you encounter any compilation errors during this step, ensure that you've installed all of the system dependencies listed above.) From 6b50755a5a1df04055ca6b21ecc42773cdcfb54d Mon Sep 17 00:00:00 2001 From: John Anderson Date: Mon, 22 Jan 2018 16:26:51 -0500 Subject: [PATCH 4/5] fixed duplicate api docs example and grammar --- docs/api/examples.md | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/docs/api/examples.md b/docs/api/examples.md index 1fe60707a..aa2478698 100644 --- a/docs/api/examples.md +++ b/docs/api/examples.md @@ -82,10 +82,10 @@ $ curl -H "Accept: application/json; indent=4" http://localhost/api/dcim/sites/6 ### Creating a new site -Send a `POST` request to the site list endpoint with token authentication and JSON-formatted data. Only mandatory fields are required. +Send a `POST` request to the site list endpoint with token authentication and JSON-formatted data. Only mandatory fields are required. This example includes one non required field, "region." ``` -$ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/ --data '{"name": "My New Site", "slug": "my-new-site"}' +$ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/ --data '{"name": "My New Site", "slug": "my-new-site", "region": 5}' { "id": 16, "name": "My New Site", @@ -102,31 +102,7 @@ $ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0 "comments": "" } ``` -Note that in this example we are creating a site bound to a region with the ID of 5. For write api actions (`POST`, `PUT`, and `PATCH`) the integer ID value is for `ForeignKey` (related model) relationships, instead of the nested representation that is used in the `GET` action. - -### Creating a new site with an existing region - -Send a `POST` rquest as before to the site list endpoint, but this time include a value for an existing region. - -``` -$ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/ --data '{"name": "My New Site", "slug": "my-new-site"}' -{ - "id": 16, - "name": "My New Site", - "slug": "my-new-site", - "region": 5, - "tenant": null, - "facility": "", - "asn": null, - "physical_address": "", - "shipping_address": "", - "contact_name": "", - "contact_phone": "", - "contact_email": "", - "comments": "" -} -``` -Note that in this example we are creating a site bound to a region with the ID of 5. For write api actions (`POST`, `PUT`, and `PATCH`) the integer ID value is used for `ForeignKey` (related model) relationships, instead of the nested representation that is used in the `GET` (list) action. +Note that in this example we are creating a site bound to a region with the ID of 5. For write API actions (`POST`, `PUT`, and `PATCH`) the integer ID value is used for `ForeignKey` (related model) relationships, instead of the nested representation that is used in the `GET` (list) action. ### Modify an existing site From 21fe7c57d88e102c4ff25f521d32b6ce70868873 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 25 Jan 2018 10:19:45 -0500 Subject: [PATCH 5/5] Closes #1835: Consistent position of previous/next rack buttons --- netbox/templates/dcim/rack.html | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 05585348f..b5eb8874e 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -24,28 +24,20 @@
- {% if prev_rack %} - - - Previous Rack - - {% endif %} - {% if next_rack %} - - - Next Rack - - {% endif %} + + Previous Rack + + + Next Rack + {% if perms.dcim.change_rack %} - - Edit this rack + Edit this rack {% endif %} {% if perms.dcim.delete_rack %} - - Delete this rack + Delete this rack {% endif %}