#NEWLINE# def index( ) : #NEWLINE# #INDENT# " Module's Home Page " #NEWLINE# try : #NEWLINE# #INDENT# module_name = settings . modules [ module ] . name_nice #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# module_name = T ( 'Person Registry' ) #NEWLINE# #UNINDENT# s3db . table ( 'pr_address' ) #NEWLINE# def prep( r ) : #NEWLINE# #INDENT# if ( r . representation == 'html' ) : #NEWLINE# #INDENT# if ( r . id or r . method ) : #NEWLINE# #INDENT# redirect ( URL ( f = 'person' , args = request . args ) ) #NEWLINE# #UNINDENT# #UNINDENT# return True #NEWLINE# #UNINDENT# s3 . prep = prep #NEWLINE# def postp( r , output ) : #NEWLINE# #INDENT# if isinstance ( output , dict ) : #NEWLINE# #INDENT# pr_gender_opts = s3db . pr_gender_opts #NEWLINE# table = db . pr_person #NEWLINE# gender = [ ] #NEWLINE# for g_opt in pr_gender_opts : #NEWLINE# #INDENT# query = ( ( table . deleted == False ) & ( table . gender == g_opt ) ) #NEWLINE# count = db ( query ) . count ( ) #NEWLINE# gender . append ( [ str ( pr_gender_opts [ g_opt ] ) , int ( count ) ] ) #NEWLINE# #UNINDENT# pr_age_group_opts = s3db . pr_age_group_opts #NEWLINE# dtable = db . pr_physical_description #NEWLINE# age = [ ] #NEWLINE# for a_opt in pr_age_group_opts : #NEWLINE# #INDENT# query = ( ( ( table . deleted == False ) & ( table . pe_id == dtable . pe_id ) ) & ( dtable . age_group == a_opt ) ) #NEWLINE# count = db ( query ) . count ( ) #NEWLINE# age . append ( [ str ( pr_age_group_opts [ a_opt ] ) , int ( count ) ] ) #NEWLINE# #UNINDENT# total = int ( db ( ( table . deleted == False ) ) . count ( ) ) #NEWLINE# output . update ( module_name = module_name , gender = json . dumps ( gender ) , age = json . dumps ( age ) , total = total ) #NEWLINE# #UNINDENT# if r . interactive : #NEWLINE# #INDENT# if ( not r . component ) : #NEWLINE# #INDENT# label = READ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label = UPDATE #NEWLINE# #UNINDENT# linkto = r . resource . crud . _linkto ( r ) ( '[id]' ) #NEWLINE# s3 . actions = [ dict ( label = str ( label ) , _class = 'action-btn' , url = str ( linkto ) ) ] #NEWLINE# #UNINDENT# r . next = None #NEWLINE# return output #NEWLINE# #UNINDENT# s3 . postp = postp #NEWLINE# output = s3_rest_controller ( 'pr' , 'person' ) #NEWLINE# response . view = 'pr/index.html' #NEWLINE# response . title = module_name #NEWLINE# return output