[7195] | 1 | ## $Id: interfaces.py 8321 2012-05-02 06:24:42Z 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 | ## |
---|
[5068] | 18 | """Interfaces of access code related components. |
---|
| 19 | """ |
---|
| 20 | from zope import schema |
---|
| 21 | from zope.interface import Interface |
---|
[7819] | 22 | from waeup.kofa.interfaces import IKofaObject |
---|
[7811] | 23 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[5068] | 24 | |
---|
[7819] | 25 | class IAccessCode(IKofaObject): |
---|
[5068] | 26 | """An access code. |
---|
| 27 | """ |
---|
| 28 | batch_serial = schema.Int( |
---|
[7719] | 29 | title = _(u'Serial number inside batch'), |
---|
[5068] | 30 | ) |
---|
| 31 | batch_prefix = schema.TextLine( |
---|
[7719] | 32 | title = _(u'Prefix inside batch'), |
---|
[5068] | 33 | ) |
---|
| 34 | batch_num = schema.Int( |
---|
[7719] | 35 | title = _(u'Batch number'), |
---|
[5068] | 36 | ) |
---|
| 37 | random_num = schema.TextLine( |
---|
[7745] | 38 | title = _(u'Random part of access code'), |
---|
[5068] | 39 | ) |
---|
| 40 | cost = schema.Float( |
---|
[7719] | 41 | title = _(u'Cost of access code'), |
---|
[5068] | 42 | ) |
---|
[6470] | 43 | state = schema.TextLine( |
---|
[7719] | 44 | title = _(u'Workflow state'), |
---|
[6450] | 45 | ) |
---|
[5098] | 46 | representation = schema.TextLine( |
---|
[7719] | 47 | title = _(u'Complete title of access code'), |
---|
[5098] | 48 | ) |
---|
[6927] | 49 | owner = schema.TextLine( |
---|
[7719] | 50 | title = _(u'Purchaser'), |
---|
[6927] | 51 | ) |
---|
[6423] | 52 | history = schema.Text( |
---|
[7719] | 53 | title = _(u'The history of access code as lines'), |
---|
[6423] | 54 | default = u'', |
---|
| 55 | readonly = True, |
---|
| 56 | ) |
---|
[6413] | 57 | |
---|
[5068] | 58 | class IAccessCodeBatch(Interface): |
---|
| 59 | """A factory for batches of access codes. |
---|
| 60 | """ |
---|
[8172] | 61 | creation_date = schema.Date( |
---|
[7719] | 62 | title = _(u'Creation date'), |
---|
[5068] | 63 | ) |
---|
| 64 | creator = schema.TextLine( |
---|
[7719] | 65 | title = _(u'Batch creator'), |
---|
[5068] | 66 | ) |
---|
[6415] | 67 | prefix = schema.TextLine( |
---|
[7719] | 68 | title = _(u'Batch prefix'), |
---|
[5068] | 69 | ) |
---|
[6415] | 70 | num = schema.Int( |
---|
[7719] | 71 | title = _(u'Batch number (1-3 digits)'), |
---|
[5085] | 72 | min = 0, max = 999, |
---|
[5068] | 73 | ) |
---|
[5085] | 74 | entry_num = schema.Int( |
---|
[7719] | 75 | title = _(u'Number of access codes'), |
---|
[6931] | 76 | default = 1000, min = 0, |
---|
[5085] | 77 | ) |
---|
| 78 | cost = schema.Float( |
---|
[7719] | 79 | title = _(u'Cost of access code'), |
---|
[5085] | 80 | default = 0.0, min = 0.0, |
---|
| 81 | ) |
---|
[6425] | 82 | disabled_num = schema.Int( |
---|
[7719] | 83 | title = _(u'Number of disabled access codes inside the batch'), |
---|
[6425] | 84 | default = 0, |
---|
| 85 | readonly = True, |
---|
| 86 | ) |
---|
| 87 | used_num = schema.Int( |
---|
[7719] | 88 | title = _(u'Number of used access codes inside the batch'), |
---|
[6425] | 89 | default = 0, |
---|
| 90 | readonly = True, |
---|
| 91 | ) |
---|
[5081] | 92 | |
---|
[7819] | 93 | class IAccessCodeBatchContainer(IKofaObject): |
---|
[5081] | 94 | """A container for access code batches. |
---|
| 95 | """ |
---|
| 96 | |
---|
| 97 | def addBatch(batch): |
---|
| 98 | """Add a batch. |
---|
| 99 | """ |
---|