Arthur 3 лет назад
Родитель
Сommit
9fddd193b9
2 измененных файлов с 14 добавлено и 0 удалено
  1. 4 0
      netbox/netbox/views/generic/object_views.py
  2. 10 0
      netbox/tenancy/views.py

+ 4 - 0
netbox/netbox/views/generic/object_views.py

@@ -327,6 +327,9 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
         """
         """
         return obj
         return obj
 
 
+    def get_extra_addanother_params(self, request, params: dict):
+        return params
+
     #
     #
     # Request handlers
     # Request handlers
     #
     #
@@ -399,6 +402,7 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
 
 
                     # If cloning is supported, pre-populate a new instance of the form
                     # If cloning is supported, pre-populate a new instance of the form
                     params = prepare_cloned_fields(obj)
                     params = prepare_cloned_fields(obj)
+                    params = self.get_extra_addanother_params(request, params)
                     if params:
                     if params:
                         if 'return_url' in request.GET:
                         if 'return_url' in request.GET:
                             params['return_url'] = request.GET.get('return_url')
                             params['return_url'] = request.GET.get('return_url')

+ 10 - 0
netbox/tenancy/views.py

@@ -1,4 +1,5 @@
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
+from django.http import QueryDict
 from django.shortcuts import get_object_or_404
 from django.shortcuts import get_object_or_404
 
 
 from circuits.models import Circuit
 from circuits.models import Circuit
@@ -365,6 +366,15 @@ class ContactAssignmentEditView(generic.ObjectEditView):
             instance.object = get_object_or_404(content_type.model_class(), pk=request.GET.get('object_id'))
             instance.object = get_object_or_404(content_type.model_class(), pk=request.GET.get('object_id'))
         return instance
         return instance
 
 
+    def get_extra_addanother_params(self, request, params: dict):
+        if not params:
+            params = QueryDict(mutable=True)
+
+        params['content_type'] = request.GET.get('content_type')
+        params['object_id'] = request.GET.get('object_id')
+
+        return params
+
 
 
 class ContactAssignmentDeleteView(generic.ObjectDeleteView):
 class ContactAssignmentDeleteView(generic.ObjectDeleteView):
     queryset = ContactAssignment.objects.all()
     queryset = ContactAssignment.objects.all()