Przeglądaj źródła

added changelog views for Tag

John Anderson 7 lat temu
rodzic
commit
8e548605c8

+ 5 - 0
CHANGELOG.md

@@ -10,10 +10,15 @@ context data may observe a performance drop when returning multiple objects. To
 Config Context is not needed, the query parameter `?exclude=config_context` may be added to the request as to remove
 the Config Context from being included in any results.
 
+### Tag Permissions Changed
+
+NetBox now makes use of its own `Tag` model instead of the vanilla model which ships with django-taggit. This new model lives in the `extras` app and thus any permissions that you may have configured using "Taggit | Tag" should be changed to now use "Extras | Tag."
+
 ## Enhancements
 
 * [#2324](https://github.com/digitalocean/netbox/issues/2324) - Add color option for tags
 * [#2791](https://github.com/digitalocean/netbox/issues/2791) - Add a comment field for tags
+* [#2926](https://github.com/digitalocean/netbox/issues/2926) - Add changelog to the Tag model
 
 ---
 

+ 3 - 0
netbox/extras/models.py

@@ -881,6 +881,9 @@ class Tag(TagBase, ChangeLoggedModel):
         default=''
     )
 
+    def get_absolute_url(self):
+        return reverse('extras:tag', args=[self.slug])
+
 
 class TaggedItem(GenericTaggedItemBase):
     tag = models.ForeignKey(

+ 3 - 0
netbox/extras/tables.py

@@ -5,6 +5,9 @@ from utilities.tables import BaseTable, BooleanColumn, ColorColumn, ToggleColumn
 from .models import ConfigContext, ObjectChange, Tag, TaggedItem
 
 TAG_ACTIONS = """
+<a href="{% url 'extras:tag_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Changelog">
+    <i class="fa fa-history"></i>
+</a>
 {% if perms.taggit.change_tag %}
     <a href="{% url 'extras:tag_edit' slug=record.slug %}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
 {% endif %}

+ 3 - 0
netbox/extras/urls.py

@@ -1,6 +1,8 @@
 from django.conf.urls import url
 
 from extras import views
+from extras.models import Tag
+
 
 app_name = 'extras'
 urlpatterns = [
@@ -11,6 +13,7 @@ urlpatterns = [
     url(r'^tags/(?P<slug>[\w-]+)/$', views.TagView.as_view(), name='tag'),
     url(r'^tags/(?P<slug>[\w-]+)/edit/$', views.TagEditView.as_view(), name='tag_edit'),
     url(r'^tags/(?P<slug>[\w-]+)/delete/$', views.TagDeleteView.as_view(), name='tag_delete'),
+    url(r'^tags/(?P<slug>[\w-]+)/changelog/$', views.ObjectChangeLogView.as_view(), name='tag_changelog', kwargs={'model': Tag}),
 
     # Config contexts
     url(r'^config-contexts/$', views.ConfigContextListView.as_view(), name='configcontext_list'),

+ 9 - 0
netbox/templates/extras/tag.html

@@ -31,6 +31,15 @@
         {% endif %}
     </div>
     <h1>{% block title %}Tag: {{ tag }}{% endblock %}</h1>
+    {% include 'inc/created_updated.html' with obj=tag %}
+    <ul class="nav nav-tabs">
+        <li role="presentation"{% if not active_tab %} class="active"{% endif %}>
+            <a href="{{ tag.get_absolute_url }}">Tag</a>
+        </li>
+        <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
+            <a href="{% url 'extras:tag_changelog' slug=tag.slug %}">Changelog</a>
+        </li>
+    </ul>
 {% endblock %}
 
 {% block content %}