1 | """Interfaces of access code related components. |
---|
2 | """ |
---|
3 | from zope import schema |
---|
4 | from zope.interface import Interface |
---|
5 | from waeup.sirp.interfaces import IWAeUPObject |
---|
6 | |
---|
7 | class IAccessCode(IWAeUPObject): |
---|
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 | default = 0.0, min = 0.0, |
---|
25 | ) |
---|
26 | state = schema.TextLine( |
---|
27 | title = u'Workflow state', |
---|
28 | ) |
---|
29 | representation = schema.TextLine( |
---|
30 | title = u'Complete title of access code', |
---|
31 | ) |
---|
32 | history = schema.Text( |
---|
33 | title = u'The history of access code as lines', |
---|
34 | default = u'', |
---|
35 | readonly = True, |
---|
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 | prefix = schema.TextLine( |
---|
48 | title = u'Batch prefix', |
---|
49 | ) |
---|
50 | num = schema.Int( |
---|
51 | title = u'Batch number (1-3 digits)', |
---|
52 | min = 0, max = 999, |
---|
53 | ) |
---|
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 | ) |
---|
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 | ) |
---|
72 | |
---|
73 | class IAccessCodeBatchContainer(IWAeUPObject): |
---|
74 | """A container for access code batches. |
---|
75 | """ |
---|
76 | |
---|
77 | def addBatch(batch): |
---|
78 | """Add a batch. |
---|
79 | """ |
---|