Changeset 3415 for WAeUP_SRP/base
- Timestamp:
- 3 Apr 2008, 16:12:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/ScratchCards.py
r3077 r3415 128 128 ###) 129 129 130 security.declareProtected(ModifyPortalContent,"restorePins") ###( 131 def restorePins(self): 132 "restore Pins from file named pins_to_restore.csv" 133 pins = self.portal_pins 134 filename = "%s/export/pins_to_restore.csv" % (i_home) 135 logger = logging.getLogger('ScratchCards.restore') 136 if not os.path.exists(filename): 137 logger.info('no file %s' % filename) 138 return 139 src = open(filename,"rb") 140 records = csv.DictReader(src) 141 cards = [] 142 already_in = [] 143 #import pdb;pdb.set_trace() 144 records.next() 145 for record in records: 146 d = {} 147 d['pin'] = record['Pin'].replace('-','') 148 if pins(pin=d['pin']): 149 logger.info("pin %(pin)s already in Pins" % d) 150 already_in += d['pin'], 151 continue 152 d['serial'] = record['Serial'] 153 d['cost'] = record['Cost'] 154 d['prefix_batch'] = "".join(record['Pin'].split('-')[:2]) 155 cards += d, 156 if already_in: 157 logger.info("found %d existing pins in %s" % (len(already_in),filename)) 158 return 159 anz = len(cards) 160 logger.info("start restoring %d pins from %s" % (anz,filename)) 161 for card in cards: 162 pins.addRecord(**card) 163 logger.info("sucessfully restored %d pins from %s" % (anz,filename)) 164 url = self.REQUEST.get('URL1') 165 return self.REQUEST.RESPONSE.redirect(url) 166 130 167 security.declareProtected(ModifyPortalContent,"archiveBatch") ###( 131 168 def archiveBatch(self,delete=False): … … 170 207 msg = "deleted %d pin from portal_pins" % len(pin_list) 171 208 logger.info(msg) 209 url = self.REQUEST.get('URL1') 210 return self.REQUEST.RESPONSE.redirect(url) 172 211 ###) 173 212
Note: See TracChangeset for help on using the changeset viewer.