Comments (4)
How is this? I can send a pull request.
if (hasattr(customer, 'suspended') and customer.suspended):
result = AUDIT_RESULTS['suspended']
else:
try:
result = AUDIT_RESULTS[customer.subscription.status]
except AttributeError, err:
result = AUDIT_RESULTS['no_subscription']
return result
from django-zebra.
I think changing L17 to if hasattr(customer, 'subscription') and customer.subscription is not None:
would be more concise in this case since there is already exception handling in place there for an entirely different purpose. (In an effort to try to avoid mixing concepts).
https://github.com/GoodCloud/django-zebra/blob/master/zebra/utils.py#L17
from django-zebra.
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?
from django-zebra.
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.
from django-zebra.
Related Issues (17)
- Update the version on PyPi HOT 2
- Validate webhooks are actually from stripe HOT 1
- Missing semicolons in javascript HOT 1
- This project is dead HOT 8
- rvnkfjldndchbtctfb
- Upgrade Stripe.js to Ver 2
- Webhooks broken in Django 1.6 HOT 1
- Transfer Webhooks like transfer.paid and transfer.updated
- Custom User Model Breaking Profile Functionality HOT 11
- Order won't submit on Mobile Safari
- zebra not syncing with database on makemigrations?
- Add test coverage HOT 2
- Getting error when initialising django-zebra HOT 2
- Convert docs to sphinx and put on RTFD.org HOT 2
- 'User' object has no attribute 'stripe_id' HOT 7
- need model howto HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-zebra.