Skip to content

Conversation

@rhyser9
Copy link
Contributor

@rhyser9 rhyser9 commented Nov 14, 2021

Fixes: #7729

Using the render_table tag attaches the calling template's context to the table object, thus allowing the vid TemplateColumn to properly evaluate the perms.ipam.add_vlan check.

VLAN_LINK = """
{% if record.pk %}
<a href="{{ record.get_absolute_url }}">{{ record.vid }}</a>
{% elif perms.ipam.add_vlan %}
<a href="{% url 'ipam:vlan_add' %}?vid={{ record.vid }}{% if record.vlan_group %}&group={{ record.vlan_group.pk }}{% endif %}" class="btn btn-sm btn-success">{{ record.available }} VLAN{{ record.available|pluralize }} available</a>
{% else %}
{{ record.available }} VLAN{{ record.available|pluralize }} available
{% endif %}
"""

See the note at https://django-tables2.readthedocs.io/en/latest/pages/template-tags.html#render-table

@jeremystretch jeremystretch merged commit 496cabc into netbox-community:develop Nov 15, 2021
@rhyser9 rhyser9 changed the title Fix #7229: Fix context of VLAN table in VLAN Group view Fix #7729: Fix context of VLAN table in VLAN Group view Nov 15, 2021
@rhyser9
Copy link
Contributor Author

rhyser9 commented Nov 15, 2021

Apologies, just realized I marked the issue as #7229 rather than #7729, my bad.

@jeremystretch
Copy link
Member

Whoops, I missed it as well. No problem!

@rhyser9 rhyser9 deleted the 7229_bug_add_vlans_link branch November 18, 2021 19:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VlanGroup view 'add' vlan buttons broken

2 participants