[5068] | 1 | """Interfaces of access code related components. |
---|
| 2 | """ |
---|
| 3 | |
---|
| 4 | from zope import schema |
---|
| 5 | from zope.interface import Interface |
---|
[5081] | 6 | from waeup.sirp.interfaces import IWAeUPObject |
---|
[5068] | 7 | |
---|
[5081] | 8 | class IAccessCode(IWAeUPObject): |
---|
[5068] | 9 | """An access code. |
---|
| 10 | """ |
---|
| 11 | batch_serial = schema.Int( |
---|
| 12 | title = u'Serial number inside batch', |
---|
| 13 | ) |
---|
| 14 | batch_prefix = schema.TextLine( |
---|
| 15 | title = u'Prefix inside batch', |
---|
| 16 | ) |
---|
| 17 | batch_num = schema.Int( |
---|
| 18 | title = u'Batch number', |
---|
| 19 | ) |
---|
| 20 | random_num = schema.TextLine( |
---|
| 21 | title = u'Random part of access code.', |
---|
| 22 | ) |
---|
| 23 | cost = schema.Float( |
---|
| 24 | title = u'Cost of access code', |
---|
[5085] | 25 | default = 0.0, min = 0.0, |
---|
[5068] | 26 | ) |
---|
| 27 | invalidation_date = schema.Datetime( |
---|
| 28 | title = u'Datetime of invalidation', |
---|
| 29 | required = False, |
---|
| 30 | default = None, |
---|
| 31 | ) |
---|
| 32 | student_id = schema.TextLine( |
---|
| 33 | title = u'Student ID or registration number', |
---|
| 34 | required = False, |
---|
| 35 | default = None, |
---|
| 36 | ) |
---|
| 37 | |
---|
| 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 | ) |
---|
| 47 | batch_prefix = schema.TextLine( |
---|
[5085] | 48 | title = u'Batch prefix', |
---|
[5068] | 49 | ) |
---|
| 50 | batch_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 | ) |
---|
[5081] | 62 | |
---|
| 63 | class IAccessCodeBatchContainer(IWAeUPObject): |
---|
| 64 | """A container for access code batches. |
---|
| 65 | """ |
---|
| 66 | |
---|
| 67 | def addBatch(batch): |
---|
| 68 | """Add a batch. |
---|
| 69 | """ |
---|