[5068] | 1 | """Interfaces of access code related components. |
---|
| 2 | """ |
---|
| 3 | from zope import schema |
---|
| 4 | from zope.interface import Interface |
---|
[5081] | 5 | from waeup.sirp.interfaces import IWAeUPObject |
---|
[5068] | 6 | |
---|
[5081] | 7 | class IAccessCode(IWAeUPObject): |
---|
[5068] | 8 | """An access code. |
---|
| 9 | """ |
---|
| 10 | batch_serial = schema.Int( |
---|
| 11 | title = u'Serial number inside batch', |
---|
| 12 | ) |
---|
| 13 | batch_prefix = schema.TextLine( |
---|
| 14 | title = u'Prefix inside batch', |
---|
| 15 | ) |
---|
| 16 | batch_num = schema.Int( |
---|
| 17 | title = u'Batch number', |
---|
| 18 | ) |
---|
| 19 | random_num = schema.TextLine( |
---|
| 20 | title = u'Random part of access code.', |
---|
| 21 | ) |
---|
| 22 | cost = schema.Float( |
---|
| 23 | title = u'Cost of access code', |
---|
[5085] | 24 | default = 0.0, min = 0.0, |
---|
[5068] | 25 | ) |
---|
[6470] | 26 | state = schema.TextLine( |
---|
| 27 | title = u'Workflow state', |
---|
[6450] | 28 | ) |
---|
[5098] | 29 | representation = schema.TextLine( |
---|
| 30 | title = u'Complete title of access code', |
---|
| 31 | ) |
---|
[6423] | 32 | history = schema.Text( |
---|
| 33 | title = u'The history of access code as lines', |
---|
| 34 | default = u'', |
---|
| 35 | readonly = True, |
---|
| 36 | ) |
---|
[6413] | 37 | |
---|
[5068] | 38 | class IAccessCodeBatch(Interface): |
---|
| 39 | """A factory for batches of access codes. |
---|
| 40 | """ |
---|
| 41 | creation_date = schema.Date( |
---|
| 42 | title = u'Creation date', |
---|
| 43 | ) |
---|
| 44 | creator = schema.TextLine( |
---|
| 45 | title = u'Batch creator', |
---|
| 46 | ) |
---|
[6415] | 47 | prefix = schema.TextLine( |
---|
[5085] | 48 | title = u'Batch prefix', |
---|
[5068] | 49 | ) |
---|
[6415] | 50 | num = schema.Int( |
---|
[5085] | 51 | title = u'Batch number (1-3 digits)', |
---|
| 52 | min = 0, max = 999, |
---|
[5068] | 53 | ) |
---|
[5085] | 54 | entry_num = schema.Int( |
---|
| 55 | title = u'Number of access codes', |
---|
| 56 | default = 1000, min = 1, |
---|
| 57 | ) |
---|
| 58 | cost = schema.Float( |
---|
| 59 | title = u'Cost of access code', |
---|
| 60 | default = 0.0, min = 0.0, |
---|
| 61 | ) |
---|
[6425] | 62 | disabled_num = schema.Int( |
---|
| 63 | title = u'Number of disabled access codes inside the batch', |
---|
| 64 | default = 0, |
---|
| 65 | readonly = True, |
---|
| 66 | ) |
---|
| 67 | used_num = schema.Int( |
---|
| 68 | title = u'Number of used access codes inside the batch', |
---|
| 69 | default = 0, |
---|
| 70 | readonly = True, |
---|
| 71 | ) |
---|
[5081] | 72 | |
---|
| 73 | class IAccessCodeBatchContainer(IWAeUPObject): |
---|
| 74 | """A container for access code batches. |
---|
| 75 | """ |
---|
| 76 | |
---|
| 77 | def addBatch(batch): |
---|
| 78 | """Add a batch. |
---|
| 79 | """ |
---|