Skip to content

Commit 2035e64

Browse files
committed
Misc cleanup
1 parent d6408ef commit 2035e64

11 files changed

+31
-27
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Before attempting to create a plugin, please assess your personal ability. Plugi
1515

1616
### Contents
1717

18-
* [Step 1: Initial Setup](/tutorial/step01-initial-setup.md) (Start here!)
18+
* [Step 1: Initial Setup](/tutorial/step01-initial-setup.md) :arrow_left: Start here!
1919
* [Step 2: Models](/tutorial/step02-models.md)
2020
* [Step 3: Tables](/tutorial/step03-tables.md)
2121
* [Step 4: Forms](/tutorial/step04-forms.md)
@@ -24,7 +24,11 @@ Before attempting to create a plugin, please assess your personal ability. Plugi
2424
* [Step 7: Navigation](/tutorial/step07-navigation.md)
2525
* [Step 8: Filter Sets](/tutorial/step08-filter-sets.md)
2626
* [Step 9: REST API](/tutorial/step09-rest-api.md)
27-
* [Step 10: GraphQL API](/tutorial/step10-graphql.md)
27+
* [Step 10: GraphQL API](/tutorial/step10-graphql-api.md)
28+
29+
### Reference
30+
31+
* [NetBox Plugin Development Documentation](https://netbox.readthedocs.io/en/feature/plugins/development/)
2832

2933
### Getting Help
3034

tutorial/step01-initial-setup.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@ Before we can begin work on our plugin, we must first ensure that we have a suit
66

77
### Install NetBox
88

9-
TODO
9+
Plugin development requires a local installation of NetBox. If you don't already have NetBox installed, please consult the [installation instructions](https://netbox.readthedocs.io/en/feature/installation/).
10+
11+
:green_circle: **Tip:** If this installation will be for development use only, it is generally necessary to complete only up to step three in the installation guide, culminating with successfully running the NetBox development server (`manage.py runserver`).
12+
13+
:warning: **Warning:** This guide requires NetBox v3.2 or later. Attempting to use an earlier NetBox release will not work.
1014

1115
### Clone the git Repository
1216

1317
Next, we'll clone the demo git repository from GitHub. First, `cd` into your preferred location (your home directory is probably fine), then clone the repo with `git clone`. We're checking out the `init` branch, which will provide us with an empty workspace to start.
1418

1519
```bash
1620
$ git clone --branch step00-empty https://github.com/netbox-community/netbox-plugin-demo
17-
# TODO: Include git output
21+
Cloning into 'netbox-plugin-demo'...
22+
remote: Enumerating objects: 58, done.
23+
remote: Counting objects: 100% (58/58), done.
24+
remote: Compressing objects: 100% (42/42), done.
25+
remote: Total 58 (delta 12), reused 58 (delta 12), pack-reused 0
26+
Unpacking objects: 100% (58/58), done.
1827
```
1928

2029
:blue_square: **Note:** It isn't strictly required to clone the demo repository, but it will enable you to conveniently check out snapshots of the code as the lessons progress and overcome any hiccups.
@@ -143,5 +152,5 @@ You should see the development start successfully. Open NetBox in a new browser
143152

144153
This completes our initial setup. Now, onto the fun stuff!
145154

146-
:arrow-right: [Step 2: Models](/tutorial/step02-models.md)
155+
:arrow_right: [Step 2: Models](/tutorial/step02-models.md)
147156

tutorial/step02-models.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ Additionally, we've added a `key` attribute: This will allow the NetBox administ
211211
Now, we can reference this as the set of valid choices on the `default_action` and `action` model fields by referencing it with the `choices` keyword argument.
212212

213213
```python
214-
# AccessList
214+
# AccessList
215215
default_action = models.CharField(
216216
max_length=30,
217217
choices=ActionChoices
218218
)
219219

220-
# AccessListRule
220+
# AccessListRule
221221
action = models.CharField(
222222
max_length=30,
223223
choices=ActionChoices
@@ -373,5 +373,5 @@ And a few rules to go with it:
373373

374374
Excellent! We can now create access lists and rules in the database. The next few steps will work on expsoing this functionality in the NetBox user interface.
375375

376-
:arrow-right: [Step 3: Tables](/tutorial/step03-tables.md)
376+
:arrow_right: [Step 3: Tables](/tutorial/step03-tables.md)
377377

tutorial/step03-tables.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ class AccessListRuleTable(NetBoxTable):
7878
linkify=True
7979
)
8080

81-
class Meta(NetBoxTable.Meta):
82-
model = AccessListRule
81+
class Meta(NetBoxTable.Meta): = AccessListRule
8382
fields = (
8483
'pk', 'id', 'access_list', 'index', 'source_prefix', 'source_ports', 'destination_prefix',
8584
'destination_ports', 'protocol', 'action', 'description', 'actions',
@@ -92,5 +91,5 @@ class AccessListRuleTable(NetBoxTable):
9291

9392
This should be all we need to display objects. Next, we'll define some forms to enable creating and modifying objects.
9493

95-
:arrow-right: [Step 4: Models](/tutorial/step04-forms.md)
94+
:arrow_right: [Step 4: Models](/tutorial/step04-forms.md)
9695

tutorial/step04-forms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ class AccessListRuleForm(NetBoxModelForm):
9292

9393
With our models, tables, and forms all in place, next we'll create some views to bring everything together!
9494

95-
:arrow-right: [Step 5: Views](/tutorial/step05-views.md)
95+
:arrow_right: [Step 5: Views](/tutorial/step05-views.md)
9696

tutorial/step05-views.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,5 +246,5 @@ However, if you click the link to the access list object, you'll be met by a `Te
246246

247247
:blue_square: **Note:** You might notice that the "add" view for access list rules still doesn't work, raising a `NoReverseMatch` exception. This is because we haven't yet defined the REST API backends required to support the dynamic form fields. We'll take care of this in step nine.
248248

249-
:arrow-right: [Step 6: Templates](/tutorial/step06-templates.md)
249+
:arrow_right: [Step 6: Templates](/tutorial/step06-templates.md)
250250

tutorial/step06-templates.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@ $ edit templates/netbox_access_lists/accesslist.html
2929

3030
Although we need to create our own template, NetBox has done much of the work for us, and provides a generic template that we can easily extend. At the top of the file, add an `extends` tag:
3131

32-
{% raw %}
3332
```
3433
{% extends 'generic/object.html' %}
3534
```
36-
{% endraw %}
3735

3836
This tells the rendering engine to first load the NetBox template at `generic/object.html` and populate only the content we provide within the associated `block` tags.
3937

4038
Let's extend the generic template's `content` block with some information about the access list.
4139

42-
{% raw %}
4340
```
4441
{% block content %}
4542
<div class="row mb-3">
@@ -72,7 +69,6 @@ Let's extend the generic template's `content` block with some information about
7269
</div>
7370
{% endblock content %}
7471
```
75-
{% endraw %}
7672

7773
Here we've created Boostrap 5 row and two column elements. In the first column, we have a simple card to display the access list's name and default action, as well as the number of rules assigned to it. And below it, you'll see an `include` tag which pulls in an additional template to render any custom fields associated with the model. In the second column, we've included two more templates to render tags and comments.
7874

@@ -111,15 +107,12 @@ This makes the table available to our template as the `rules_table` context vari
111107

112108
First, we need to import the `render_table` tag from the `django-tables2` library, so that we can render the table as HTML. Add this at the top of the template, immediately below the {% raw %}`{% extends %}`{% endraw %} tag:
113109

114-
{% raw %}
115110
```
116111
{% load render_table from django_tables2 %}
117112
```
118-
{% endraw %}
119113

120114
Then, immediately above the {% raw %}`{% endblock content %}`{% endraw %} line at the end of the file, insert the following template code:
121115

122-
{% raw %}
123116
```
124117
<div class="row">
125118
<div class="col col-md-12">
@@ -132,7 +125,6 @@ Then, immediately above the {% raw %}`{% endblock content %}`{% endraw %} line a
132125
</div>
133126
</div>
134127
```
135-
{% endraw %}
136128

137129
After refreshing the access list view in the browser, you should now see the rules table at the bottom of the page.
138130

@@ -148,7 +140,6 @@ $ edit templates/netbox_access_lists/accesslistrule.html
148140

149141
And copy the content below:
150142

151-
{% raw %}
152143
```
153144
{% extends 'generic/object.html' %}
154145
@@ -227,7 +218,6 @@ And copy the content below:
227218
</div>
228219
{% endblock content %}
229220
```
230-
{% endraw %}
231221

232222
You'll probably be able to figure out most of this for yourself by now, but here are a few details worth mentioning:
233223

@@ -239,5 +229,5 @@ You'll probably be able to figure out most of this for yourself by now, but here
239229

240230
Feel free to experiment with different layouts and content before proceeding with the next step.
241231

242-
:arrow-right: [Step 7: Navigation](/tutorial/step07-navigation.md)
232+
:arrow_right: [Step 7: Navigation](/tutorial/step07-navigation.md)
243233

tutorial/step07-navigation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@ Now we should see green "add" buttons appear next to our menu links.
110110

111111
![Navigation menu items with buttons](/images/step07-menu-items2.png)
112112

113-
:arrow-right: [Step 8: Filer Sets](/tutorial/step08-filter-sets.md)
113+
:arrow_right: [Step 8: Filer Sets](/tutorial/step08-filter-sets.md)
114114

tutorial/step08-filter-sets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ If you haven't already, create a few more access lists and rules, and experiment
122122

123123
:green_circle: **Tip:** You may notice that we did not add a form field for the model's `id` filter: This is because it is unlikely to be useful for a human utilizing the UI. However, we still want to support filtering object by their primary keys, because it _is_ very helpful for consumers of NetBox's REST API, which we'll cover next.
124124

125-
:arrow-right: [Step 9: REST API](/tutorial/step09-rest-api.md)
125+
:arrow_right: [Step 9: REST API](/tutorial/step09-rest-api.md)
126126

tutorial/step09-rest-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,5 @@ With all of our REST API components now in place, we should be able to make API
237237

238238
![REST API - Access list rules](/images/step09-rest-api2.png)
239239

240-
This completes the tutorial. Well done! Now you're all set to make a plugin of your own!
240+
:arrow_right: [Step 10: GraphQL API](/tutorial/step10-graphql-api.md)
241241

0 commit comments

Comments
 (0)