mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
Move ObjectContactsView to netbox.views.generic.feature_views
This commit is contained in:
parent
f8bb764a7d
commit
5945b27740
@ -661,7 +661,7 @@ def register_models(*models):
|
|||||||
# Register applicable feature views for the model
|
# Register applicable feature views for the model
|
||||||
if issubclass(model, ContactsMixin):
|
if issubclass(model, ContactsMixin):
|
||||||
register_model_view(model, 'contacts', kwargs={'model': model})(
|
register_model_view(model, 'contacts', kwargs={'model': model})(
|
||||||
'tenancy.views.ObjectContactsView'
|
'netbox.views.generic.ObjectContactsView'
|
||||||
)
|
)
|
||||||
if issubclass(model, JournalingMixin):
|
if issubclass(model, JournalingMixin):
|
||||||
register_model_view(model, 'journal', kwargs={'model': model})(
|
register_model_view(model, 'journal', kwargs={'model': model})(
|
||||||
|
@ -12,13 +12,19 @@ from core.tables import JobTable, ObjectChangeTable
|
|||||||
from extras.forms import JournalEntryForm
|
from extras.forms import JournalEntryForm
|
||||||
from extras.models import JournalEntry
|
from extras.models import JournalEntry
|
||||||
from extras.tables import JournalEntryTable
|
from extras.tables import JournalEntryTable
|
||||||
|
from tenancy.models import ContactAssignment
|
||||||
|
from tenancy.tables import ContactAssignmentTable
|
||||||
|
from tenancy.filtersets import ContactAssignmentFilterSet
|
||||||
|
from tenancy.forms import ContactAssignmentFilterForm
|
||||||
from utilities.permissions import get_permission_for_model
|
from utilities.permissions import get_permission_for_model
|
||||||
from utilities.views import ConditionalLoginRequiredMixin, GetReturnURLMixin, ViewTab
|
from utilities.views import ConditionalLoginRequiredMixin, GetReturnURLMixin, ViewTab
|
||||||
from .base import BaseMultiObjectView
|
from .base import BaseMultiObjectView
|
||||||
|
from .object_views import ObjectChildrenView
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'BulkSyncDataView',
|
'BulkSyncDataView',
|
||||||
'ObjectChangeLogView',
|
'ObjectChangeLogView',
|
||||||
|
'ObjectContactsView',
|
||||||
'ObjectJobsView',
|
'ObjectJobsView',
|
||||||
'ObjectJournalView',
|
'ObjectJournalView',
|
||||||
'ObjectSyncDataView',
|
'ObjectSyncDataView',
|
||||||
@ -244,3 +250,25 @@ class BulkSyncDataView(GetReturnURLMixin, BaseMultiObjectView):
|
|||||||
))
|
))
|
||||||
|
|
||||||
return redirect(self.get_return_url(request))
|
return redirect(self.get_return_url(request))
|
||||||
|
|
||||||
|
|
||||||
|
class ObjectContactsView(ObjectChildrenView):
|
||||||
|
child_model = ContactAssignment
|
||||||
|
table = ContactAssignmentTable
|
||||||
|
filterset = ContactAssignmentFilterSet
|
||||||
|
filterset_form = ContactAssignmentFilterForm
|
||||||
|
template_name = 'tenancy/object_contacts.html'
|
||||||
|
tab = ViewTab(
|
||||||
|
label=_('Contacts'),
|
||||||
|
badge=lambda obj: obj.get_contacts().count(),
|
||||||
|
permission='tenancy.view_contactassignment',
|
||||||
|
weight=5000
|
||||||
|
)
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
model = kwargs.pop('model')
|
||||||
|
self.queryset = model.objects.all()
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_children(self, request, parent):
|
||||||
|
return parent.get_contacts().restrict(request.user, 'view').order_by('priority', 'contact', 'role')
|
||||||
|
@ -1,36 +1,13 @@
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
from utilities.query import count_related
|
from utilities.query import count_related
|
||||||
from utilities.views import GetRelatedModelsMixin, ViewTab, register_model_view
|
from utilities.views import GetRelatedModelsMixin, register_model_view
|
||||||
from . import filtersets, forms, tables
|
from . import filtersets, forms, tables
|
||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
|
||||||
class ObjectContactsView(generic.ObjectChildrenView):
|
|
||||||
child_model = ContactAssignment
|
|
||||||
table = tables.ContactAssignmentTable
|
|
||||||
filterset = filtersets.ContactAssignmentFilterSet
|
|
||||||
filterset_form = forms.ContactAssignmentFilterForm
|
|
||||||
template_name = 'tenancy/object_contacts.html'
|
|
||||||
tab = ViewTab(
|
|
||||||
label=_('Contacts'),
|
|
||||||
badge=lambda obj: obj.get_contacts().count(),
|
|
||||||
permission='tenancy.view_contactassignment',
|
|
||||||
weight=5000
|
|
||||||
)
|
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
|
||||||
model = kwargs.pop('model')
|
|
||||||
self.queryset = model.objects.all()
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_children(self, request, parent):
|
|
||||||
return parent.get_contacts().restrict(request.user, 'view').order_by('priority', 'contact', 'role')
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tenant groups
|
# Tenant groups
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user