# -*- coding: utf-8 -*-
"""
.. module:: dj-stripe.mixins.

   :synopsis: dj-stripe Mixins.

.. moduleauthor:: Daniel Greenfield (@pydanny)

"""

from __future__ import unicode_literals

from django.conf import settings

from . import settings as djstripe_settings
from .models import Plan, Customer


class PaymentsContextMixin(object):
    """Adds plan context to a view."""

    def get_context_data(self, **kwargs):
        """Inject STRIPE_PUBLIC_KEY and plans into context_data."""
        context = super(PaymentsContextMixin, self).get_context_data(**kwargs)
        context.update({
            "STRIPE_PUBLIC_KEY": settings.STRIPE_PUBLIC_KEY,
            "plans": Plan.objects.all(),
        })
        return context


class SubscriptionMixin(PaymentsContextMixin):
    """Adds customer subscription context to a view."""

    def get_context_data(self, *args, **kwargs):
        """Inject is_plans_plural and customer into context_data."""
        context = super(SubscriptionMixin, self).get_context_data(**kwargs)
        context['is_plans_plural'] = Plan.objects.count() > 1
        context['customer'], _created = Customer.get_or_create(
            subscriber=djstripe_settings.subscriber_request_callback(self.request))
        context['subscription'] = context['customer'].subscription
        return context

@@ -183,42 +183,8 @@
 ls%0A%0A
-from django.conf import settings%0A%0A
 from
@@ -583,16 +583,25 @@
 C_KEY%22: 
+djstripe_
 settings

Update mixins.py