1 | ## $Id: interfaces.py 7321 2011-12-10 06:15:17Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
4 | ## This program is free software; you can redistribute it and/or modify |
---|
5 | ## it under the terms of the GNU General Public License as published by |
---|
6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
7 | ## (at your option) any later version. |
---|
8 | ## |
---|
9 | ## This program is distributed in the hope that it will be useful, |
---|
10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | ## GNU General Public License for more details. |
---|
13 | ## |
---|
14 | ## You should have received a copy of the GNU General Public License |
---|
15 | ## along with this program; if not, write to the Free Software |
---|
16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | ## |
---|
18 | """Interfaces of access code related components. |
---|
19 | """ |
---|
20 | from zope import schema |
---|
21 | from zope.interface import Interface |
---|
22 | from waeup.sirp.interfaces import ISIRPObject |
---|
23 | |
---|
24 | class IAccessCode(ISIRPObject): |
---|
25 | """An access code. |
---|
26 | """ |
---|
27 | batch_serial = schema.Int( |
---|
28 | title = u'Serial number inside batch', |
---|
29 | ) |
---|
30 | batch_prefix = schema.TextLine( |
---|
31 | title = u'Prefix inside batch', |
---|
32 | ) |
---|
33 | batch_num = schema.Int( |
---|
34 | title = u'Batch number', |
---|
35 | ) |
---|
36 | random_num = schema.TextLine( |
---|
37 | title = u'Random part of access code.', |
---|
38 | ) |
---|
39 | cost = schema.Float( |
---|
40 | title = u'Cost of access code', |
---|
41 | default = 0.0, min = 0.0, |
---|
42 | ) |
---|
43 | state = schema.TextLine( |
---|
44 | title = u'Workflow state', |
---|
45 | ) |
---|
46 | representation = schema.TextLine( |
---|
47 | title = u'Complete title of access code', |
---|
48 | ) |
---|
49 | owner = schema.TextLine( |
---|
50 | title = u'Purchaser', |
---|
51 | ) |
---|
52 | history = schema.Text( |
---|
53 | title = u'The history of access code as lines', |
---|
54 | default = u'', |
---|
55 | readonly = True, |
---|
56 | ) |
---|
57 | |
---|
58 | class IAccessCodeBatch(Interface): |
---|
59 | """A factory for batches of access codes. |
---|
60 | """ |
---|
61 | creation_date = schema.Date( |
---|
62 | title = u'Creation date', |
---|
63 | ) |
---|
64 | creator = schema.TextLine( |
---|
65 | title = u'Batch creator', |
---|
66 | ) |
---|
67 | prefix = schema.TextLine( |
---|
68 | title = u'Batch prefix', |
---|
69 | ) |
---|
70 | num = schema.Int( |
---|
71 | title = u'Batch number (1-3 digits)', |
---|
72 | min = 0, max = 999, |
---|
73 | ) |
---|
74 | entry_num = schema.Int( |
---|
75 | title = u'Number of access codes', |
---|
76 | default = 1000, min = 0, |
---|
77 | ) |
---|
78 | cost = schema.Float( |
---|
79 | title = u'Cost of access code', |
---|
80 | default = 0.0, min = 0.0, |
---|
81 | ) |
---|
82 | disabled_num = schema.Int( |
---|
83 | title = u'Number of disabled access codes inside the batch', |
---|
84 | default = 0, |
---|
85 | readonly = True, |
---|
86 | ) |
---|
87 | used_num = schema.Int( |
---|
88 | title = u'Number of used access codes inside the batch', |
---|
89 | default = 0, |
---|
90 | readonly = True, |
---|
91 | ) |
---|
92 | |
---|
93 | class IAccessCodeBatchContainer(ISIRPObject): |
---|
94 | """A container for access code batches. |
---|
95 | """ |
---|
96 | |
---|
97 | def addBatch(batch): |
---|
98 | """Add a batch. |
---|
99 | """ |
---|