Loading services/admin.py +14 −4 Original line number Diff line number Diff line Loading @@ -193,6 +193,11 @@ class AllocationInline(admin.TabularInline): show_change_link = True ordering = ('-start',) def resource_link(self, obj): url = reverse('admin:services_ipresource_change', args=[obj.resource.pk]) return format_html('<a href="{}">{}</a>', url, str(obj.resource)) resource_link.short_description = 'IP' def get_queryset(self, request): qs = super().get_queryset(request) qs = qs.select_related('resource') Loading Loading @@ -237,6 +242,11 @@ class ServiceAllocationMixin: raw_id_fields = ('resource',) autocomplete_fields = ('service',) def service_link(self, obj): url = reverse('admin:services_service_change', args=[obj.service.pk]) return format_html('<a href="{}">{}</a>', url, str(obj.service)) service_link.short_description = 'Service' def get_queryset(self, request): qs = super().get_queryset(request) qs = qs.select_related('route') Loading @@ -260,8 +270,8 @@ class NewServiceAllocationInline(ServiceAllocationMixin, NewAllocationMixin, All class ActiveServiceAllocationInline(ServiceAllocationMixin, ActiveAllocationMixin, AllocationInline): fields = ('id', 'service', 'resource', 'route', 'start', 'stop',) readonly_fields = ('service', 'start', 'resource', 'stop',) fields = ('id', 'service_link', 'resource_link', 'route', 'start', 'stop',) readonly_fields = ('service_link', 'start', 'resource_link', 'stop',) def stop(self, obj): return format_html('<a href="{}" class="deletelink">Terminer</a>', reverse('admin:stop-allocation', kwargs={'resource': obj.resource.ip})) Loading @@ -269,8 +279,8 @@ class ActiveServiceAllocationInline(ServiceAllocationMixin, ActiveAllocationMixi class InactiveServiceAllocationInline(ServiceAllocationMixin, InactiveAllocationMixin, AllocationInline): fields = ('id', 'service', 'resource', 'route', 'start', 'end') readonly_fields = ('service', 'resource', 'route', 'start', 'end') fields = ('id', 'service_link', 'resource_link', 'route', 'start', 'end') readonly_fields = ('service_link', 'resource_link', 'route', 'start', 'end') #class ActiveAntennaAllocationInline(AntennaAllocationMixin, ActiveAllocationMixin, AllocationInline): Loading Loading
services/admin.py +14 −4 Original line number Diff line number Diff line Loading @@ -193,6 +193,11 @@ class AllocationInline(admin.TabularInline): show_change_link = True ordering = ('-start',) def resource_link(self, obj): url = reverse('admin:services_ipresource_change', args=[obj.resource.pk]) return format_html('<a href="{}">{}</a>', url, str(obj.resource)) resource_link.short_description = 'IP' def get_queryset(self, request): qs = super().get_queryset(request) qs = qs.select_related('resource') Loading Loading @@ -237,6 +242,11 @@ class ServiceAllocationMixin: raw_id_fields = ('resource',) autocomplete_fields = ('service',) def service_link(self, obj): url = reverse('admin:services_service_change', args=[obj.service.pk]) return format_html('<a href="{}">{}</a>', url, str(obj.service)) service_link.short_description = 'Service' def get_queryset(self, request): qs = super().get_queryset(request) qs = qs.select_related('route') Loading @@ -260,8 +270,8 @@ class NewServiceAllocationInline(ServiceAllocationMixin, NewAllocationMixin, All class ActiveServiceAllocationInline(ServiceAllocationMixin, ActiveAllocationMixin, AllocationInline): fields = ('id', 'service', 'resource', 'route', 'start', 'stop',) readonly_fields = ('service', 'start', 'resource', 'stop',) fields = ('id', 'service_link', 'resource_link', 'route', 'start', 'stop',) readonly_fields = ('service_link', 'start', 'resource_link', 'stop',) def stop(self, obj): return format_html('<a href="{}" class="deletelink">Terminer</a>', reverse('admin:stop-allocation', kwargs={'resource': obj.resource.ip})) Loading @@ -269,8 +279,8 @@ class ActiveServiceAllocationInline(ServiceAllocationMixin, ActiveAllocationMixi class InactiveServiceAllocationInline(ServiceAllocationMixin, InactiveAllocationMixin, AllocationInline): fields = ('id', 'service', 'resource', 'route', 'start', 'end') readonly_fields = ('service', 'resource', 'route', 'start', 'end') fields = ('id', 'service_link', 'resource_link', 'route', 'start', 'end') readonly_fields = ('service_link', 'resource_link', 'route', 'start', 'end') #class ActiveAntennaAllocationInline(AntennaAllocationMixin, ActiveAllocationMixin, AllocationInline): Loading