mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
dcim: make front and rear work (references #2248)
This commit is contained in:
parent
d11de6d021
commit
808f5c95e3
@ -3,7 +3,7 @@ from collections import OrderedDict
|
||||
import svgwrite
|
||||
from django.conf import settings
|
||||
from django.db.models import Count, F
|
||||
from django.http import HttpResponseForbidden, HttpResponse
|
||||
from django.http import HttpResponseForbidden, HttpResponseBadRequest, HttpResponse
|
||||
from django.shortcuts import get_object_or_404, reverse
|
||||
from django.utils.http import urlencode
|
||||
from drf_yasg import openapi
|
||||
@ -218,7 +218,13 @@ class RackElevationViewSet(ViewSet):
|
||||
"""
|
||||
rack = get_object_or_404(Rack, pk=pk)
|
||||
|
||||
elevation = rack.get_front_elevation()
|
||||
side = request.GET.get('face', 'front')
|
||||
if side == 'front':
|
||||
elevation = rack.get_front_elevation()
|
||||
elif side == 'rear':
|
||||
elevation = rack.get_rear_elevation()
|
||||
else:
|
||||
return HttpResponseBadRequest('side should either be "front" or "back".')
|
||||
drawing = svgwrite.Drawing(size=(230, len(elevation)*20), style="box-sizing: border-box")
|
||||
|
||||
for i, u in enumerate(elevation):
|
||||
|
@ -8,6 +8,6 @@
|
||||
|
||||
<div class="rack_frame">
|
||||
|
||||
<img src="{% url 'dcim-api:rack-elevation-detail' pk=rack.pk %}" height="100%">
|
||||
<img src="{% url 'dcim-api:rack-elevation-detail' pk=rack.pk %}?face={{face}}" height="100%">
|
||||
|
||||
</div>
|
||||
|
@ -317,13 +317,13 @@
|
||||
<div class="rack_header">
|
||||
<h4>Front</h4>
|
||||
</div>
|
||||
{% include 'dcim/inc/rack_elevation.html' with primary_face=front_elevation secondary_face=rear_elevation face_id=0 reserved_units=rack.get_reserved_units %}
|
||||
{% include 'dcim/inc/rack_elevation.html' with face="front" %}
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-6 col-xs-12">
|
||||
<div class="rack_header">
|
||||
<h4>Rear</h4>
|
||||
</div>
|
||||
{% include 'dcim/inc/rack_elevation.html' with primary_face=rear_elevation secondary_face=front_elevation face_id=1 reserved_units=rack.get_reserved_units %}
|
||||
{% include 'dcim/inc/rack_elevation.html' with face="rear" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
|
Loading…
Reference in New Issue
Block a user