# -*- coding: utf-8
# Copyright 2005 by Meelis Mets
from Products.Archetypes.public import BaseSchema, Schema
from Products.Archetypes.public import StringField, LinesField
from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget
from Products.Archetypes.public import BaseContent, registerType
from Globals import InitializeClass
from Products.CMFCore.utils import getToolByName
#from Products.reportlab.pdfgen import canvas
#from Products.reportlab.lib.units import cm
from AccessControl import ClassSecurityInfo, Unauthorized
from config import PROJECT_NAME
schema = BaseSchema
class Profile(BaseContent):
""" Profile product """
meta_type = "Profile"
archetype_name = "Profile"
global_allow = 0
exclude_from_nav = True
allowed_content_types = []
security = ClassSecurityInfo()
schema = schema
actions = (
{
'id':'view',
'name':'View',
'action':'string:${object_url}/profile_view',
'permissions': ('View',),
},
{
'id':'desired_employment',
'name':'Desired employment',
'action':'string:${object_url}/desired_edit',
'permissions': ('View',),
},
{
'id':'workexperience',
'name':'Work experience',
'action':'string:${object_url}/workexp_edit',
'permissions': ('View',),
},
{
'id':'education',
'name':'Education',
'action':'string:${object_url}/education_edit',
'permissions': ('View',),
},
{
'id':'languages',
'name':'Languages',
'action':'string:${object_url}/languages_edit',
'permissions': ('View',),
},
{
'id':'skills',
'name':'Skills',
'action':'string:${object_url}/skills_edit',
'permissions': ('View',),
},
{
'id':'additional',
'name':'Additional',
'action':'string:${object_url}/additional_edit',
'permissions': ('View',),
},
{
'id':'cv',
'name':'CV',
'action':'string:${object_url}/cv_view',
'permissions': ('View',),
},
{
'id':'edit',
'name':'Edit',
'action':'string:${object_url}/base_edit',
'permissions': ('Manage Portal',),
},
{
'id':'metadata',
'name':'Properties',
'action':'string:${object_url}/base_metadata',
'permissions': ('Manage Portal',),
},
)
def __init__(self, id):
self.id = id
self.desired = ''
self.workExperiences = []
self.education = []
self.languages = {'mothertongue': '', 'other': []}
self.skills = {'social' : '',
'organisational' : '',
'qualification' : '',
'technical' : '',
'computer' : '',
'artistic' : '',
'other' : '',
'driving' : ''}
self.additional = {'information' : '', 'annexes' : ''}
self.largeIcon = "profile.gif"
def getLargeIcon(self):
""" returns large icon name """
return self.largeIcon
def saveWorkExperience(self, REQUEST):
""" Save Work Experience """
dateBegin = {'day': REQUEST.get('from_d'), 'month': REQUEST.get('from_m'), 'year': REQUEST.get('from_y')}
dateEnd = {'day': REQUEST.get('to_d'), 'month': REQUEST.get('to_m'), 'year': REQUEST.get('to_y')}
position = REQUEST.get('position')
activities = REQUEST.get('activities')
employer = REQUEST.get('employer')
sector = REQUEST.get('sector')
workExperience = {'dateBegin' : dateBegin,
'dateEnd' : dateEnd,
'position' : position,
'activities' : activities,
'employer' : employer,
'sector' : sector}
i = int(REQUEST.get('edit'))
if(i==0):
self.workExperiences.append(workExperience)
else:
self.workExperiences[i-1]=workExperience
self._p_changed = 1
def removeWorkExperiences(self, REQUEST):
""" Remove WorkExperiences """
delete = int(REQUEST.get('id'))-1
self.workExperiences.pop(delete)
self._p_changed = 1
def getWorkExperiences(self):
""" get work experiences """
return self.workExperiences
def getEducation(self):
""" get education """
return self.education
def saveEducation(self, REQUEST):
""" Save Education """
dateBegin = {'day': REQUEST.get('from_d'), 'month': REQUEST.get('from_m'), 'year': REQUEST.get('from_y')}
dateEnd = {'day': REQUEST.get('to_d'), 'month': REQUEST.get('to_m'), 'year': REQUEST.get('to_y')}
qualification = REQUEST.get('qualification')
skills = REQUEST.get('skills')
organisation = REQUEST.get('organisation')
level = REQUEST.get('level')
edu = {'dateBegin' : dateBegin,
'dateEnd' : dateEnd,
'qualification' : qualification,
'skills' : skills,
'organisation' : organisation,
'level' : level}
i = int(REQUEST.get('edit'))
if(i==0):
self.education.append(edu)
else:
self.education[i-1]=edu
self._p_changed = 1
def removeEducation(self, REQUEST):
""" Remove Education """
delete = int(REQUEST.get('id'))-1
self.education.pop(delete)
self._p_changed = 1
def getLanguages(self):
""" get Languages """
return self.languages
def saveLanguages(self, REQUEST):
""" Save Languages """
mothertongue = REQUEST.get('mothertongue')
language = REQUEST.get('language')
listening = REQUEST.get('listening')
reading = REQUEST.get('reading')
interaction = REQUEST.get('interaction')
production = REQUEST.get('production')
writing = REQUEST.get('writing')
lan = {'language' : language,
'listening' : listening,
'reading' : reading,
'interaction' : interaction,
'production' : production,
'writing' : writing}
i = int(REQUEST.get('edit'))
if(i==0):
if(language!=''):
self.languages['other'].append(lan)
else:
self.languages['other'][i-1] = lan
self.languages['mothertongue'] = mothertongue
self._p_changed = 1
def removeLanguages(self, REQUEST):
""" Remove Languages """
delete = int(REQUEST.get('id'))-1
self.languages['other'].pop(delete)
self._p_changed = 1
def getSkills(self):
""" get skills """
return self.skills
def saveSkills(self, REQUEST):
""" Save Skills """
self.skills['social'] = REQUEST.get('social')
self.skills['organisational'] = REQUEST.get('organisational')
self.skills['technical'] = REQUEST.get('technical')
self.skills['computer'] = REQUEST.get('computer')
self.skills['artistic'] = REQUEST.get('artistic')
self.skills['other'] = REQUEST.get('other')
self.skills['driving'] = REQUEST.get('driving')
self._p_changed = 1
def getAdditional(self):
""" get additional """
return self.additional
def saveAdditional(self, REQUEST):
""" Save Additional """
self.additional['information'] = REQUEST.get('information')
self.additional['annexes'] = REQUEST.get('annexes')
self._p_changed = 1
def getDesired(self):
""" get Desired employment """
return self.desired
def saveDesired(self, REQUEST):
""" Save Desired employment """
self.desired = REQUEST.get('desired')
self._p_changed = 1
def arrayToString(self, array):
""" array to string splittable by \n """
string = ''
for value in array:
string = string+value+'\n'
return string
def arrayToBr(self, array):
""" array to string splittable by
"""
string = ''
for value in array:
string = string+value+'
'
return string
def getHTML(self):
""" HTML """
a = str(self.cv_view())
b = a.split("")
begin = "\n\n