Esempio n. 1
0
def unsubscribe_payments_on_user_delete(sender, instance, **kwargs):
    """Cancel Stripe subscriptions before deleting User."""
    user = instance
    if user.stripe_customer_id:
        # This may raise an exception if the Stripe API call fails.
        # This will stop User deletion while an admin investigates.
        cancel_stripe_customer_subscription(user.stripe_customer_id)
Esempio n. 2
0
def unsubscribe_payments_on_user_delete(sender, instance, **kwargs):
    """Cancel Stripe subscriptions before deleting User."""
    user = instance
    if user.stripe_customer_id:
        # This may raise an exception if the Stripe API call fails.
        # This will stop User deletion while an admin investigates.
        cancel_stripe_customer_subscription(user.stripe_customer_id)
Esempio n. 3
0
File: views.py Progetto: B3nnyL/kuma
    def scrub_user():
        # Before doing anything, cancel any active subscriptions first.
        if user.stripe_customer_id:
            for subscription in cancel_stripe_customer_subscription(
                    user.stripe_customer_id):
                UserSubscription.set_canceled(request.user, subscription.id)

        # From the User abstract class
        user.first_name = ""
        user.last_name = ""
        user.email = ""

        # All User attributes
        user.timezone = ""
        user.locale = ""
        user.homepage = ""
        user.title = ""
        user.fullname = ""
        user.organization = ""
        user.location = ""
        user.bio = ""
        user.irc_nickname = ""
        user.website_url = ""
        user.github_url = ""
        user.mozillians_url = ""
        user.twitter_url = ""
        user.linkedin_url = ""
        user.facebook_url = ""
        user.stackoverflow_url = ""
        user.discourse_url = ""
        user.stripe_customer_id = ""
        user.save()

        user.socialaccount_set.all().delete()
        user.key_set.all().delete()
Esempio n. 4
0
def test_cancel_stripe_customer_no_subscriptions(mock_sub, mock_cust):
    '''A stripe customer with no subscriptions returns True.'''
    cancel_stripe_customer_subscription('cust_id')
    assert not mock_sub.called
Esempio n. 5
0
def test_cancel_stripe_customer_multiple_subscriptions(mock_sub, mock_cust):
    '''A stripe customer's subscriptions can be cancelled.'''
    cancel_stripe_customer_subscription('cust_id')
    assert mock_sub.call_count == 2
Esempio n. 6
0
def test_cancel_stripe_customer_subscription(mock_sub, mock_cust):
    '''A stripe customer's subscriptions can be cancelled.'''
    cancel_stripe_customer_subscription('cust_id')
    mock_sub.return_value.delete.assert_called_once_with()
Esempio n. 7
0
def test_cancel_stripe_customer_no_subscriptions(mock_sub, mock_cust):
    """A stripe customer with no subscriptions returns True."""
    cancel_stripe_customer_subscription("cust_id")
    assert not mock_sub.called
Esempio n. 8
0
def test_cancel_stripe_customer_multiple_subscriptions(mock_sub, mock_cust):
    """A stripe customer's subscriptions can be cancelled."""
    cancel_stripe_customer_subscription("cust_id")
    assert mock_sub.call_count == 2
Esempio n. 9
0
def test_cancel_stripe_customer_subscription(mock_sub, mock_cust):
    """A stripe customer's subscriptions can be cancelled."""
    cancel_stripe_customer_subscription("cust_id")
    mock_sub.return_value.delete.assert_called_once_with()
Esempio n. 10
0
def test_cancel_stripe_customer_no_subscriptions(mock_sub, mock_cust):
    '''A stripe customer with no subscriptions returns True.'''
    cancel_stripe_customer_subscription('cust_id')
    assert not mock_sub.called
Esempio n. 11
0
def test_cancel_stripe_customer_multiple_subscriptions(mock_sub, mock_cust):
    '''A stripe customer's subscriptions can be cancelled.'''
    cancel_stripe_customer_subscription('cust_id')
    assert mock_sub.call_count == 2
Esempio n. 12
0
def test_cancel_stripe_customer_subscription(mock_sub, mock_cust):
    '''A stripe customer's subscriptions can be cancelled.'''
    cancel_stripe_customer_subscription('cust_id')
    mock_sub.return_value.delete.assert_called_once_with()