aklim007

temp2

Jun 25th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. comcenter = get_object_or_404(ComCenter, id = comcenter_id)
  2.  
  3. hardware = []
  4. racks = []
  5. pow_cable = []
  6. for hw in Hardware.objects.filter(comcenter__id = comcenter_id, hardwaremodel__is_module = False):
  7.     title = hw.hardwaremodel.title
  8.     if hw.description:
  9.         title += ' ' + hw.description
  10.     if hw.rackplace:
  11.         hardware.append({
  12.             'id': hw.id,
  13.             'is_face': hw.rackplace.is_face,
  14.             'first_screw': hw.rackplace.first_screw, #для упорядочивания оборудования
  15.             'rack_id': hw.rackplace.rack.id,
  16.             'num_psu': hw.num_psu,
  17.             'title': title,
  18.         })
  19.     else:
  20.         hardware.append({
  21.             'id': hw.id,
  22.             'is_face': '',
  23.             'first_screw': '',
  24.             'rack_id': '',
  25.             'num_psu': hw.num_psu,
  26.             'title': title,
  27.         })
  28.    
  29.    
  30.     for power_cable in hw.power_sources.all():
  31.         pow_cable.append({
  32.             'source_id': power_cable.source.id,
  33.             'consumer_id': hw.id,
  34.         })
  35.        
  36. for rk in Rack.objects.filter(comcenter__id = comcenter_id):
  37.     racks.append({
  38.         'id': rk.id,
  39.         'title': rk.title,
  40.         'fromtop': rk.fromtop,
  41.     })
  42. 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