Last change
on this file since 1447 was
1438,
checked in by Henrik Bettermann, 18 years ago
|
bed statistics and folder view separated
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1438] | 1 | ## Script (Python) "getBedStatistics"
|
---|
| 2 | ##bind container=container
|
---|
| 3 | ##bind context=context
|
---|
| 4 | ##bind namespace=
|
---|
| 5 | ##bind script=script
|
---|
| 6 | ##bind subpath=traverse_subpath
|
---|
| 7 | ##parameters=student=None
|
---|
| 8 | ##title=
|
---|
| 9 | ##
|
---|
| 10 | # $Id: getAccoFolderInfo.py 1301 2007-01-15 12:00:30Z joachim $
|
---|
| 11 |
|
---|
| 12 | pa = context.portal_accommodation
|
---|
| 13 | bed_types = pa.uniqueValuesFor('bed_type')
|
---|
| 14 | bt_list = []
|
---|
| 15 | bt_names = context.getBedTypeNames()
|
---|
| 16 | res = pa.uniqueValuesFor('student')
|
---|
| 17 | reserved = [st for st in res if st]
|
---|
| 18 | sum_total = 0
|
---|
| 19 | sum_occupied = 0
|
---|
| 20 | info = {}
|
---|
| 21 | #from Products.zdb import set_trace;set_trace()
|
---|
| 22 | for bt in bed_types:
|
---|
| 23 | total = len(pa(bed_type=bt))
|
---|
| 24 | sum_total += total
|
---|
| 25 | occupied = len(pa.searchResults({'bed_type': bt,'student':reserved}))
|
---|
| 26 | sum_occupied += occupied
|
---|
| 27 | bt_list.append({'name': bt_names[bt],
|
---|
| 28 | 'total': total,
|
---|
| 29 | 'reserved': occupied,
|
---|
| 30 | 'full': occupied == total,
|
---|
| 31 | })
|
---|
| 32 | bt_list.append({'name': "All Categories",
|
---|
| 33 | 'total': sum_total,
|
---|
| 34 | 'reserved': sum_occupied,
|
---|
| 35 | })
|
---|
| 36 | info['bed_types'] = bt_list
|
---|
| 37 | reserved = pa.uniqueValuesFor('student')
|
---|
| 38 | res_list = []
|
---|
| 39 | if reserved > 1:
|
---|
| 40 | for st in reserved:
|
---|
| 41 | if st:
|
---|
| 42 | res = pa(student=st)
|
---|
| 43 | res_list.append({'student': st, 'bed': res[0].bed })
|
---|
| 44 | info['reserved'] = res_list
|
---|
| 45 | return info |
---|
Note: See
TracBrowser for help on using the repository browser.