portal = context.getPortalObject()
web_site = context.getWebSiteValue()
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()
context.REQUEST.set('new_support_request', None)

support_request_template = portal.restrictedTraverse(
  portal.portal_preferences.getPreferredSupportRequestTemplate())
support_request = support_request_template.Base_createCloneDocument(batch_mode=1)

kw = {}
if context.getPortalType() in ["Hosting Subscription", "Computer"]:
  kw['aggregate'] = context.getRelativeUrl()

support_request.edit(
  title=title,
  destination_decision_value=person,
  resource=resource,
  start_date=DateTime(),
  **kw
)
support_request.validate(comment="Submitted from the web site contact form")

web_message_template = portal.restrictedTraverse(
  portal.portal_preferences.getPreferredWebMessageTemplate())
web_message = web_message_template.Base_createCloneDocument(batch_mode=1)
# XXX init script is not called when cloning?
web_message.Event_init()
web_message.edit(
  title=title,
  content_type="text/plain",
  text_content=description,
  source_value=person,
  resource=resource,
  start_date=DateTime(),
  follow_up_value=support_request,
)
web_message.stop(comment="Submitted from the web site contact form")


return support_request.Base_redirect("")
