def template():
 def prep(r):
  if r.component:
   if (r.component_name == 'translate'):
    table = s3db.survey_translate
    if (r.component_id == None):
     table.file.readable = False
     table.file.writable = False
    else:
     table.language.writable = False
     table.code.writable = False
    s3db.configure('survey_translate', deletable=False)
  else:
   table = r.table
   s3_action_buttons(r)
   rows = db((table.status == 1)).select(table.id)
   try:
    s3.actions[1]['restrict'].extend((str(row.id) for row in rows))
   except KeyError:
    s3.actions[1]['restrict'] = [str(row.id) for row in rows]
   except IndexError:
    pass
   s3.dataTableStyleAlert = [str(row.id) for row in rows]
   rows = db((table.status == 3)).select(table.id)
   s3.dataTableStyleDisabled = [str(row.id) for row in rows]
   s3.dataTableStyleWarning = [str(row.id) for row in rows]
   rows = db((table.status == 4)).select(table.id)
   s3.dataTableStyleWarning.extend((str(row.id) for row in rows))
   s3db.configure('survey_template', orderby='survey_template.status', create_next=URL(c='survey', f='template'), update_next=URL(c='survey', f='template'))
  return True
 s3.prep = prep
 def postp(r, output):
  if r.component:
   template_id = r.id
   if (r.component_name == 'translate'):
    s3_action_buttons(r)
    s3.actions.extend([dict(label=str(T('Download')), _class='action-btn', url=r.url(method='translate_download', component='translate', component_id='[id]', representation='xls')), dict(label=str(T('Upload')), _class='action-btn', url=URL(c=module, f='template', args=[template_id, 'translate', '[id]']))])
  return output
 s3.postp = postp
 if request.ajax:
  post = request.post_vars
  action = post.get('action')
  template_id = post.get('parent_id')
  section_id = post.get('section_id')
  section_text = post.get('section_text')
  if ((action == 'section') and (template_id != None)):
   id = db.survey_section.insert(name=section_text, template_id=template_id, cloned_section_id=section_id)
   if (id is None):
    print 'Failed to insert record'
   return
 s3db.configure('survey_template', listadd=False)
 output = s3_rest_controller(rheader=s3db.survey_template_rheader)
 return output

def template ( ) : def prep ( r ) : if r . component : if ( r . component_name == 'translate' ) : table = s3db . survey_translate if ( r . component_id == None ) : table . file . readable = False table . file . writable = False else : table . language . writable = False table . code . writable = False s3db . configure ( 'survey_translate' , deletable = False ) else : table = r . table s3_action_buttons ( r ) rows = db ( ( table . status == 1 ) ) . select ( table . id ) try : s3 . actions [ 1 ] [ 'restrict' ] . extend ( ( str ( row . id ) for row in rows ) ) except KeyError : s3 . actions [ 1 ] [ 'restrict' ] = [ str ( row . id ) for row in rows ] except IndexError : pass s3 . dataTableStyleAlert = [ str ( row . id ) for row in rows ] rows = db ( ( table . status == 3 ) ) . select ( table . id ) s3 . dataTableStyleDisabled = [ str ( row . id ) for row in rows ] s3 . dataTableStyleWarning = [ str ( row . id ) for row in rows ] rows = db ( ( table . status == 4 ) ) . select ( table . id ) s3 . dataTableStyleWarning . extend ( ( str ( row . id ) for row in rows ) ) s3db . configure ( 'survey_template' , orderby = 'survey_template.status' , create_next = URL ( c = 'survey' , f = 'template' ) , update_next = URL ( c = 'survey' , f = 'template' ) ) return True s3 . prep = prep def postp ( r , output ) : if r . component : template_id = r . id if ( r . component_name == 'translate' ) : s3_action_buttons ( r ) s3 . actions . extend ( [ dict ( label = str ( T ( 'Download' ) ) , _class = 'action-btn' , url = r . url ( method = 'translate_download' , component = 'translate' , component_id = '[id]' , representation = 'xls' ) ) , dict ( label = str ( T ( 'Upload' ) ) , _class = 'action-btn' , url = URL ( c = module , f = 'template' , args = [ template_id , 'translate' , '[id]' ] ) ) ] ) return output s3 . postp = postp if request . ajax : post = request . post_vars action = post . get ( 'action' ) template_id = post . get ( 'parent_id' ) section_id = post . get ( 'section_id' ) section_text = post . get ( 'section_text' ) if ( ( action == 'section' ) and ( template_id != None ) ) : id = db . survey_section . insert ( name = section_text , template_id = template_id , cloned_section_id = section_id ) if ( id is None ) : print 'Failed to insert record' return s3db . configure ( 'survey_template' , listadd = False ) output = s3_rest_controller ( rheader = s3db . survey_template_rheader ) return output
require an openvz os template .