Skip to content

Commit

Permalink
Some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps committed Nov 21, 2021
1 parent d7dbe20 commit cdcc6ef
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
10 changes: 6 additions & 4 deletions netbox_secretstore/template_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ def right_page(self):
obj = self.context['object']

secrets = None
if ContentType.objects.get_for_model(obj).name == 'device':
secrets = Secret.objects.filter(device=obj)
elif ContentType.objects.get_for_model(obj).name == 'virtualmachine':
secrets = Secret.objects.filter(virtualmachine=obj)
ctype = ContentType.objects.get_for_model(obj)
if ctype.model == 'device':
secrets = Secret.objects.filter(assigned_object_id=obj.pk, assigned_object_type=ctype)
elif ctype.model == 'virtualmachine':
secrets = Secret.objects.filter(assigned_object_id=obj.pk, assigned_object_type=ctype)

return self.render('netbox_secretstore/inc/device_secrets.html', extra_context={
'secrets': secrets,
'type': ctype.model if ctype.model == 'device' else ctype.name.replace(' ', '_'),
})


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h5 class="card-header">
</div>
{% if perms.netbox_secretstore.add_secret %}
<div class="card-footer text-end noprint">
<a href="{% url 'plugins:netbox_secretstore:secret_add' %}?device={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-sm btn-primary">
<a href="{% url 'plugins:netbox_secretstore:secret_add' %}?{{ type }}={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-sm btn-primary">
<i class="mdi mdi-plus-thick"></i> Add Secret
</a>
</div>
Expand Down
58 changes: 29 additions & 29 deletions netbox_secretstore/templates/netbox_secretstore/secret_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@
{{ form.private_key }}
<div class="field-group">
<h4>Secret Assignment</h4>
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item" role="presentation">
<button
role="tab"
type="button"
id="device_tab"
data-bs-toggle="tab"
class="nav-link{% if not vm_tab_active %} active{% endif %}"
data-bs-target="#device"
aria-controls="device"
>
Device
</button>
</li>
<li class="nav-item" role="presentation">
<button
role="tab"
type="button"
id="vm_tab"
data-bs-toggle="tab"
class="nav-link{% if vm_tab_active %} active{% endif %}"
data-bs-target="#virtualmachine"
aria-controls="virtualmachine"
>
Virtual Machine
</button>
</li>
</ul>
<div class="tab-content">
{% with vm_tab_active=form.initial.virtual_machine %}
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item" role="presentation">
<button
role="tab"
type="button"
id="device_tab"
data-bs-toggle="tab"
class="nav-link{% if not vm_tab_active %} active{% endif %}"
data-bs-target="#device"
aria-controls="device"
>
Device
</button>
</li>
<li class="nav-item" role="presentation">
<button
role="tab"
type="button"
id="vm_tab"
data-bs-toggle="tab"
class="nav-link{% if vm_tab_active %} active{% endif %}"
data-bs-target="#virtualmachine"
aria-controls="virtualmachine"
>
Virtual Machine
</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane{% if not vm_tab_active %} active{% endif %}" id="device">
{% render_field form.device %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='netbox-secretstore',
version='1.0.9',
version='1.0.10',
description='Netbox Secret Store',
long_description='A Secret store for NetBox',
url='https://github.com/dansheps/netbox-secretstore/',
Expand Down

0 comments on commit cdcc6ef

Please sign in to comment.