#NEWLINE# def get_subscription_properties_by_user( couch_user ) : #NEWLINE# #INDENT# def _is_paying_subscription( subscription ) : #NEWLINE# #INDENT# NON_PAYING_SERVICE_TYPES = [ SubscriptionType . TRIAL , SubscriptionType . EXTENDED_TRIAL , SubscriptionType . SANDBOX , SubscriptionType . INTERNAL ] #NEWLINE# NON_PAYING_PRO_BONO_STATUSES = [ ProBonoStatus . YES , ProBonoStatus . DISCOUNTED ] #NEWLINE# paying = ( subscription . service_type not in NON_PAYING_SERVICE_TYPES ) #NEWLINE# paying = ( paying and ( subscription . pro_bono_status not in NON_PAYING_PRO_BONO_STATUSES ) ) #NEWLINE# return paying #NEWLINE# #UNINDENT# all_subscriptions = [ ] #NEWLINE# paying_subscribed_editions = [ ] #NEWLINE# subscribed_editions = [ ] #NEWLINE# for domain_name in couch_user . domains : #NEWLINE# #INDENT# ( plan_version , subscription ) = Subscription . get_subscribed_plan_by_domain ( domain_name ) #NEWLINE# subscribed_editions . append ( plan_version . plan . edition ) #NEWLINE# if ( subscription is not None ) : #NEWLINE# #INDENT# all_subscriptions . append ( subscription ) #NEWLINE# #UNINDENT# if ( ( subscription is not None ) and _is_paying_subscription ( subscription ) ) : #NEWLINE# #INDENT# paying_subscribed_editions . append ( plan_version . plan . edition ) #NEWLINE# #UNINDENT# #UNINDENT# def _is_one_of_editions( edition ) : #NEWLINE# #INDENT# return ( 'yes' if ( edition in subscribed_editions ) else 'no' ) #NEWLINE# #UNINDENT# def _is_a_pro_bono_status( status ) : #NEWLINE# #INDENT# return ( 'yes' if ( status in [ s . pro_bono_status for s in all_subscriptions ] ) else 'no' ) #NEWLINE# #UNINDENT# def _is_on_extended_trial( ) : #NEWLINE# #INDENT# service_types = [ s . service_type for s in all_subscriptions ] #NEWLINE# return ( 'yes' if ( SubscriptionType . EXTENDED_TRIAL in service_types ) else 'no' ) #NEWLINE# #UNINDENT# def _max_edition( ) : #NEWLINE# #INDENT# for edition in paying_subscribed_editions : #NEWLINE# #INDENT# assert ( edition in [ e [ 0 ] for e in SoftwarePlanEdition . CHOICES ] ) #NEWLINE# #UNINDENT# return ( max ( paying_subscribed_editions ) if paying_subscribed_editions else '' ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'is_on_community_plan' : _is_one_of_editions ( SoftwarePlanEdition . COMMUNITY ) , #NEWLINE# 'is_on_standard_plan' : _is_one_of_editions ( SoftwarePlanEdition . STANDARD ) , #NEWLINE# 'is_on_pro_plan' : _is_one_of_editions ( SoftwarePlanEdition . PRO ) , #NEWLINE# 'is_on_pro_bono_plan' : _is_a_pro_bono_status ( ProBonoStatus . YES ) , #NEWLINE# 'is_on_discounted_plan' : _is_a_pro_bono_status ( ProBonoStatus . DISCOUNTED ) , #NEWLINE# 'is_on_extended_trial_plan' : _is_on_extended_trial ( ) , #NEWLINE# 'max_edition_of_paying_plan' : _max_edition ( ) , #NEWLINE# #UNINDENT# }