<s> from __future__ import unicode_literals <EOL> from collections import OrderedDict <EOL> import sys <EOL> from django . apps import apps as django_apps <EOL> from django . conf import settings <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> PY3 = sys . version > "<STR_LIT:3>" <EOL> subscriber_request_callback = getattr ( settings , "<STR_LIT>" , ( lambda request : request . user ) ) <EOL> INVOICE_FROM_EMAIL = getattr ( settings , "<STR_LIT>" , "<STR_LIT>" ) <EOL> PAYMENTS_PLANS = getattr ( settings , "<STR_LIT>" , { } ) <EOL> PLAN_HIERARCHY = getattr ( settings , "<STR_LIT>" , { } ) <EOL> PAYMENT_PLANS = OrderedDict ( sorted ( PAYMENTS_PLANS . items ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) ) <EOL> PLAN_CHOICES = [ ( plan , PAYMENTS_PLANS [ plan ] . get ( "<STR_LIT:name>" , plan ) ) for plan in PAYMENTS_PLANS ] <EOL> PASSWORD_INPUT_RENDER_VALUE = getattr ( settings , '<STR_LIT>' , False ) <EOL> PASSWORD_MIN_LENGTH = getattr ( settings , '<STR_LIT>' , <NUM_LIT:6> ) <EOL> PRORATION_POLICY = getattr ( settings , '<STR_LIT>' , False ) <EOL> PRORATION_POLICY_FOR_UPGRADES = getattr ( settings , '<STR_LIT>' , False ) <EOL> CANCELLATION_AT_PERIOD_END = not getattr ( settings , '<STR_LIT>' , False ) <EOL> SEND_INVOICE_RECEIPT_EMAILS = getattr ( settings , "<STR_LIT>" , True ) <EOL> CURRENCIES = getattr ( settings , "<STR_LIT>" , ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) ) <EOL> ) <EOL> DEFAULT_PLAN = getattr ( settings , "<STR_LIT>" , None ) <EOL> PLAN_LIST = [ ] <EOL> for p in PAYMENTS_PLANS : <EOL> if PAYMENTS_PLANS [ p ] . get ( "<STR_LIT>" ) : <EOL> plan = PAYMENTS_PLANS [ p ] <EOL> plan [ '<STR_LIT>' ] = p <EOL> PLAN_LIST . append ( plan ) <EOL> trial_period_for_subscriber_callback = getattr ( settings , <EOL> "<STR_LIT>" , <EOL> getattr ( settings , "<STR_LIT>" , None ) <EOL> ) <EOL> DJSTRIPE_WEBHOOK_URL = getattr ( settings , "<STR_LIT>" , r"<STR_LIT>" ) <EOL> def plan_from_stripe_id ( stripe_id ) : <EOL> payment_plans = getattr ( settings , "<STR_LIT>" , { } ) <EOL> plan_id = None <EOL> for key in payment_plans . keys ( ) : <EOL> if payment_plans [ key ] . get ( "<STR_LIT>" ) == stripe_id : <EOL> plan_id = key <EOL> return plan_id <EOL> def _check_subscriber_for_email_address ( subscriber_model , message ) : <EOL> """<STR_LIT>""" <EOL> if ( "<STR_LIT:email>" not in subscriber_model . _meta . get_all_field_names ( ) ) and not hasattr ( subscriber_model , '<STR_LIT:email>' ) : <EOL> raise ImproperlyConfigured ( message ) <EOL> def get_subscriber_model ( ) : <EOL> """<STR_LIT>""" <EOL> SUBSCRIBER_MODEL = getattr ( settings , "<STR_LIT>" , None ) <EOL> if not SUBSCRIBER_MODEL : <EOL> from django . contrib . auth import get_user_model <EOL> subscriber_model = get_user_model ( ) <EOL> _check_subscriber_for_email_address ( subscriber_model , "<STR_LIT>" ) <EOL> return subscriber_model <EOL> subscriber_model = None <EOL> try : <EOL> subscriber_model = django_apps . get_model ( SUBSCRIBER_MODEL ) <EOL> except ValueError : <EOL> raise ImproperlyConfigured ( "<STR_LIT>" ) <EOL> except LookupError : <EOL> raise ImproperlyConfigured ( "<STR_LIT>" . format ( model = SUBSCRIBER_MODEL ) ) <EOL> _check_subscriber_for_email_address ( subscriber_model , "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> if not callable ( getattr ( settings , "<STR_LIT>" ) ) : <EOL> raise ImproperlyConfigured ( "<STR_LIT>" ) <EOL> else : <EOL> raise ImproperlyConfigured ( "<STR_LIT>" ) <EOL> return subscriber_model </s>
