parameters: ()
return_statement: return dict(form=form,left_sidebar_enabled=True,right_sidebar_enabled=True)
docstring: Add a booking request to a calendar event
docstring_summary: Add a booking request to a calendar event
docstring_tokens: Add a booking request to a calendar event
function: def add_booking_request():
      """
      Add a booking request to a calendar event
      """
      page = db.page(request.args(0))
      if not page:
          redirect(URL('index'))
      form = SQLFORM.factory(db.calendar_contact, db.calendar_booking_request)
      page_low_title = page.title.lower()
      if form.process().accepted:
          _id = db.calendar_contact.insert(**db.calendar_contact._filter_fields(form.vars))
          form.vars.contact=_id
          form.vars.page=page.id
          _id = db.calendar_booking_request.insert(**db.calendar_booking_request._filter_fields(form.vars))
          
          duration = db.calendar_duration(form.vars.duration)
  
          #send an email
          message=T("""
              The following person would like to book %s :
  
              Name : %s
              Email : %s
              Phone number : %s
              Address : %s
              From : %s
              During : %s
              Remark : %s
          """) % (page_low_title, form.vars.name, form.vars.email, form.vars.phone_number, form.vars.address,
                  form.vars.start_date.strftime("%d/%m/%Y"), duration.name if duration else '', form.vars.remark)
          if mail.send(to=WEBSITE_PARAMETERS.booking_form_email,
                    cc=[WEBSITE_PARAMETERS.booking_form_cc if WEBSITE_PARAMETERS.booking_form_cc else ''],
                    bcc=[WEBSITE_PARAMETERS.booking_form_bcc if WEBSITE_PARAMETERS.booking_form_bcc else ''],
                    subject=T('Booking request for %s on %s website') % (page_low_title,WEBSITE_PARAMETERS.website_name),
                    reply_to = form.vars.email,
                    message = message):
              session.flash = T('Your booking request has been recorded. Somebody will contact you as soon as possible. Thank you')
              redirect(URL('pages','show_page',args=page.url))
          else:
              form.errors.your_email = T('Unable to send the email')
      elif form.errors:
         response.flash = T('form has errors')
      return dict(form=form,left_sidebar_enabled=True,right_sidebar_enabled=True)
function_tokens: def add_booking_request ( ) : page = db . page ( request . args ( 0 ) ) if not page : redirect ( URL ( 'index' ) ) form = SQLFORM . factory ( db . calendar_contact , db . calendar_booking_request ) page_low_title = page . title . lower ( ) if form . process ( ) . accepted : _id = db . calendar_contact . insert ( * * db . calendar_contact . _filter_fields ( form . vars ) ) form . vars . contact = _id form . vars . page = page . id _id = db . calendar_booking_request . insert ( * * db . calendar_booking_request . _filter_fields ( form . vars ) ) duration = db . calendar_duration ( form . vars . duration ) #send an email message = T ( """
              The following person would like to book %s :
  
              Name : %s
              Email : %s
              Phone number : %s
              Address : %s
              From : %s
              During : %s
              Remark : %s
          """ ) % ( page_low_title , form . vars . name , form . vars . email , form . vars . phone_number , form . vars . address , form . vars . start_date . strftime ( "%d/%m/%Y" ) , duration . name if duration else '' , form . vars . remark ) if mail . send ( to = WEBSITE_PARAMETERS . booking_form_email , cc = [ WEBSITE_PARAMETERS . booking_form_cc if WEBSITE_PARAMETERS . booking_form_cc else '' ] , bcc = [ WEBSITE_PARAMETERS . booking_form_bcc if WEBSITE_PARAMETERS . booking_form_bcc else '' ] , subject = T ( 'Booking request for %s on %s website' ) % ( page_low_title , WEBSITE_PARAMETERS . website_name ) , reply_to = form . vars . email , message = message ) : session . flash = T ( 'Your booking request has been recorded. Somebody will contact you as soon as possible. Thank you' ) redirect ( URL ( 'pages' , 'show_page' , args = page . url ) ) else : form . errors . your_email = T ( 'Unable to send the email' ) elif form . errors : response . flash = T ( 'form has errors' ) return dict ( form = form , left_sidebar_enabled = True , right_sidebar_enabled = True )