def as_html_description(transaction): provider = transaction.orig_organization subscriber = transaction.dest_organization look = re.match(DESCRIBE_BUY_PERIODS % { 'plan': r'(?P<plan>\S+)', 'ends_at': r'.*', 'humanized_periods': r'.*'}, transaction.descr) if not look: look = re.match(DESCRIBE_UNLOCK_NOW % { 'plan': r'(?P<plan>\S+)', 'unlock_event': r'.*'}, transaction.descr) if not look: look = re.match(DESCRIBE_UNLOCK_LATER % { 'plan': r'(?P<plan>\S+)', 'unlock_event': r'.*', 'amount': r'.*'}, transaction.descr) if not look: look = re.match(DESCRIBE_BALANCE % { 'plan': r'(?P<plan>\S+)'}, transaction.descr) if not look: # DESCRIBE_CHARGED_CARD, DESCRIBE_CHARGED_CARD_PROCESSOR # and DESCRIBE_CHARGED_CARD_PROVIDER. # are specially crafted to start with "Charge ..." look = re.match(r'Charge (?P<charge>\S+)', transaction.descr) if look: link = '<a href="%s">%s</a>' % (reverse('saas_charge_receipt', args=(subscriber, look.group('charge'),)), look.group('charge')) return transaction.descr.replace(look.group('charge'), link) return transaction.descr plan_link = ('<a href="%s%s/">%s</a>' % ( product_url(provider, subscriber), look.group('plan'), look.group('plan'))) return transaction.descr.replace(look.group('plan'), plan_link)
def get_success_url(self): redirect_path = validate_redirect_url( self.request.GET.get(REDIRECT_FIELD_NAME, None)) if hasattr(self, 'charge') and self.charge: if redirect_path: return '%s?%s=%s' % ( reverse('saas_charge_receipt', args=(self.charge.customer, self.charge.processor_key)), REDIRECT_FIELD_NAME, redirect_path) return reverse('saas_charge_receipt', args=(self.charge.customer, self.charge.processor_key)) if redirect_path: return redirect_path if self.sole_provider: return product_url(self.sole_provider, self.customer) return reverse('saas_organization_profile', args=(self.customer,))
def get_success_url(self): redirect_path = validate_redirect_url( self.request.GET.get(REDIRECT_FIELD_NAME, None)) if hasattr(self, 'charge') and self.charge: if redirect_path: return '%s?%s=%s' % (reverse( 'saas_charge_receipt', args=(self.charge.customer, self.charge.processor_key)), REDIRECT_FIELD_NAME, redirect_path) return reverse('saas_charge_receipt', args=(self.charge.customer, self.charge.processor_key)) if redirect_path: return redirect_path if self.sole_provider: return product_url(self.sole_provider, self.customer) return reverse('saas_organization_profile', args=(self.customer, ))
def as_html_description(transaction): provider = transaction.orig_organization subscriber = transaction.dest_organization look = re.match( DESCRIBE_BUY_PERIODS % { 'plan': r'(?P<plan>\S+)', 'ends_at': r'.*', 'humanized_periods': r'.*' }, transaction.descr) if not look: look = re.match( DESCRIBE_UNLOCK_NOW % { 'plan': r'(?P<plan>\S+)', 'unlock_event': r'.*' }, transaction.descr) if not look: look = re.match( DESCRIBE_UNLOCK_LATER % { 'plan': r'(?P<plan>\S+)', 'unlock_event': r'.*', 'amount': r'.*' }, transaction.descr) if not look: look = re.match(DESCRIBE_BALANCE % {'plan': r'(?P<plan>\S+)'}, transaction.descr) if not look: # DESCRIBE_CHARGED_CARD, DESCRIBE_CHARGED_CARD_PROCESSOR # and DESCRIBE_CHARGED_CARD_PROVIDER. # are specially crafted to start with "Charge ..." look = re.match(r'Charge (?P<charge>\S+)', transaction.descr) if look: link = '<a href="%s">%s</a>' % (reverse('saas_charge_receipt', args=( subscriber, look.group('charge'), )), look.group('charge')) return transaction.descr.replace(look.group('charge'), link) return transaction.descr plan_link = ('<a href="%s%s/">%s</a>' % (product_url( provider, subscriber), look.group('plan'), look.group('plan'))) return transaction.descr.replace(look.group('plan'), plan_link)
def as_html_description(transaction, provider=None): """ ``DESCRIBE_BALANCE`` transactions contain subscriber on both sides (orig_organization and dest_organization). We thus pass provider as an extra parameter to create URLs. """ if provider is None: provider = transaction.orig_organization subscriber = transaction.dest_organization look = re.match( DESCRIBE_BUY_PERIODS % {"plan": r"(?P<plan>\S+)", "ends_at": r".*", "humanized_periods": r".*"}, transaction.descr, ) if not look: look = re.match(DESCRIBE_UNLOCK_NOW % {"plan": r"(?P<plan>\S+)", "unlock_event": r".*"}, transaction.descr) if not look: look = re.match( DESCRIBE_UNLOCK_LATER % {"plan": r"(?P<plan>\S+)", "unlock_event": r".*", "amount": r".*"}, transaction.descr, ) if not look: look = re.match(DESCRIBE_BALANCE % {"plan": r"(?P<plan>\S+)"}, transaction.descr) if not look: # DESCRIBE_CHARGED_CARD, DESCRIBE_CHARGED_CARD_PROCESSOR # and DESCRIBE_CHARGED_CARD_PROVIDER. # are specially crafted to start with "Charge ..." look = re.match(r"Charge (?P<charge>\S+)", transaction.descr) if look: link = '<a href="%s">%s</a>' % ( reverse("saas_charge_receipt", args=(subscriber, look.group("charge"))), look.group("charge"), ) return transaction.descr.replace(look.group("charge"), link) return transaction.descr plan_link = '<a href="%s%s/">%s</a>' % (product_url(provider, subscriber), look.group("plan"), look.group("plan")) return transaction.descr.replace(look.group("plan"), plan_link)
def get_app_url(obj): return product_url(obj.organization)