- Timestamp:
- 2 Jul 2011, 02:30:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py
r6495 r6499 25 25 class AccessCode(grok.Model): 26 26 """An access code (aka PIN). 27 28 Implements 29 :class:`waeup.sirp.accesscodes.interfaces.IAccessCode`. :class:`AccessCode` 30 instances are normally part of an :class:`AccessCodeBatch` so 31 their representation (or code) is built with the containing batch 32 involved. 33 34 `batch_serial` 35 the serial number of the new :class:`AccessCode` inside its batch. 36 37 `random_num` 38 a 10-digit number representing the main part of the code. 39 40 :class:`AccessCode` instances normally have a representation (or 41 code) like 42 43 ``APP-XXX-YYYYYYYYYY`` 44 45 where ``APP`` is the prefix of the containing batch, ``XXX`` is 46 the batch number and ``YYYYYYYYYY`` is the real code. The complete 47 PIN is portal-wide unique. 48 49 Access code instances are far more than simple strings. They have 50 a state, a history (so that all changes can be tracked) and a 51 cost (given as a float number). 52 53 The state of an access code is something like 'used', 'disabled', 54 etc. and determined by the workflow defined in 55 :mod:`waeup.sirp.accesscodes.workflow`. This also means that 56 instead of setting the status of an access code directly (you 57 can't do that easily, and yes, that's intentionally), you have to 58 trigger a transition (that might fail, if the transition is not 59 allowed in terms of logic or permissions). See 60 :mod:`waeup.sirp.accesscodes.workflow` for details. 61 27 62 """ 28 63 grok.implements(IAccessCode) … … 35 70 @property 36 71 def representation(self): 72 """A string representation of the :class:`AccessCode`. 73 74 It has format ``APP-XXX-YYYYYYYYYY`` as described above. 75 """ 37 76 return '%s-%s-%s' % ( 38 77 self.batch_prefix, self.batch_num, self.random_num) … … 40 79 @property 41 80 def batch(self): 81 """The batch this :class:`AccessCode` is contained. 82 """ 42 83 return getattr(self, '__parent__', None) 43 84 44 85 @property 45 86 def batch_prefix(self): 87 """The prefix of the batch this :class:`AccessCode` belongs to. 88 """ 46 89 if self.batch is None: 47 90 return '' … … 50 93 @property 51 94 def batch_num(self): 95 """The number of the batch this :class:`AccessCode` belongs to. A 96 read-only attribute. 97 """ 52 98 if self.batch is None: 53 99 return '' … … 56 102 @property 57 103 def cost(self): 104 """A float representing the price or ``None``. A read-only attribute. 105 """ 58 106 if self.batch is None: 59 107 return None … … 62 110 @property 63 111 def state(self): 112 """The workflow state. A read-only attribute. 113 """ 64 114 return IWorkflowState(self).getState() 65 115
Note: See TracChangeset for help on using the changeset viewer.