"+str(dataObject.Creator())+" | "
for field in self.appFields:
noData = 0
for data in dataObject.appData:
if(str(field['id'])==str(data['id'])):
noData = 1
if str(field['type']) in ['text', 'textarea', 'dropdown']:
html = html+""+str(data['value'])+" | "
if str(field['type']) in ['single selection']:
if str(data['value']) != 'None':
html = html+""+str(field['options'][int(str(data['value']))])+" | "
else:
html = html+" | "
if str(field['type']) in ['multiple selection']:
if (data['value'] == None):
html = html+" | "
elif (len(data['value'])==1):
html = html+""+str(field['options'][int(str(data['value']))])+" | "
else:
val = ''
for i in data['value']:
val = val + str(field['options'][int(str(i))]) + ", "
val = val[:-2]
html = html+""+val+" | "
if str(field['type']) in ['link']:
if (data['value'] == None):
html = html+" | "
#elif (len(data['value'])==1):
# html = html+""+str(data['value'])+" | "
else:
val = ''
for i in data['value']:
val = val + "" + str(i) + ", "
val = val[:-2]
html = html + "" + val + " | "
if(noData==0):
html = html + " | "
html = html+""
return html
def mailLink(self, forgotten_userid, REQUEST, link):
""" Send reminder Email to a member.
o Raise an exception if user ID is not found.
"""
membership = getToolByName(self, 'portal_membership')
member = membership.getMemberById(forgotten_userid)
if member is None:
raise ValueError('The username you entered could not be found.')
# assert that we can actually get an email address, otherwise
# the template will be made with a blank To:, this is bad
if not member.getProperty('email'):
raise ValueError('That user does not have an email address.')
#check, msg = _checkEmail(member.getProperty('email'))
#if not check:
# raise ValueError, msg
# Rather than have the template try to use the mailhost, we will
# render the message ourselves and send it from here (where we
# don't need to worry about 'UseMailHost' permissions).
mail_text = self.mail_link_template( self
, REQUEST
, member=member
, link=link
)
host = self.MailHost
host.send( mail_text )
return self.mail_password_response( self, REQUEST )
def copyApplication(self, REQUEST):
""" Copies already made form to users forms folder """
self.saveData(REQUEST)
user = str(REQUEST.AUTHENTICATED_USER)
homeFolder = self.portal_membership.getHomeFolder(user)
id = str(self.id)+'-copy'
if hasattr(homeFolder, id):
copiedForm = getattr(homeFolder,id)
copiedForm.appFields = self.appFields
copiedForm.appData = self.appData
self.appData = []
for field in self.appFields:
data = {'id': field['id'], 'value': ''}
self.appData.append(data)
else:
typestool = getToolByName(self, 'portal_types')
puf_type = getattr(typestool, 'Application', None)
if not puf_type:
return 0
puf_type.global_allow = 1
id = homeFolder.invokeFactory("Application", id=str(self.id)+'-copy', title=self.title)
copiedForm = getattr(homeFolder,id)
copiedForm.appCopy = 1
copiedForm.appFields = self.appFields
copiedForm.appData = self.appData
copiedForm.motherId = self.id
puf_type.global_allow = 0
self.appData = []
for field in self.appFields:
data = {'id': field['id'], 'value': ''}
self.appData.append(data)
if(self.sendmail==True):
self.mailLink(user, REQUEST, copiedForm.absolute_url())
self._p_changed = 1
return copiedForm
security.declareProtected('Modify portal content', 'getHTML')
def getHTML(self):
""" HTML """
a = str(self.app_print())
b = a.split("")
begin = "\n\n\n\n\n\n"
end = "\n"
html = begin + b[1] + b[3] +end
return html
registerType(Application, PROJECT_NAME)