Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- comcenter = get_object_or_404(ComCenter, id = comcenter_id)
- hardware = []
- racks = []
- pow_cable = []
- for hw in Hardware.objects.filter(comcenter__id = comcenter_id, hardwaremodel__is_module = False):
- title = hw.hardwaremodel.title
- if hw.description:
- title += ' ' + hw.description
- if hw.rackplace:
- hardware.append({
- 'id': hw.id,
- 'is_face': hw.rackplace.is_face,
- 'first_screw': hw.rackplace.first_screw, #для упорядочивания оборудования
- 'rack_id': hw.rackplace.rack.id,
- 'num_psu': hw.num_psu,
- 'title': title,
- })
- else:
- hardware.append({
- 'id': hw.id,
- 'is_face': '',
- 'first_screw': '',
- 'rack_id': '',
- 'num_psu': hw.num_psu,
- 'title': title,
- })
- for power_cable in hw.power_sources.all():
- pow_cable.append({
- 'source_id': power_cable.source.id,
- 'consumer_id': hw.id,
- })
- for rk in Rack.objects.filter(comcenter__id = comcenter_id):
- racks.append({
- 'id': rk.id,
- 'title': rk.title,
- 'fromtop': rk.fromtop,
- })
- response = {'ck_title': comcenter.title, 'racks': list(racks), 'hardware': list(hardware), 'power_cable': list(pow_cable)}
Advertisement
Add Comment
Please, Sign In to add comment