#NEWLINE# def _get_subscription( self ) : #NEWLINE# #INDENT# ' Get current subscription settings ' #NEWLINE# db = current . db #NEWLINE# s3db = current . s3db #NEWLINE# pe_id = current . auth . user . pe_id #NEWLINE# stable = s3db . pr_subscription #NEWLINE# ftable = s3db . pr_filter #NEWLINE# query = ( ( stable . pe_id == pe_id ) & ( stable . deleted != True ) ) #NEWLINE# left = ftable . on ( ( ftable . id == stable . filter_id ) ) #NEWLINE# row = db ( query ) . select ( stable . id , stable . notify_on , stable . frequency , ftable . id , ftable . query , left = left , limitby = ( 0 , 1 ) ) . first ( ) #NEWLINE# output = { #NEWLINE# #INDENT# 'pe_id' : pe_id , #NEWLINE# #UNINDENT# } #NEWLINE# get_vars = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if row : #NEWLINE# #INDENT# s = getattr ( row , 'pr_subscription' ) #NEWLINE# f = getattr ( row , 'pr_filter' ) #NEWLINE# rtable = s3db . pr_subscription_resource #NEWLINE# query = ( ( rtable . subscription_id == s . id ) & ( rtable . deleted != True ) ) #NEWLINE# rows = db ( query ) . select ( rtable . id , rtable . resource , rtable . url , rtable . last_check_time , rtable . next_check_time ) #NEWLINE# if f . query : #NEWLINE# #INDENT# filters = json . loads ( f . query ) #NEWLINE# for ( k , v ) in filters : #NEWLINE# #INDENT# if ( v is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( k in get_vars ) : #NEWLINE# #INDENT# if ( type ( get_vars [ k ] ) is list ) : #NEWLINE# #INDENT# get_vars [ k ] . append ( v ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# get_vars [ k ] = [ get_vars [ k ] , v ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# get_vars [ k ] = v #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# output . update ( { #NEWLINE# #INDENT# 'id' : s . id , #NEWLINE# 'filter_id' : f . id , #NEWLINE# 'get_vars' : get_vars , #NEWLINE# 'resources' : rows , #NEWLINE# 'notify_on' : s . notify_on , #NEWLINE# 'frequency' : s . frequency , #NEWLINE# 'method' : [ 'EMAIL' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# output . update ( { #NEWLINE# #INDENT# 'id' : None , #NEWLINE# 'filter_id' : None , #NEWLINE# 'get_vars' : get_vars , #NEWLINE# 'resources' : None , #NEWLINE# 'notify_on' : stable . notify_on . default , #NEWLINE# 'frequency' : stable . frequency . default , #NEWLINE# 'method' : [ 'EMAIL' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return output