<s> from os import path <EOL> try : <EOL> import json <EOL> except ImportError : <EOL> try : <EOL> import simplejson as json <EOL> except : <EOL> import gluon . contrib . simplejson as json <EOL> from gluon import * <EOL> from gluon . storage import Storage <EOL> from s3 import * <EOL> THEME = "<STR_LIT>" <EOL> class index ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> request = current . request <EOL> response = current . response <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> if current . auth . is_logged_in ( ) : <EOL> grid = "<STR_LIT>" <EOL> else : <EOL> grid = "<STR_LIT>" <EOL> latest_projects = DIV ( _id = "<STR_LIT>" , <EOL> _class = "<STR_LIT>" % grid ) <EOL> lappend = latest_projects . append <EOL> db = current . db <EOL> s3db = current . s3db <EOL> table = s3db . project_project <EOL> table_drrpp = s3db . project_drrpp <EOL> query = ( table . deleted != True ) & ( table . approved_by != None ) <EOL> rows = db ( query ) . select ( table . id , <EOL> table . name , <EOL> table_drrpp . activities , <EOL> table . organisation_id , <EOL> table . start_date , <EOL> left = table_drrpp . on ( table . id == table_drrpp . project_id ) , <EOL> limitby = ( <NUM_LIT:0> , <NUM_LIT:3> ) ) <EOL> project_ids = [ r . project_project . id for r in rows ] <EOL> ltable = s3db . project_location <EOL> gtable = s3db . gis_location <EOL> query = ( ltable . deleted != True ) & ( ltable . project_id == table . id ) & ( gtable . id == ltable . location_id ) & ( gtable . level == "<STR_LIT>" ) <EOL> locations = db ( query ) . select ( ltable . project_id , <EOL> gtable . L0 ) <EOL> odd = True <EOL> for row in rows : <EOL> countries = [ l . gis_location . L0 for l in locations if l . project_location . project_id == row . project_project . id ] <EOL> location = "<STR_LIT:U+002CU+0020>" . join ( countries ) <EOL> if odd : <EOL> _class = "<STR_LIT>" % grid <EOL> else : <EOL> _class = "<STR_LIT>" % grid <EOL> card = DIV ( DIV ( A ( row . project_project . name , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" , args = [ row . project_project . id ] ) ) , <EOL> _class = "<STR_LIT>" % grid , <EOL> ) , <EOL> DIV ( "<STR_LIT>" % s3db . org_organisation_represent ( row . project_project . organisation_id ) , <EOL> _class = "<STR_LIT>" % grid , <EOL> ) , <EOL> DIV ( SPAN ( "<STR_LIT>" % row . project_project . start_date , <EOL> _class = "<STR_LIT>" ) , <EOL> SPAN ( "<STR_LIT>" % location , <EOL> _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" % grid , <EOL> ) , <EOL> DIV ( row . project_drrpp . activities or "<STR_LIT>" , <EOL> _class = "<STR_LIT>" % grid , <EOL> ) , <EOL> _class = _class , <EOL> ) <EOL> lappend ( card ) <EOL> odd = False if odd else True <EOL> login = current . auth . login ( inline = True ) <EOL> appname = request . application <EOL> s3 = response . s3 <EOL> if current . session . s3 . debug : <EOL> s3 . scripts . append ( "<STR_LIT>" % appname ) <EOL> else : <EOL> s3 . scripts . append ( "<STR_LIT>" % appname ) <EOL> s3 . jquery_ready . append ( '''<STR_LIT>''' ) <EOL> return dict ( title = "<STR_LIT>" , <EOL> form = login , <EOL> latest_projects = latest_projects , <EOL> ) <EOL> class register ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> request = current . request <EOL> response = current . response <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> T = current . T <EOL> auth = current . auth <EOL> _settings = auth . settings <EOL> table = _settings . table_user <EOL> table . language . default = T . accepted_language <EOL> table . organisation_id . widget = S3OrganisationAutocompleteWidget ( ) <EOL> table . organisation_id . requires = IS_COMBO_BOX ( "<STR_LIT>" , <EOL> current . s3db . org_organisation_id . attr . requires ) <EOL> _settings . register_onaccept = register_onaccept <EOL> form = auth . register ( js_validation = False ) <EOL> _form = form [ <NUM_LIT:0> ] <EOL> _form [ - <NUM_LIT:1> ] = TR ( TD ( _class = "<STR_LIT>" ) , <EOL> TD ( _class = "<STR_LIT>" ) , <EOL> TD ( INPUT ( _type = "<STR_LIT>" , <EOL> _value = T ( "<STR_LIT>" ) ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> _form [ <NUM_LIT:0> ] = TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( INPUT ( _id = "<STR_LIT>" , <EOL> _class = "<STR_LIT:string>" , <EOL> _type = "<STR_LIT:text>" , <EOL> _name = "<STR_LIT>" , <EOL> _size = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> _form [ <NUM_LIT:1> ] = TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( INPUT ( _id = "<STR_LIT>" , <EOL> _class = "<STR_LIT:string>" , <EOL> _type = "<STR_LIT:text>" , <EOL> _name = "<STR_LIT>" , <EOL> _size = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> _form [ <NUM_LIT:2> ] = TR ( TD ( _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( form . custom . widget . organisation_id , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> _form [ <NUM_LIT:3> ] = TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( INPUT ( _id = "<STR_LIT>" , <EOL> _class = "<STR_LIT:string>" , <EOL> _type = "<STR_LIT:text>" , <EOL> _name = "<STR_LIT:email>" , <EOL> _size = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> _form [ <NUM_LIT:4> ] = TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( INPUT ( _id = "<STR_LIT>" , <EOL> _type = "<STR_LIT:password>" , <EOL> _name = "<STR_LIT:password>" , <EOL> _class = "<STR_LIT:password>" , <EOL> ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> _form [ <NUM_LIT:5> ] = TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( INPUT ( _id = "<STR_LIT>" , <EOL> _type = "<STR_LIT:password>" , <EOL> _name = "<STR_LIT>" , <EOL> _class = "<STR_LIT:password>" , <EOL> ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> append = _form [ <NUM_LIT:2> ] . append <EOL> append ( <EOL> TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( SELECT ( OPTION ( _value = "<STR_LIT>" ) , <EOL> OPTION ( T ( "<STR_LIT>" ) , <EOL> _value = "<STR_LIT:1>" ) , <EOL> OPTION ( T ( "<STR_LIT>" ) , <EOL> _value = "<STR_LIT:2>" ) , <EOL> OPTION ( T ( "<STR_LIT>" ) , <EOL> _value = "<STR_LIT:3>" ) , <EOL> OPTION ( T ( "<STR_LIT>" ) , <EOL> _value = "<STR_LIT:4>" ) , <EOL> OPTION ( T ( "<STR_LIT>" ) , <EOL> _value = "<STR_LIT:5>" ) , <EOL> _name = "<STR_LIT>" , <EOL> _id = "<STR_LIT>" , <EOL> _class = "<STR_LIT>" <EOL> ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> ) <EOL> append ( <EOL> TR ( TD ( SPAN ( "<STR_LIT>" , _class = "<STR_LIT>" ) , <EOL> DIV ( _rel = "<STR_LIT>" , <EOL> _class = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( LABEL ( DIV ( "<STR_LIT>" % T ( "<STR_LIT>" ) ) , <EOL> _id = "<STR_LIT>" , <EOL> _for = "<STR_LIT>" ) , <EOL> _class = "<STR_LIT>" ) , <EOL> TD ( TEXTAREA ( _id = "<STR_LIT>" , <EOL> _class = "<STR_LIT:text>" , <EOL> _name = "<STR_LIT>" , <EOL> _rows = "<STR_LIT>" , <EOL> _cols = "<STR_LIT>" , <EOL> ) , <EOL> _class = "<STR_LIT>" ) , <EOL> _id = "<STR_LIT>" <EOL> ) <EOL> ) <EOL> s3 = response . s3 <EOL> appname = request . application <EOL> if s3 . debug : <EOL> s3 . scripts . append ( "<STR_LIT>" % appname ) <EOL> s3 . scripts . append ( "<STR_LIT>" % appname ) <EOL> else : <EOL> s3 . scripts . append ( "<STR_LIT>" % appname ) <EOL> s3 . scripts . append ( "<STR_LIT>" % appname ) <EOL> s3 . jquery_ready . append ( "<STR_LIT>" . join ( ( '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' , str ( _settings . password_min_length ) , '''<STR_LIT>''' , str ( T ( "<STR_LIT>" ) ) , '''<STR_LIT>''' ) ) ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> return dict ( form = form ) <EOL> def register_onaccept ( form ) : <EOL> """<STR_LIT>""" <EOL> req_vars = form . request_vars <EOL> position = req_vars . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> reason = req_vars . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> db = current . db <EOL> table = db . auth_user <EOL> db ( table . id == form . vars . id ) . update ( comments = "<STR_LIT>" % ( position , reason ) ) <EOL> class contact ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> request = current . request <EOL> response = current . response <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> if request . env . request_method == "<STR_LIT:POST>" : <EOL> vars = request . post_vars <EOL> result = current . msg . send_email ( <EOL> to = "<STR_LIT>" , <EOL> subject = vars . subject , <EOL> message = vars . message , <EOL> reply_to = vars . address , <EOL> ) <EOL> if result : <EOL> response . confirmation = "<STR_LIT>" <EOL> s3 = response . s3 <EOL> if s3 . cdn : <EOL> if s3 . debug : <EOL> s3 . scripts . append ( "<STR_LIT>" ) <EOL> else : <EOL> s3 . scripts . append ( "<STR_LIT>" ) <EOL> else : <EOL> if s3 . debug : <EOL> s3 . scripts . append ( "<STR_LIT>" % request . application ) <EOL> else : <EOL> s3 . scripts . append ( "<STR_LIT>" % request . application ) <EOL> s3 . jquery_ready . append ( <EOL> '''<STR_LIT>''' ) <EOL> response . title = "<STR_LIT>" <EOL> return dict ( <EOL> ) <EOL> class about ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> response = current . response <EOL> request = current . request <EOL> T = current . T <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> return dict ( <EOL> title = T ( "<STR_LIT>" ) , <EOL> ) <EOL> class admin ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> auth = current . auth <EOL> s3_has_role = auth . s3_has_role <EOL> system_roles = auth . get_system_roles ( ) <EOL> ADMIN = system_roles . ADMIN <EOL> ORG_ADMIN = system_roles . ORG_ADMIN <EOL> if s3_has_role ( ADMIN ) | s3_has_role ( ORG_ADMIN ) : <EOL> response = current . response <EOL> request = current . request <EOL> T = current . T <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> panel_list = [ A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT:user>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" , args = [ <NUM_LIT:1> , "<STR_LIT>" ] ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" , args = [ <NUM_LIT:6> , "<STR_LIT>" ] ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" , args = "<STR_LIT>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" , args = "<STR_LIT>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" , args = "<STR_LIT>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT:location>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" ) <EOL> ) , <EOL> A ( T ( "<STR_LIT>" ) , <EOL> _href = URL ( c = "<STR_LIT>" , f = "<STR_LIT>" ) <EOL> ) , <EOL> ] <EOL> return dict ( item = UL ( * panel_list , <EOL> _id = "<STR_LIT>" ) ) <EOL> else : <EOL> redirect ( URL ( c = "<STR_LIT:default>" , f = "<STR_LIT:index>" ) ) <EOL> class analysis ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> response = current . response <EOL> request = current . request <EOL> T = current . T <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> return dict ( <EOL> title = T ( "<STR_LIT>" ) , <EOL> ) <EOL> class get_started ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> response = current . response <EOL> request = current . request <EOL> T = current . T <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> return dict ( <EOL> ) <EOL> class login ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> response = current . response <EOL> request = current . request <EOL> T = current . T <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> return dict ( <EOL> form = current . auth . login ( ) <EOL> ) <EOL> class mypage ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> auth = current . auth <EOL> response = current . response <EOL> request = current . request <EOL> T = current . T <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> response . title = T ( "<STR_LIT>" ) <EOL> return dict ( <EOL> title = T ( "<STR_LIT>" ) , <EOL> ) <EOL> class organisations ( ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self ) : <EOL> request = current . request <EOL> response = current . response <EOL> response . title = "<STR_LIT>" <EOL> view = path . join ( request . folder , "<STR_LIT>" , "<STR_LIT>" , <EOL> THEME , "<STR_LIT>" , "<STR_LIT>" ) <EOL> try : <EOL> response . view = open ( view , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> from gluon . http import HTTP <EOL> raise HTTP ( <NUM_LIT> , "<STR_LIT>" % view ) <EOL> s3 = response . s3 <EOL> s3 [ "<STR_LIT>" ] = '<STR_LIT>' <EOL> tables = [ ] <EOL> table = request . vars . get ( "<STR_LIT>" , None ) <EOL> if table is None : <EOL> if s3 . debug : <EOL> append = s3 . scripts . append <EOL> appname = request . application <EOL> append ( "<STR_LIT>" % appname ) <EOL> append ( "<STR_LIT>" % appname ) <EOL> append ( "<STR_LIT>" % appname ) <EOL> append ( "<STR_LIT>" % appname ) <EOL> else : <EOL> s3 . scripts . append ( "<STR_LIT>" % request . application ) <EOL> s3 . js_global . append ( '''<STR_LIT>''' ) <EOL> s3request , list_fields = self . _regional ( ) <EOL> tables . append ( self . _table ( "<STR_LIT>" , s3request . resource , list_fields ) ) <EOL> s3request , list_fields = self . _groups ( ) <EOL> tables . append ( self . _table ( "<STR_LIT>" , s3request . resource , list_fields ) ) <EOL> else : <EOL> if table == "<STR_LIT>" : <EOL> s3request , list_fields = self . _groups ( ) <EOL> elif table == "<STR_LIT>" : <EOL> s3request , list_fields = self . _regional ( ) <EOL> current . s3db . configure ( s3request . resource . tablename , <EOL> list_fields = list_fields ) <EOL> return s3request ( ) <EOL> return dict ( tables = tables ) <EOL> @ staticmethod <EOL> def _regional ( ) : <EOL> """<STR_LIT>""" <EOL> T = current . T <EOL> s3request = s3_request ( "<STR_LIT>" , "<STR_LIT>" , extension = "<STR_LIT>" ) <EOL> f = ( FS ( "<STR_LIT>" ) . anyof ( [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) ) <EOL> s3request . resource . add_filter ( f ) <EOL> list_fields = [ "<STR_LIT:id>" , <EOL> "<STR_LIT:name>" , <EOL> "<STR_LIT>" , <EOL> ( T ( "<STR_LIT>" ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ( T ( "<STR_LIT>" ) , "<STR_LIT>" ) , <EOL> ] <EOL> return ( s3request , list_fields ) <EOL> @ staticmethod <EOL> def _groups ( ) : <EOL> """<STR_LIT>""" <EOL> T = current . T <EOL> s3db = current . s3db <EOL> table = s3db . org_organisation <EOL> table . address = Field . Method ( "<STR_LIT:address>" , <EOL> s3db . org_organisation_address ) <EOL> s3request = s3_request ( "<STR_LIT>" , "<STR_LIT>" , extension = "<STR_LIT>" ) <EOL> f = ( FS ( "<STR_LIT>" ) . anyof ( [ "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) ) <EOL> s3request . resource . add_filter ( f ) <EOL> list_fields = [ "<STR_LIT:id>" , <EOL> "<STR_LIT:name>" , <EOL> "<STR_LIT>" , <EOL> ( T ( "<STR_LIT>" ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> ( T ( "<STR_LIT>" ) , "<STR_LIT:address>" ) , <EOL> ( T ( "<STR_LIT>" ) , "<STR_LIT>" ) , <EOL> ] <EOL> return ( s3request , list_fields ) <EOL> @ staticmethod <EOL> def _table ( name , resource , field_list , limit = <NUM_LIT:10> , orderby = "<STR_LIT:name>" ) : <EOL> """<STR_LIT>""" <EOL> data = resource . select ( field_list , <EOL> limit = None , <EOL> orderby = orderby , <EOL> count = True , <EOL> represent = True ) <EOL> rfields = data [ "<STR_LIT>" ] <EOL> records = data [ "<STR_LIT>" ] <EOL> numrows = len ( records ) <EOL> rows = [ ] <EOL> cols = [ ] <EOL> for rfield in rfields : <EOL> colname = rfield . colname <EOL> cols . append ( { "<STR_LIT:name>" : colname , "<STR_LIT:label>" : rfield . label } ) <EOL> for i in xrange ( numrows ) : <EOL> if len ( rows ) == i : <EOL> rows . append ( [ ] ) <EOL> rows [ i ] . append ( records [ i ] [ colname ] ) <EOL> options = json . dumps ( { <EOL> "<STR_LIT>" : data [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ { "<STR_LIT>" : [ <NUM_LIT:0> ] } ] , <EOL> "<STR_LIT>" : [ { "<STR_LIT:name>" : col [ "<STR_LIT:name>" ] , <EOL> "<STR_LIT>" : False , <EOL> } for col in cols ] , <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : limit , <EOL> "<STR_LIT>" : True , <EOL> } ) <EOL> script = '''<STR_LIT>''' % XML ( options ) <EOL> current . response . s3 . js_global . append ( script ) <EOL> table = Storage ( cols = cols , <EOL> rows = rows , <EOL> ) <EOL> return table </s>
