-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audit_customer_subscription fails when subscription == null #22
Comments
How is this? I can send a pull request.
|
I think changing L17 to https://github.com/GoodCloud/django-zebra/blob/master/zebra/utils.py#L17 |
So what exactly is the point of this function? I dont see any usage within Zebra and if it throws an exception when there is no subscription how do you check what kind of account status someone has through a template? I modified this function (as above) and created a template tag so I display templates based on current subscriptions. How are other accomplishing this same task? |
The purpose of the function is to provide a single point for quickly determining the status of a given customer's subscription. Obviously we missed the use case where the subscription does not exist, as you pointed out above. In my project I'm still using the original version of the code we created and never ran in to this issue. I'm not using it at the template level since it does result in a call to Stripe, instead I call the function once at the beginning of a session and keep the result in the session. I believe as it is currently written the functionality doesn't quite match the docstring, either. Originally the audit method returned a boolean and only support 3 states 5ce7d46#zebra/conf/defaults.py The reason I don't want to mix concepts per your suggestion above is because if the exception is a key error it means there is a status which is unaccounted for in https://github.com/GoodCloud/django-zebra/blob/master/zebra/conf/options.py#L39 and I believe raising an exception in the case is the best thing to do so nothing slips by if Stripe updates their statuses. All this to say it looks like this needs some much overdue attention and upon a closer examination there's a lot more we could do to correct the functionality. |
Auditing a customer subscription for a newly created customer object fails when subscription data has not been created. It looks like Customer.subscription is null on creation and if this isnt updated before audit_customer_subscription it fails because subscription doesnt have a status.
*** AttributeError: 'NoneType' object has no attribute 'status'
The text was updated successfully, but these errors were encountered: