-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
86 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.dispatch import Signal | ||
|
||
# Define a signal for post-subscription | ||
post_subscribe = Signal() | ||
|
||
# Define a signal for post-cancellation | ||
post_cancel = Signal() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,5 +63,4 @@ packages = find: | |
zip_safe: False | ||
|
||
[options.extras_require] | ||
stripe = | ||
djstripe>=2.8.3 | ||
stripe = djstripe>=2.8.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class MyAppConfig(AppConfig): | ||
name = 'testapp' | ||
|
||
def ready(self): | ||
# Import and register signal handlers here | ||
print(dir()) | ||
from . import signal_handlers # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.dispatch import receiver | ||
|
||
from ckc.stripe.signals import post_subscribe, post_cancel | ||
from ckc.stripe.views import SubscribeViewSet | ||
from testapp.models import SubscriptionThroughModel | ||
|
||
|
||
@receiver(post_subscribe, sender=SubscribeViewSet) | ||
def subscribe_signal_handler(sender, **kwargs): | ||
""" example function for how to define a post subscribe signal handler. """ | ||
if sender != SubscribeViewSet: | ||
raise ValidationError('sender must be SubscribeViewSet') | ||
SubscriptionThroughModel.objects.get_or_create(user=kwargs['user'], subscription=kwargs['subscription']) | ||
|
||
@receiver(post_cancel, sender=SubscribeViewSet) | ||
def cancel_signal_handler(sender, **kwargs): | ||
if sender != SubscribeViewSet: | ||
raise ValidationError('sender must be SubscribeViewSet') | ||
SubscriptionThroughModel.objects.filter(user=kwargs['user'], subscription=kwargs['subscription']).delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters