Last change
on this file since 1591 was
1,
checked in by myroslav, 18 years ago
|
Building directory structure
|
File size:
1.8 KB
|
Rev | Line | |
---|
[1] | 1 | from Products.CMFCore.utils import getToolByName |
---|
| 2 | from Products.Archetypes.public import * |
---|
| 3 | |
---|
| 4 | from validators import MaxSmValidator |
---|
| 5 | from config import * |
---|
| 6 | |
---|
| 7 | schema = BaseSchema+Schema(( |
---|
| 8 | ComputedField('title', |
---|
| 9 | accessor = 'Title', |
---|
| 10 | expression = "context.getBody()[:25]+'...'", |
---|
| 11 | widget=ComputedWidget( |
---|
| 12 | visible={'edit':'invisible', |
---|
| 13 | 'view':'invisible'}, ), |
---|
| 14 | ), |
---|
| 15 | StringField('sender', |
---|
| 16 | required=1, |
---|
| 17 | default_method = 'setDefaultSender', |
---|
| 18 | widget = StringWidget( |
---|
| 19 | condition = "python: object.portal_smsCommunicator.getProperty('policy') == 'free'" |
---|
| 20 | ) |
---|
| 21 | ), |
---|
| 22 | StringField('recipient', |
---|
| 23 | required=1, |
---|
| 24 | widget = LinesWidget( |
---|
| 25 | rows = 1, |
---|
| 26 | label="recipient"), |
---|
| 27 | ), |
---|
| 28 | TextField('body', |
---|
| 29 | searchable = 1, |
---|
| 30 | validators=MaxSmValidator(), |
---|
| 31 | widget = TextAreaWidget( |
---|
| 32 | description = "Enter your text message.", |
---|
| 33 | label = "Body text") |
---|
| 34 | ), |
---|
| 35 | )) |
---|
| 36 | |
---|
| 37 | class ShortMessage(BaseContent): |
---|
| 38 | |
---|
| 39 | schema = schema |
---|
| 40 | archetype_name=ARCHETYPE_NAME |
---|
| 41 | |
---|
| 42 | def setDefaultSender(self): |
---|
| 43 | communicator = getToolByName(self, 'portal_smsCommunicator') |
---|
| 44 | policy = communicator.getProperty('policy') |
---|
| 45 | if policy == 'free': |
---|
| 46 | return None |
---|
| 47 | else: |
---|
| 48 | return communicator.getProperty('mtMessageOriginator') |
---|
| 49 | |
---|
| 50 | registerType(ShortMessage) |
---|
Note: See
TracBrowser
for help on using the repository browser.