Ignore:
Timestamp:
16 Jun 2011, 21:06:35 (14 years ago)
Author:
uli
Message:

More stuff to remove.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py

    r6383 r6386  
    2020    grok.implements(IAccessCode)
    2121
    22     def __init__(self, batch_serial, random_num, invalidation_date=None,
    23                  student_id=None, disabled=False):
     22    def __init__(self, batch_serial, random_num):
    2423        self.batch_serial = batch_serial
    2524        self.random_num = random_num
    26         self._invalidation_date = invalidation_date
    27         self.student_id = student_id
    28         self._disabled = disabled
    2925        IWorkflowInfo(self).fireTransition('init')
    3026
     
    5551            return None
    5652        return self.batch.cost
    57 
    58     @property
    59     def invalidation_date(self):
    60         # We define this as a property to make it unwritable.
    61         # This attribute should be set by the surrounding batch only.
    62         return self._invalidation_date
    63 
    64     @property
    65     def disabled(self):
    66         # We define this as a property to make it unwritable.
    67         # This attribute should be set by the surrounding batch only.
    68         return self._disabled
    6953
    7054class AccessCodeBatch(grok.Model):
     
    8670        self._entries = list()
    8771        self._acids = OIBTree()
    88         self._studids = OIBTree()
    8972        self._createEntries()
    9073
     
    9477        for num, pin in enumerate(self._getNewRandomNum(num=self.entry_num)):
    9578            self.addAccessCode(num, pin)
    96         self._p_changed = True # XXX: most probably not needed.
    9779        return
    9880
     
    133115        return self._entries[self._acids[ac_id]]
    134116
    135     def getAccessCodeForStudentId(self, stud_id):
    136         """Get any AccessCode invalidated for ``stud_id`` or ``KeyError``.
    137         """
    138         return self._entries[self._studids[stud_id]]
    139 
    140117    def addAccessCode(self, num, pin):
    141118        """Add an access-code.
     
    151128        """
    152129        num = self._acids[ac_id]
    153         ac = self.getAccessCode(ac_id)
    154         ac._invalidation_date = datetime.now()
    155         ac.student_id = student_id
    156         if student_id is not None:
    157             self._studids.update({student_id: num})
    158130        self.invalidated_num += 1
    159131
     
    168140        if ac._disabled == True:
    169141            return
    170         ac._disabled = True
    171         old_student_id = ac.student_id
    172         if old_student_id is not None:
    173             del self._studids[old_student_id]
    174             self._studids.update({user_id: num})
    175         ac.student_id = user_id
    176         ac._invalidation_date = datetime.now()
    177142        self.disabled_num += 1
    178143
     
    184149        """
    185150        num = self._acids[ac_id]
    186         ac = self.getAccessCode(ac_id)
    187         if ac._disabled == False:
    188             return
    189         ac.student_id = None
    190         ac._disabled = False
    191         ac._invalidation_date = None
    192151        self.disabled_num -= 1
    193152
     
    234193            )
    235194        writer = csv.writer(open(csv_path, 'w'), quoting=csv.QUOTE_ALL)
    236         writer.writerow(['prefix', 'serial', 'ac', 'student', 'date'])
     195        writer.writerow(['prefix', 'serial', 'ac', 'date'])
    237196        writer.writerow([self.prefix, '%0.2f' % self.cost, str(self.num),
    238197                         str(self.entry_num)])
    239198        for value in self._entries:
    240             date = ''
    241             if value.invalidation_date is not None:
    242                 date = value.invalidation_date.strftime(
    243                     '%Y-%m-%d-%H-%M-%S')
    244199            writer.writerow([
    245200                    self.prefix, value.batch_serial, value.representation,
    246                     value.student_id, date
    247201                    ])
    248202        return os.path.basename(csv_path)
     
    259213            except KeyError:
    260214                return []
    261         if searchtype != 'stud_id':
    262             return []
    263         try:
    264             entry = self.getAccessCodeForStudentId(searchterm)
    265             return [entry]
    266         except KeyError:
    267             pass
    268         return []
    269215
    270216class AccessCodeBatchContainer(grok.Container):
Note: See TracChangeset for help on using the changeset viewer.