Changeset 1120
- Timestamp:
- 21 Dec 2006, 21:37:26 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/ScratchCards.py
r1082 r1120 137 137 % (doc.prefix,doc.batch_no), 138 138 )[-max_pins:] if not p.student] 139 ## used = [{'pin': p.pin,140 ## 'serial': p.serial,141 ## 'student': p.student,142 ## } for p in pins_cat.searchResults(prefix_batch = "%s%d"143 ## % (doc.prefix,doc.batch_no),144 ## ) if p.student]145 ## if len (unused) <= max_pins:146 ## return unused,used147 139 return unused 140 141 security.declareProtected(View,"getUsedPins") 142 def getUsedPins(self): 143 """return a list of used Pins""" 144 #import pdb;pdb.set_trace() 145 pins_cat = self.portal_pins 146 doc = self.getContent() 147 used = [{'pin': p.pin, 148 'prefix_batch': p.prefix_batch, 149 'serial': p.serial, 150 'student': p.student, 151 } for p in pins_cat.searchResults(prefix_batch = "%s%d" 152 % (doc.prefix,doc.batch_no), 153 ) if p.student] 154 return used 148 155 149 156 security.declareProtected(View,"getNumberOfUsedPins") -
WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt
r1012 r1120 25 25 /> 26 26 <br /> 27 28 29 30 27 <h3><span tal:replace="info/nr_used" /> Pins used out of 31 28 <span tal:replace="info/batch_doc/no_of_pins" /></h3> 32 33 29 <span tal:replace="structure rendered" /> 34 35 30 <table> 36 31 <tr tal:repeat="pin info/used"> 32 <td tal:content="python:path('repeat/pin/index')+1" /> 37 33 <td width="50px"> <span tal:content="pin/serial" />: </td> 38 34 <td tal:content="pin/pin" /> … … 45 41 </tr> 46 42 </table> 47 48 49 43 <br /> 50 51 44 <span tal:condition="python:member.id in ('admin','joachim')"> 52 45 ---top secret--- … … 59 52 ---top secret--- 60 53 </span> 61 62 63 54 </span> 64 55 </metal:main> -
WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py
r1070 r1120 20 20 #from Products.zdb import set_trace 21 21 #set_trace() 22 def set_used_pins(items, from_cat=False): 23 l = [] 24 for i in items: 25 item = {} 26 if from_cat: 27 sno = i.student 28 prefix = i.prefix_batch 29 serial = i.serial 30 pin = i.pin 31 else: 32 sno = i['student'] 33 prefix = i.get('prefix_batch') 34 serial = i.get('serial') 35 pin = i.get('pin') 36 item['student'] = sno 37 item['prefix'] = prefix 38 item['serial'] = serial 39 if len(sno) > 0: 40 item['pin'] = pin 41 else: 42 if str(member) in ('henrik','joachim'): 43 item['pin'] = "%s" % (pin,) 44 else: 45 item['pin'] = "%s%s****%s" % (i.prefix_batch,pin[-10:-7],pin[-3:]) 46 if len(sno)==10: 47 #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication') 48 res = context.students_catalog(jamb_reg_no=sno.upper()) 49 if len(res) > 0: 50 if sno.startswith('disabled'): 51 item['student_url'] = None 52 else: 53 item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id) 54 item['student_id'] = res[0].id 55 else: 56 item['student_url'] = None 57 item['student_id'] = '' 58 elif sno: 59 if sno.startswith('disabled'): 60 item['student_url'] = None 61 else: 62 item['student_url'] = '%s/campus/students/%s' % (context.portal_url(),item['student']) 63 item['student_id'] = item['student'] 64 else: 65 item['student_url'] = '' 66 item['student_id'] = "not used" 67 l.append(item) 68 return l 69 22 70 lt = context.portal_layouts 23 71 validate = request.has_key("cpsdocument_edit_button") … … 36 84 if context.portal_type == "ScratchCardBatch": 37 85 info['batch_doc'] = context.getContent() 86 info['used'] = set_used_pins(info['batch_doc'].getUsedPins()) 38 87 info['unused'] = info['batch_doc'].getUnusedPins() 39 88 info['nr_used'] = info['batch_doc'].getNumberOfUsedPins() … … 68 117 else: 69 118 items = [] 70 l = []71 119 ## students_url = "%s/%s" % (context.portal_url(),'students') 72 pins = []73 for i in items:74 item = {}75 sno = i['student']76 item['student'] = sno77 item['prefix'] = i.prefix_batch78 item['serial'] = i.serial79 if len(sno) > 0:80 item['pin'] = i.pin81 else:82 if str(member) in ('henrik','joachim'):83 item['pin'] = "%s" % (i.pin,)84 else:85 item['pin'] = "%s%s****%s" % (i.prefix_batch,i.pin[-10:-7],i.pin[-3:])86 if i.pin in pins:87 continue88 pins.append(i.pins)89 if len(sno)==10:90 #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')91 res = context.students_catalog(jamb_reg_no=sno.upper())92 if len(res) > 0:93 if sno.startswith('disabled'):94 item['student_url'] = None95 else:96 item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)97 item['student_id'] = res[0].id98 else:99 item['student_url'] = None100 item['student_id'] = ''101 elif sno:102 if sno.startswith('disabled'):103 item['student_url'] = None104 else:105 item['student_url'] = '%s/campus/students/%s' % (context.portal_url(),item['student'])106 item['student_id'] = item['student']107 else:108 item['student_url'] = ''109 item['student_id'] = "not used"110 l.append(item)111 120 112 info['used'] = l 121 info['used'] = set_used_pins(items,from_cat=True) 113 122 114 123 return view(rendered = rend,
Note: See TracChangeset for help on using the changeset viewer.