1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #5873: Use numeric IDs in all object URLs

This commit is contained in:
Jeremy Stretch
2021-02-26 17:23:23 -05:00
parent 1dcd857ca6
commit 6a9b50f95d
37 changed files with 97 additions and 126 deletions

View File

@ -147,24 +147,23 @@ class ButtonsColumn(tables.TemplateColumn):
# Note that braces are escaped to allow for string formatting prior to template rendering
template_code = """
{{% if "changelog" in buttons %}}
<a href="{{% url '{app_label}:{model_name}_changelog' {pk_field}=record.{pk_field} %}}" class="btn btn-default btn-xs" title="Change log">
<a href="{{% url '{app_label}:{model_name}_changelog' pk=record.pk %}}" class="btn btn-default btn-xs" title="Change log">
<i class="mdi mdi-history"></i>
</a>
{{% endif %}}
{{% if "edit" in buttons and perms.{app_label}.change_{model_name} %}}
<a href="{{% url '{app_label}:{model_name}_edit' {pk_field}=record.{pk_field} %}}?return_url={{{{ request.path }}}}{{{{ return_url_extra }}}}" class="btn btn-xs btn-warning" title="Edit">
<a href="{{% url '{app_label}:{model_name}_edit' pk=record.pk %}}?return_url={{{{ request.path }}}}{{{{ return_url_extra }}}}" class="btn btn-xs btn-warning" title="Edit">
<i class="mdi mdi-pencil"></i>
</a>
{{% endif %}}
{{% if "delete" in buttons and perms.{app_label}.delete_{model_name} %}}
<a href="{{% url '{app_label}:{model_name}_delete' {pk_field}=record.{pk_field} %}}?return_url={{{{ request.path }}}}{{{{ return_url_extra }}}}" class="btn btn-xs btn-danger" title="Delete">
<a href="{{% url '{app_label}:{model_name}_delete' pk=record.pk %}}?return_url={{{{ request.path }}}}{{{{ return_url_extra }}}}" class="btn btn-xs btn-danger" title="Delete">
<i class="mdi mdi-trash-can-outline"></i>
</a>
{{% endif %}}
"""
def __init__(self, model, *args, pk_field='pk', buttons=None, prepend_template=None, return_url_extra='',
**kwargs):
def __init__(self, model, *args, buttons=None, prepend_template=None, return_url_extra='', **kwargs):
if prepend_template:
prepend_template = prepend_template.replace('{', '{{')
prepend_template = prepend_template.replace('}', '}}')
@ -173,7 +172,6 @@ class ButtonsColumn(tables.TemplateColumn):
template_code = self.template_code.format(
app_label=model._meta.app_label,
model_name=model._meta.model_name,
pk_field=pk_field,
buttons=buttons
)