コード例 #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)
コード例 #2
0
ファイル: signal_handlers.py プロジェクト: Elchi3/kuma
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)
コード例 #3
0
ファイル: views.py プロジェクト: 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()
コード例 #4
0
ファイル: test_utils.py プロジェクト: Elchi3/kuma
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
コード例 #5
0
ファイル: test_utils.py プロジェクト: Elchi3/kuma
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
コード例 #6
0
ファイル: test_utils.py プロジェクト: Elchi3/kuma
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()
コード例 #7
0
ファイル: test_utils.py プロジェクト: teacherstrange/kuma
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
コード例 #8
0
ファイル: test_utils.py プロジェクト: teacherstrange/kuma
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
コード例 #9
0
ファイル: test_utils.py プロジェクト: teacherstrange/kuma
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()
コード例 #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
コード例 #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
コード例 #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()