# -*- 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': ('Modify portal content',), }, { 'id':'desired_employment', 'name':'Desired employment', 'action':'string:${object_url}/desired_edit', 'permissions': ('Modify portal content',), }, { 'id':'workexperience', 'name':'Work experience', 'action':'string:${object_url}/workexp_edit', 'permissions': ('Modify portal content',), }, { 'id':'education', 'name':'Education', 'action':'string:${object_url}/education_edit', 'permissions': ('Modify portal content',), }, { 'id':'languages', 'name':'Languages', 'action':'string:${object_url}/languages_edit', 'permissions': ('Modify portal content',), }, { 'id':'skills', 'name':'Skills', 'action':'string:${object_url}/skills_edit', 'permissions': ('Modify portal content',), }, { 'id':'additional', 'name':'Additional', 'action':'string:${object_url}/additional_edit', 'permissions': ('Modify portal content',), }, { '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 security.declareProtected('Modify portal content', 'showContent') def showContent(self): """ permission to show content """ return 0 security.declareProtected('Modify portal content', 'saveWorkExperience') 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 security.declareProtected('Modify portal content', 'removeWorkExperiences') def removeWorkExperiences(self, REQUEST): """ Remove WorkExperiences """ delete = int(REQUEST.get('id'))-1 self.workExperiences.pop(delete) self._p_changed = 1 security.declareProtected('View', 'getWorkExperiences') def getWorkExperiences(self): """ get work experiences """ return self.workExperiences security.declareProtected('View', 'getEducation') def getEducation(self): """ get education """ return self.education security.declareProtected('Modify portal content', 'saveEducation') 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 security.declareProtected('Modify portal content', 'removeEducation') def removeEducation(self, REQUEST): """ Remove Education """ delete = int(REQUEST.get('id'))-1 self.education.pop(delete) self._p_changed = 1 security.declareProtected('View', 'getLanguages') def getLanguages(self): """ get Languages """ return self.languages security.declareProtected('Modify portal content', 'saveLanguages') 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 security.declareProtected('Modify portal content', 'removeLanguages') def removeLanguages(self, REQUEST): """ Remove Languages """ delete = int(REQUEST.get('id'))-1 self.languages['other'].pop(delete) self._p_changed = 1 security.declareProtected('View', 'getSkills') def getSkills(self): """ get skills """ return self.skills security.declareProtected('Modify portal content', 'saveSkills') 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 security.declareProtected('View', 'getAdditional') def getAdditional(self): """ get additional """ return self.additional security.declareProtected('Modify portal content', 'saveAdditional') def saveAdditional(self, REQUEST): """ Save Additional """ self.additional['information'] = REQUEST.get('information') self.additional['annexes'] = REQUEST.get('annexes') self._p_changed = 1 security.declareProtected('View', 'getDesired') def getDesired(self): """ get Desired employment """ return self.desired security.declareProtected('Modify portal content', 'saveDesired') 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\nCV\n\n\n\n" end = "\n" html = begin + b[1] + end return html def getPDF(self): html = self.getHTML() return html # def hello(c): # """ hello """ # c = canvas.Canvas("hello.pdf") # c.drawString(9*cm, 22*cm, "Hello World!") # c.showPage() # c.save() registerType(Profile, PROJECT_NAME)