djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

I want to add different apps to a Particular Plan. #84

Closed vaibhav-jain closed 8 years ago

vaibhav-jain commented 8 years ago

I want to know how to implement Plan with features like Freshdesk do. Like they can enable or disable features within a Particular Plan

smirolo commented 8 years ago

In decorators.py there is a requires_paid_subscription decorator which is part of the flexible security framework.

What you would do to allow/deny access to certain features (i.e. URLs) based on the subscribed-to Plan is to decorate the view implementing the feature.

Example: urls.py:

 from saas.decorators import requires_paid_subscription
 from .views import FeatureView

urlpatterns = [
...
url(r'^(?P<organization>[a-z])/(?P<subscribed_plan>[a-z])/feature/',
    requires_paid_subscription(FeatureView.as_view()), name='feature'),
...
]

It is pretty straightforward to create new sets of decorators such that the Plan does not have to be part of the URL. Let me know if that would be helpful. Maybe something like:

def requires_paid_subscription(function=None,
    organization_kwarg_slug='organization',
    plans=None):      # plans is a list of ``Plan`` organization must be subscribed to.
vaibhav-jain commented 8 years ago

@smirolo thanks for your reply. I think this we will help us.