Changeset 3076
- Timestamp:
- 31 Jan 2008, 18:29:58 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/ScratchCards.py
r2241 r3076 128 128 ###) 129 129 130 131 security.declareProtected(ModifyPortalContent,"getUnusedPins") 130 security.declareProtected(ModifyPortalContent,"archiveBatch") ###( 131 def archiveBatch(self,delete=False): 132 """archive a batch""" 133 #import pdb;pdb.set_trace() 134 batch = self.getContent() 135 member = self.portal_membership.getAuthenticatedMember() 136 logger = logging.getLogger('ScratchCards.archiveBatch') 137 nr = batch.no_of_pins 138 prefix = batch.prefix 139 sold = batch.sold_by 140 cost = batch.cost 141 batch_no = batch.batch_no 142 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 143 export_file = "%s/export/%s-%s_archive_%s.csv" % (i_home,prefix,batch_no,current) 144 lines = [] 145 fields = ['prefix','cost','serial','pin','student'] 146 headline = ','.join(fields) 147 out = open(export_file,"wb") 148 out.write(headline +'\n') 149 out.write('%(prefix)s,%(cost)8.2f,%(batch_no)d,%(nr)d,%(sold)s\n' % vars()) 150 out.close() 151 out = open(export_file,"a") 152 csv_writer = csv.DictWriter(out,fields,) 153 pins = self.portal_pins(prefix_batch = "%(prefix)s%(batch_no)d" % vars()) 154 logger.info('%s starts archiving %s_%s with %s records ' % (member, 155 prefix, 156 batch_no, 157 len(pins))) 158 159 pin_list = [] 160 for pin in pins: 161 pin_list += pin.pin, 162 lines.append(self.portal_pins.record2dict(fields,pin)) 163 total = len(lines) 164 csv_writer.writerows(lines) 165 msg = "wrote %(total)d records to %(export_file)s" % vars() 166 logger.info(msg) 167 if delete: 168 for pin in pin_list: 169 self.deleteRecord(pin) 170 msg = "deleted %(total)d pin from pins_catalog" % len(pin_list) 171 logger.info(msg) 172 ###) 173 174 security.declareProtected(ModifyPortalContent,"getUnusedPins") ###( 132 175 def getUnusedPins(self): 133 176 """return a list of unused Pins""" … … 144 187 return unused[-max_pins:] 145 188 return unused 146 147 security.declareProtected(View,"getUsedPins") 189 ###) 190 191 security.declareProtected(View,"getUsedPins") ###( 148 192 def getUsedPins(self): 149 193 """return a list of used Pins""" … … 159 203 ) if p.student] 160 204 return used 161 162 security.declareProtected(View,"getNumberOfUsedPins") 205 ###) 206 207 security.declareProtected(View,"getNumberOfUsedPins") ###( 163 208 def getNumberOfUsedPins(self): 164 209 """return the number of used Pins""" … … 173 218 ) if p.student] 174 219 return len(used) 220 ###) 175 221 176 222 InitializeClass(ScratchCardBatch) -
WAeUP_SRP/base/skins/waeup_pins/pins_view.pt
r2766 r3076 56 56 <br /> 57 57 <h3>PIN Batches</h3> 58 <br /> 59 <form action="." method="get"> 58 <form action="." method="post" class="group" 59 tal:define="rows info/batches; 60 choosen_ids info/choosen_ids|python:[]" 61 > 62 <table class="contentListing" width="100%"> 63 <tr tal:repeat="line rows" 64 tal:attributes="class python:test(repeat['line'].even(), 'even ajaxtd', 'odd ajaxtd')"> 65 <span tal:repeat="row line"> 66 <td align="left" valign="middle" style="width: 5px;"> 67 <input type="checkbox" name="ids:list" value="" id="" class="noborder" 68 tal:define="id row" 69 tal:attributes="value id; 70 id python:'cb_' + id; 71 checked python:id in choosen_ids;" 72 /> 73 </td> 74 <td><a href="view" tal:attributes="href string:${context/absolute_url}/${row}"> 75 <strong tal:content="row" /></a> </td> 76 </span> 77 </tr> 78 </table> 79 <table width="100%" cellspacing="0" cellpadding="2" 80 class="folderButtons"> 81 <tr> 82 <td align="left" valign="top" rowspan="3"></td> 83 <td align="left" valign="top"> 84 <input tal:condition="nothing" type="button" value="button_select_all" class="context" 85 onclick="someJavaScriptFunctionThatWillBeReplaced" 86 i18n:attributes="value" 87 tal:attributes="onclick python:'toggleSelect(this, \'%s\', \'%s\')' 88 % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))" 89 /> 90 <input type="submit" name="archive:method" value="archive" 91 class="destructive" i18n:attributes="value" 92 tal:attributes="onclick python:'return window.confirm(\'%s\')' % 93 ('confirm archive', )" 94 /> 95 <input type="submit" name="archive_delete:method" value="archive + delete" 96 class="destructive" i18n:attributes="value" 97 tal:attributes="onclick python:'return window.confirm(\'%s\')' % 98 ('confirm archive and delete', )" 99 /> 100 </td> 101 </tr> 102 </table> 103 </form> 104 <form action="." method="get" tal:condition="nothing"> 60 105 <select class="form-element" name=":action" 61 106 tal:attributes="onChange string:location.href='${context/absolute_url}/'+this.options[this.selectedIndex].value" -
WAeUP_SRP/base/skins/waeup_pins/search_pins.py
r2766 r3076 12 12 list Students for ClearanceOfficers 13 13 """ 14 try: 15 from Products.zdb import set_trace 16 except: 17 def set_trace(): 18 pass 14 19 15 20 request = REQUEST … … 111 116 batches = context.objectIds() 112 117 batches.sort() 113 info['batches'] = batches 118 l = [] 119 cols = 6 120 rows,rest = divmod(len(batches),cols) 121 for r in range(rows): 122 von = r*cols 123 l += batches[von:von+cols], 124 if rest: 125 von = r*cols + cols 126 l += batches[von:von+rest], 127 info['batches'] = l 114 128 view = context.pins_view 115 129 if psm == '':
Note: See TracChangeset for help on using the changeset viewer.