Example #1
0
 def get_context_data(self, **kwargs):
     context = super(PersonView, self).get_context_data(**kwargs)
     cards_qs = self.request.user.cards.filter(is_saved=True).order_by('-added')
     context.update({
         'cards': {
             'test': cards_qs.filter(api_type=CreditCard.TEST),
             'live': cards_qs.filter(api_type=CreditCard.LIVE),
         },
         'stripe_live_settings_valid': stripe_live_settings_valid(),
         'stripe_test_settings_valid': stripe_test_settings_valid(),
         'dwolla_live_settings_valid': dwolla_live_settings_valid(),
         'dwolla_test_settings_valid': dwolla_test_settings_valid(),
     })
     if self.object.dwolla_live_can_connect():
         context['dwolla_oauth_url'] = dwolla_customer_oauth_url(
             self.request.user, LIVE, self.request)
     return context
Example #2
0
    def get_context_data(self, **kwargs):
        context = super(SummaryView, self).get_context_data(**kwargs)

        context.update({
            'attendees': self.order.attendees.all(),
            'new_card_form': getattr(self, 'new_card_form', None),
            'choose_card_form': getattr(self, 'choose_card_form', None),
            'dwolla_form': getattr(self, 'dwolla_form', None),
            'check_form': getattr(self, 'check_form', None),
            'net_balance': self.net_balance,
            'STRIPE_PUBLISHABLE_KEY': getattr(settings,
                                              'STRIPE_PUBLISHABLE_KEY',
                                              ''),
            'STRIPE_TEST_PUBLISHABLE_KEY': getattr(settings,
                                                   'STRIPE_TEST_PUBLISHABLE_KEY',
                                                   ''),
        })
        user = self.request.user
        dwolla_obj = user if user.is_authenticated() else self.order
        dwolla_connected = dwolla_obj.dwolla_live_connected() if self.event.api_type == Event.LIVE else dwolla_obj.dwolla_test_connected()
        dwolla_can_connect = dwolla_obj.dwolla_live_can_connect() if self.event.api_type == Event.LIVE else dwolla_obj.dwolla_test_can_connect()
        if dwolla_can_connect:
            kwargs = {
                'event_slug': self.event.slug,
                'organization_slug': self.event.organization.slug,
            }
            if self.kwargs.get('code') and not self.request.user.is_authenticated():
                kwargs['code'] = self.order.code
            next_url = reverse('brambling_event_order_summary', kwargs=kwargs)
            context['dwolla_oauth_url'] = dwolla_customer_oauth_url(
                dwolla_obj, self.event.api_type, self.request, next_url)
        if dwolla_connected:
            context.update({
                'dwolla_is_connected': True,
                'dwolla_user_id': dwolla_obj.dwolla_user_id if self.event.api_type == Event.LIVE else dwolla_obj.dwolla_test_user_id
            })
        context.update(self.summary_data)
        return context