Skip to content

Commit

Permalink
Merge pull request #62 from mlebreuil/develop
Browse files Browse the repository at this point in the history
permission management
  • Loading branch information
mlebreuil authored Jun 7, 2023
2 parents 02879a3 + fe62c89 commit 8431ef1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ Add support for Netbox 3.5 which become the minimum version supported to accomod
#### version 2.0.3

* [#60](https://github.com/mlebreuil/netbox-contract/issues/60) Update contract quick search to also filter on fields "External reference" and "Comments".
* [#49](https://github.com/mlebreuil/netbox-contract/issues/49) Manage permissions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "netbox-contract"
version = "2.0.2"
version = "2.0.3"
authors = [
{ name="Marc Lebreuil", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion src/netbox_contract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ContractsConfig(PluginConfig):
name = 'netbox_contract'
verbose_name = 'Netbox contract'
description = 'Contract management plugin for Netbox'
version = '2.0.2'
version = '2.0.3'
author = 'Marc Lebreuil'
author_email = '[email protected]'
base_url = 'contracts'
Expand Down
20 changes: 13 additions & 7 deletions src/netbox_contract/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
link='plugins:netbox_contract:contract_add',
title='Add',
icon_class='mdi mdi-plus-thick',
color=ButtonColorChoices.GREEN
color=ButtonColorChoices.GREEN,
permissions=['netbox_contract.add_contract']
)
]

Expand All @@ -18,7 +19,8 @@
link='plugins:netbox_contract:invoice_add',
title='Add',
icon_class='mdi mdi-plus-thick',
color=ButtonColorChoices.GREEN
color=ButtonColorChoices.GREEN,
permissions=['netbox_contract.add_invoice']
)
]

Expand All @@ -27,26 +29,30 @@
link='plugins:netbox_contract:serviceprovider_add',
title='Add',
icon_class='mdi mdi-plus-thick',
color=ButtonColorChoices.GREEN
color=ButtonColorChoices.GREEN,
permissions=['netbox_contract.add_serviceprovider']
)
]

contract_menu_item = PluginMenuItem(
link='plugins:netbox_contract:contract_list',
link_text='Contracts',
buttons=contract_buttons
buttons=contract_buttons,
permissions=['netbox_contract.view_contract']
)

invoices_menu_item = PluginMenuItem(
link='plugins:netbox_contract:invoice_list',
link_text='Invoices',
buttons=invoice_buttons
buttons=invoice_buttons,
permissions=['netbox_contract.view_invoice']
)

service_provider_menu_item = PluginMenuItem(
link='plugins:netbox_contract:serviceprovider_list',
link_text='Service Providers',
buttons=serviceprovider_buttons
buttons=serviceprovider_buttons,
permissions=['netbox_contract.view_serviceprovider']
)

items = (contract_menu_item,invoices_menu_item,service_provider_menu_item)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load render_table from django_tables2 %}
{% if perms.netbox_contract.view_contract %}
<div class="row">
<div class="col col-md-12">
<div class="card">
Expand All @@ -8,12 +9,15 @@ <h5 class="card-header">Contracts Assignements</h5>
{% render_table assignements_table %}
</div>
{% endif %}
{% if perms.netbox_contract.add_contractassignement %}
<div class="card-footer text-end noprint">
<a href="{% url 'plugins:netbox_contract:contractassignement_add' %}?content_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-primary btn-sm">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
Add assignement
</a>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
4 changes: 3 additions & 1 deletion src/netbox_contract/templates/contract_list_bottom.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load render_table from django_tables2 %}
{% if perms.netbox_contract.view_contract %}
<div class="row">
<div class="col col-md-12">
<div class="card">
Expand All @@ -8,4 +9,5 @@ <h5 class="card-header">Contracts</h5>
</div>
</div>
</div>
</div>
</div>
{% endif %}
6 changes: 5 additions & 1 deletion src/netbox_contract/templates/netbox_contract/contract.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,24 @@ <h5 class="card-header">Assignements</h5>
</div>
</div>
</div>
{% if perms.netbox_contract.view_invoice %}
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Invoices</h5>
<div class="card-body table-responsive">
{% render_table invoices_table %}
</div>
{% if perms.netbox_contract.add_invoice %}
<div class="card-footer text-end noprint">
<a href="{% url 'plugins:netbox_contract:invoice_add' %}?contracts={{ object.pk }}" class="btn btn-primary btn-sm">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
Add an invoice
</a>
</div>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
{% endblock content %}

0 comments on commit 8431ef1

Please sign in to comment.