| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
from AccessControl import ClassSecurityInfo |
|---|
| 20 |
from Products.Archetypes.public import * |
|---|
| 21 |
from Products.CMFCore.utils import getToolByName |
|---|
| 22 |
|
|---|
| 23 |
from config import PROJECTNAME, MODIFY_CONTENT, VIEW, FS_STORAGE |
|---|
| 24 |
from Material import Material |
|---|
| 25 |
from Schemata import material_schema, license_schema |
|---|
| 26 |
if FS_STORAGE: |
|---|
| 27 |
from Products.FileSystemStorage.FileSystemStorage import FileSystemStorage |
|---|
| 28 |
else: |
|---|
| 29 |
from Products.Archetypes.Storage import AttributeStorage as FileSystemStorage |
|---|
| 30 |
|
|---|
| 31 |
lemillprintresource_schema= Schema(( |
|---|
| 32 |
StringField('author', |
|---|
| 33 |
widget = StringWidget( |
|---|
| 34 |
label = 'Author', |
|---|
| 35 |
label_msgid = 'label_author', |
|---|
| 36 |
description = 'Author of this resource', |
|---|
| 37 |
description_msgid = 'description_author', |
|---|
| 38 |
i18n_domain = 'lemill', |
|---|
| 39 |
), |
|---|
| 40 |
), |
|---|
| 41 |
FileField('file', |
|---|
| 42 |
required=True, |
|---|
| 43 |
storage=FileSystemStorage(), |
|---|
| 44 |
widget = FileWidget( |
|---|
| 45 |
label="PDF resource", |
|---|
| 46 |
description="Allowed file types: .pdf", |
|---|
| 47 |
i18n_domain="lemill", |
|---|
| 48 |
label_msgid='label_pdf_file', |
|---|
| 49 |
description_msgid='help_pdf_file', |
|---|
| 50 |
show_content_type= True, |
|---|
| 51 |
), |
|---|
| 52 |
), |
|---|
| 53 |
)) |
|---|
| 54 |
|
|---|
| 55 |
schema = material_schema + license_schema + lemillprintresource_schema |
|---|
| 56 |
|
|---|
| 57 |
schema = schema.copy() |
|---|
| 58 |
|
|---|
| 59 |
toBeHidden = ['bodyText', 'creators'] |
|---|
| 60 |
for x in schema.keys(): |
|---|
| 61 |
schema[x].schemata = 'default' |
|---|
| 62 |
schema[x].isMetadata = False |
|---|
| 63 |
if x in toBeHidden: |
|---|
| 64 |
schema[x].widget.visible = {'view': 'invisible', 'edit':'invisible'} |
|---|
| 65 |
if x == 'description': |
|---|
| 66 |
schema[x].widget.visible = {'view': 'visible', 'edit':'visible'} |
|---|
| 67 |
schema.moveField('file', after='title') |
|---|
| 68 |
schema.moveField('author', after='file') |
|---|
| 69 |
schema.moveField('description', after='author') |
|---|
| 70 |
schema.moveField('tags', after='description') |
|---|
| 71 |
schema.moveField('rights', pos='bottom') |
|---|
| 72 |
|
|---|
| 73 |
class LeMillPrintResource(Material): |
|---|
| 74 |
""" Reference to external resource """ |
|---|
| 75 |
|
|---|
| 76 |
schema = schema |
|---|
| 77 |
|
|---|
| 78 |
meta_type = 'LeMillPrintResource' |
|---|
| 79 |
archetype_name = 'LeMillPrintResource' |
|---|
| 80 |
default_location = 'content/printresources' |
|---|
| 81 |
|
|---|
| 82 |
portlet = 'here/portlet_lemillprintresource_actions/macros/portlet' |
|---|
| 83 |
security = ClassSecurityInfo() |
|---|
| 84 |
security.declareObjectPublic() |
|---|
| 85 |
|
|---|
| 86 |
aliases = { |
|---|
| 87 |
'(Default)' : 'base_view', |
|---|
| 88 |
'view' : 'base_view', |
|---|
| 89 |
'edit' : 'base_edit' |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
def amIMaterial(self): |
|---|
| 93 |
""" references are not proper material""" |
|---|
| 94 |
return False |
|---|
| 95 |
|
|---|
| 96 |
def hasComplexWorkflow(self): |
|---|
| 97 |
""" Can have drafts or versions """ |
|---|
| 98 |
return False |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
registerType(LeMillPrintResource, PROJECTNAME) |
|---|