1 | """Interfaces of access code related components. |
---|
2 | """ |
---|
3 | |
---|
4 | from zope import schema |
---|
5 | from zope.interface import Interface |
---|
6 | |
---|
7 | class IAccessCode(Interface): |
---|
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', |
---|
24 | ) |
---|
25 | invalidation_date = schema.Datetime( |
---|
26 | title = u'Datetime of invalidation', |
---|
27 | required = False, |
---|
28 | default = None, |
---|
29 | ) |
---|
30 | student_id = schema.TextLine( |
---|
31 | title = u'Student ID or registration number', |
---|
32 | required = False, |
---|
33 | default = None, |
---|
34 | ) |
---|
35 | |
---|
36 | class IAccessCodeBatch(Interface): |
---|
37 | """A factory for batches of access codes. |
---|
38 | """ |
---|
39 | creation_date = schema.Date( |
---|
40 | title = u'Creation date', |
---|
41 | ) |
---|
42 | creator = schema.TextLine( |
---|
43 | title = u'Batch creator', |
---|
44 | ) |
---|
45 | batch_prefix = schema.TextLine( |
---|
46 | title = u'Prefix inside batch', |
---|
47 | ) |
---|
48 | batch_num = schema.Int( |
---|
49 | title = u'Batch number', |
---|
50 | ) |
---|
51 | |
---|
52 | def __iter__(): |
---|
53 | """Iterate over all access codes in this batch. |
---|
54 | """ |
---|