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