from rest_framework.permissions import BasePermission

from ...settings import subscriber_request_callback
from ...utils import subscriber_has_active_subscription


class DJStripeSubscriptionPermission(BasePermission):
    """
    A permission to be used when wanting to permit users with active subscriptions.
    """

    def has_permission(self, request, view):
        """
        Check if the subscriber has an active subscription.

        Returns false if:
            * a subscriber isn't passed through the request

        See ``utils.subscriber_has_active_subscription`` for more rules.

        """
        try:
            subscriber_has_active_subscription(subscriber_request_callback(request))
        except AttributeError:
            return False

from rest_framework.permissions import BasePermission

from ...settings import subscriber_request_callback
from ...utils import subscriber_has_active_subscription


class DJStripeSubscriptionPermission(BasePermission):
    """
    A permission to be used when wanting to permit users with active subscriptions.
    """

    def has_permission(self, request, view) -> bool:
        """
        Check if the subscriber has an active subscription.

        Returns false if:
            * a subscriber isn't passed through the request

        See ``utils.subscriber_has_active_subscription`` for more rules.

        """
        try:
            return subscriber_has_active_subscription(
                subscriber_request_callback(request)
            )
        except AttributeError:
            return False

Fix missing return statement in DJStripeSubscriptionPermission
Fix missing return statement in DJStripeSubscriptionPermission

Fixes #1250

  from rest_framework.permissions import BasePermission
  
  from ...settings import subscriber_request_callback
  from ...utils import subscriber_has_active_subscription
  
  
  class DJStripeSubscriptionPermission(BasePermission):
      """
      A permission to be used when wanting to permit users with active subscriptions.
      """
  
-     def has_permission(self, request, view):
+     def has_permission(self, request, view) -> bool:
          """
          Check if the subscriber has an active subscription.
  
          Returns false if:
              * a subscriber isn't passed through the request
  
          See ``utils.subscriber_has_active_subscription`` for more rules.
  
          """
          try:
-             subscriber_has_active_subscription(subscriber_request_callback(request))
+             return subscriber_has_active_subscription(
+                 subscriber_request_callback(request)
+             )
          except AttributeError:
              return False
  
Fix missing return statement in DJStripeSubscriptionPermission
## Code Before:
from rest_framework.permissions import BasePermission

from ...settings import subscriber_request_callback
from ...utils import subscriber_has_active_subscription


class DJStripeSubscriptionPermission(BasePermission):
    """
    A permission to be used when wanting to permit users with active subscriptions.
    """

    def has_permission(self, request, view):
        """
        Check if the subscriber has an active subscription.

        Returns false if:
            * a subscriber isn't passed through the request

        See ``utils.subscriber_has_active_subscription`` for more rules.

        """
        try:
            subscriber_has_active_subscription(subscriber_request_callback(request))
        except AttributeError:
            return False

## Instruction:
Fix missing return statement in DJStripeSubscriptionPermission
## Code After:
from rest_framework.permissions import BasePermission

from ...settings import subscriber_request_callback
from ...utils import subscriber_has_active_subscription


class DJStripeSubscriptionPermission(BasePermission):
    """
    A permission to be used when wanting to permit users with active subscriptions.
    """

    def has_permission(self, request, view) -> bool:
        """
        Check if the subscriber has an active subscription.

        Returns false if:
            * a subscriber isn't passed through the request

        See ``utils.subscriber_has_active_subscription`` for more rules.

        """
        try:
            return subscriber_has_active_subscription(
                subscriber_request_callback(request)
            )
        except AttributeError:
            return False
