from Products.Archetypes.atapi import *
from Products.ATContentTypes.content.folder import ATFolder
from Products.ATContentTypes.content.file import ATFile
from Products.ATContentTypes.content.base import ATCTContent
from Products.ATContentTypes.content.schemata import ATContentTypeSchema, finalizeATCTSchema
from Products.CMFPlone.interfaces import INonStructuralFolder
from Products.CMFCore import permissions
from Products.CV.config import PROJECTNAME
from string import split, join
CVSchema = ATFolder.schema.copy() + Schema((
ComputedField(
name='title',
searchable=1,
expression='context._computeTitle()',
accessor='Title',
widget=ComputedWidget(mode='view')
),
ComputedField(
name='description',
searchable=1,
expression='context._computeDescription()',
accessor='Description',
widget=ComputedWidget(mode='view')
),
StringField(
name='fullName',
widget=StringWidget(label='Full name'),
required=True,
),
LinesField(
name='qualifications',
widget=LinesWidget(label='Qualifications'),
required=True,
),
LinesField(
name='address',
widget=LinesWidget(label='Address'),
required=True,
),
StringField(
name='homePhone',
widget=StringWidget(label='Home phone number'),
required=True,
),
StringField(
name='mobilePhone',
widget=StringWidget(label='Mobile phone number'),
),
StringField(
name='workPhone',
widget=StringWidget(label='Work phone number'),
),
StringField(
name='email',
widget=StringWidget(label='Email address'),
required=True,
),
DateTimeField(
name='birthDate',
widget=CalendarWidget(label='Date of birth',
show_hm=False,
starting_year=1970,
format='%Y-%m-%d'),
required=True,
),
StringField(
name='maritalStatus',
widget=SelectionWidget(label='Marital status'),
vocabulary=['Single', 'Married', 'Divorced'],
required=True,
),
StringField(
name='drivingLicence',
widget=StringWidget(label='Driving licence'),
required=True,
),
TextField(
name='interests',
widget=RichWidget(label='Interests'),
required=True,
)
),)
EducationSchema = ATContentTypeSchema.copy() + Schema((
ComputedField(
name='title',
searchable=1,
expression='context._computeTitle()',
accessor='Title'),
DateTimeField(
name='fromDate',
widget=CalendarWidget(label='From date',
show_hm=False,
starting_year=1980,
format='%Y-%m-%d'),
required=True,
),
DateTimeField(
name='toDate',
widget=CalendarWidget(label='To date',
show_hm=False,
starting_year=1980,
format='%Y-%m-%d'),
),
StringField(
name='qualification',
widget=StringWidget(label='Qualifiction'),
),
StringField(
name='institute',
widget=StringWidget(label='Institute'),
required=True,
),
TextField(
name='description',
widget=RichWidget(label='Description'),
required=True,
default_content_type='text/html',
allowable_content_types=('text/html',),
default_output_type='text/html',
)
),)
EmploymentSchema = ATContentTypeSchema.copy() + Schema((
ComputedField(
name='title',
searchable=1,
expression='context._computeTitle()',
accessor='Title'),
DateTimeField(
name='fromDate',
widget=CalendarWidget(label='From date',
show_hm=False,
starting_year=1980,
format='%Y-%m-%d'),
required=True,
),
DateTimeField(
name='toDate',
widget=CalendarWidget(label='To date',
show_hm=False,
starting_year=1980,
format='%Y-%m-%d'),
),
StringField(
name='position',
widget=StringWidget(label='Position'),
),
StringField(
name='company',
widget=StringWidget(label='Company'),
required=True,
),
StringField(
name='location',
widget=StringWidget(label='Location'),
required=True,
),
TextField(
name='description',
widget=RichWidget(label='Description'),
required=True,
default_content_type='text/html',
allowable_content_types=('text/html',),
default_output_type='text/html',
)
),)
PublicationSchema = ATFile.schema.copy() + Schema((
StringField(
name='publicationType',
widget=SelectionWidget(label='Publication type'),
vocabulary=['article', 'book', 'booklet', 'conference',
'inBook', 'inCollection', 'inProceedings',
'manual', 'mastersThesis', 'misc', 'phdThesis',
'proceedings', 'techreport', 'unpublished'],
required=True,
),
StringField(
name='address',
widget=StringWidget(label='Address')
),
LinesField(
name='authors',
widget=LinesWidget(label='Authors'),
required=True,
),
StringField(
name='booktitle',
widget=StringWidget(label='Book title'),
),
StringField(
name='chapter',
widget=StringWidget(label='Chapter'),
),
StringField(
name='edition',
widget=StringWidget(label='Edition'),
),
StringField(
name='editor',
widget=StringWidget(label='Editor'),
),
StringField(
name='howpublished',
widget=StringWidget(label='How published'),
),
StringField(
name='institution',
widget=StringWidget(label='Institution'),
),
StringField(
name='journal',
widget=StringWidget(label='Journal'),
),
StringField(
name='key',
widget=StringWidget(label='Key'),
),
StringField(
name='month',
widget=StringWidget(label='Month'),
),
StringField(
name='note',
widget=StringWidget(label='Note'),
),
StringField(
name='number',
widget=StringWidget(label='Number'),
),
StringField(
name='organization',
widget=StringWidget(label='Organization'),
),
StringField(
name='pages',
widget=StringWidget(label='Pages'),
),
StringField(
name='publisher',
widget=StringWidget(label='Publisher'),
),
StringField(
name='school',
widget=StringWidget(label='School'),
),
StringField(
name='series',
widget=StringWidget(label='Series'),
),
StringField(
name='techReportType',
widget=StringWidget(label='Technical report type'),
),
StringField(
name='volume',
widget=StringWidget(label='Volume'),
),
StringField(
name='year',
widget=StringWidget(label='Year'),
required=True,
),
StringField(
name='onlineUrl',
widget=StringWidget(label='URL'),
),
StringField(
name='onlineSize',
widget=StringWidget(label='Size'),
)
),)
SkillSchema = ATContentTypeSchema.copy() + Schema((
ComputedField(
name='title',
searchable=1,
expression='context._computeTitle()',
accessor='Title'),
StringField(
name='category',
widget=StringWidget(label='Category'),
required=True,
),
TextField(
name='description',
widget=RichWidget(label='Description'),
default_content_type='text/html',
allowable_content_types=('text/html',),
default_output_type='text/html',
)
),)
finalizeATCTSchema(CVSchema)
finalizeATCTSchema(EducationSchema)
finalizeATCTSchema(EmploymentSchema)
finalizeATCTSchema(PublicationSchema)
finalizeATCTSchema(SkillSchema)
class CV(ATFolder):
"""
A CV lists details of someone's education and employment histories
as well as key skills and any publications, along with generic
properties like address, name, etc.
"""
portal_type = meta_type = 'CV'
archetype_name = 'Curriculum Vitae'
content_icon = 'cv.png'
schema = CVSchema
typeDescription = 'A Curriculum Vitae for someone.'
allowed_content_types = ['Education', 'Employment', 'Publication', 'Skill']
default_view = 'cv_view'
immediate_view = 'cv_view'
# __implements__ = ATFolder.__implements__ + [INonStructuralFolder]
# actions = ATFolder.actions
def canSetDefaultPage(self):
return False
def _computeTitle(self):
return 'Curriculum Vitae for ' + self.getFullName();
def _computeDescription(self):
return "%s\n%s\n%s\n%s" % (self.getFullName(),
self.getAddress(),
self.getEmail(),
self.getBirthDate())
def lastModified(self):
""" Gets the date of the latest edit, including subobjects """
lastMod = self.ModificationDate()
for subobject in self.objectValues():
if subobject.ModificationDate() > lastMod:
lastMod = subobject.ModificationDate()
return lastMod
registerType(CV, "CV")
class Education(ATCTContent):
portal_type = meta_type = 'Education'
archetype_name = 'Education'
content_icon = 'education.png'
schema = EducationSchema
typeDescription = 'Details of education from some institute.'
# __implements__ = ATCTContent.__implements__
# actions = ATCTContent.actions
global_allow = False
def _computeTitle(self):
return 'Education at ' + self.getInstitute();
registerType(Education, "Education")
class Employment(ATCTContent):
portal_type = meta_type = 'Employment'
archetype_name = 'Employment'
content_icon = 'employment.png'
schema = EmploymentSchema
typeDescription = 'Details of employment with some employer.'
# __implements__ = ATCTContent.__implements__
# actions = ATCTContent.actions
global_allow = False
def _computeTitle(self):
return 'Employment at ' + self.getCompany();
registerType(Employment, "Employment")
class Publication(ATFile):
portal_type = meta_type = 'Publication'
archetype_name = 'Publication'
content_icon = 'publication.png'
schema = PublicationSchema
typeDescription = 'A publication with citation details.'
# __implements__ = ATFile.__implements__
# actions = ATFile.actions
global_allow = False
def listAuthors(self):
name_list = []
for full_name in self.authors:
names = split(full_name, ' ')
surname = names[-1]
backward_name = surname
for name in names[:-1]:
backward_name = backward_name + ' ' + name[0] + '.'
name_list.append(backward_name)
if len(name_list) > 1:
return join(name_list[0:-1], ',') + ' and ' + name_list[-1]
else:
return name_list[0]
registerType(Publication, "Publication")
class Skill(ATCTContent):
portal_type = meta_type = 'Skill'
archetype_name = 'Skill'
content_icon = 'skill.png'
schema = SkillSchema
typeDescription = 'Details of a skill.'
# __implements__ = ATCTContent.__implements__
# actions = ATCTContent.actions
global_allow = False
def _computeTitle(self):
return 'Skill in ' + self.getCategory();
registerType(Skill, "Skill")