1 1 0
default
Branko Majic (branko) - 2 years ago 2017-12-22 11:35:31
branko@majic.rs
CONNT-25: Removed Django admin customisation: - Removed custom HTML template for Django Admin when adding a new communication. - Reimplemented limiting of source/destination to use filtering information passed-in by default from Django Admin.
2 files changed with 14 insertions and 26 deletions:
↑ Collapse Diff ↑
...
 
@@ -40,6 +40,10 @@
40 40
 
#
41 41
 

	
42 42
 

	
43
 
# Standard library imports.
44
 
from urlparse import parse_qsl
45
 

	
46
 

	
43 47
 
# Django imports.
44 48
 
from django.contrib import admin
45 49
 
from django.urls import resolve
...
 
@@ -230,22 +234,22 @@ class CommunicationAdmin(admin.ModelAdmi
230 234
 
          kwargs - Additional keyword arguments
231 235
 
        """
232 236
 

	
233
 
        # Resolve the view name based on the request's path.
234
 
        view_name = resolve(request.path).view_name
235
 

	
236 237
 
        # Only process the source and destination fields that point to
237 238
 
        # interfaces.
238 239
 
        if db_field.name == "source" or db_field.name == "destination":
239 240
 
            # Perform no filtering by default.
240 241
 
            interface_filter = {}
241 242
 

	
242
 
            # If project was specified in GET requests, add it as a filter.
243
 
            if 'project' in request.GET:
244
 
                interface_filter['entity__project'] = request.GET['project']
245
 
            # If location was specified in GET request, add it as a filter.
246
 
            if 'location' in request.GET:
247
 
                interface_filter['entity__location'] = request.GET['location']
248
 
            # If there are any filtering options for the show interfaces, apply them.
243
 
            # Parse the filter from URL GET parameter passed-in by the Django Admin.
244
 
            changelist_filters = dict(parse_qsl(request.GET.get('_changelist_filters', '')))
245
 

	
246
 
            # Apply project filter if requested.
247
 
            if 'project' in changelist_filters:
248
 
                interface_filter['entity__project'] = changelist_filters['project']
249
 
            # Apply location filter if requested.
250
 
            if 'location' in changelist_filters:
251
 
                interface_filter['entity__location'] = changelist_filters['location']
252
 
            # Apply our filters to queryset if there are any.
249 253
 
            if interface_filter:
250 254
 
                kwargs["queryset"] = Interface.objects.filter(**interface_filter)
251 255
 

	
conntrackt/templates/admin/conntrackt/communication/change_list.html
 
deleted file
0 comments (0 inline, 0 general)