def sites_for_org():
 try:
  org = request.args[0]
 except:
  result = current.xml.json_message(False, 400, 'No Org provided!')
 else:
  try:
   org = int(org)
  except:
   result = current.xml.json_message(False, 400, 'Invalid Org provided!')
  else:
   stable = s3db.org_site
   if settings.get_org_branches():
    btable = s3db.org_organisation_branch
    query = ((btable.organisation_id == org) & (btable.deleted != True))
    rows = db(query).select(btable.branch_id)
    org_ids = ([row.branch_id for row in rows] + [org])
    query = (stable.organisation_id.belongs(org_ids) & (stable.deleted != True))
   else:
    query = ((stable.organisation_id == org) & (stable.deleted != True))
   rows = db(query).select(stable.site_id, stable.name, orderby=stable.name)
   result = rows.json()
 finally:
  response.headers['Content-Type'] = 'application/json'
  return result

def sites_for_org ( ) : try : org = request . args [ 0 ] except : result = current . xml . json_message ( False , 400 , 'No Org provided!' ) else : try : org = int ( org ) except : result = current . xml . json_message ( False , 400 , 'Invalid Org provided!' ) else : stable = s3db . org_site if settings . get_org_branches ( ) : btable = s3db . org_organisation_branch query = ( ( btable . organisation_id == org ) & ( btable . deleted != True ) ) rows = db ( query ) . select ( btable . branch_id ) org_ids = ( [ row . branch_id for row in rows ] + [ org ] ) query = ( stable . organisation_id . belongs ( org_ids ) & ( stable . deleted != True ) ) else : query = ( ( stable . organisation_id == org ) & ( stable . deleted != True ) ) rows = db ( query ) . select ( stable . site_id , stable . name , orderby = stable . name ) result = rows . json ( ) finally : response . headers [ 'Content-Type' ] = 'application/json' return result
used to provide the list of sites for an organisation - used in user registration & assets access via the .