-
-
Notifications
You must be signed in to change notification settings - Fork 933
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
Added campaign_name field to Donation model #335
Conversation
if fixed_amount: | ||
try: | ||
initial = {'amount': Decimal(fixed_amount)} | ||
initial = {'amount': Decimal(fixed_amount), 'campaign': campaign} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind reformatting that to multiple lines?
LGTM Of course if we want to store more info about campaigns than just the name maybe it'd be better to have a separate campaign data model and have an optional foreign key in the donation model. That allows us to have in theory easy metadata storage and is future proof. E.g. imagine having a campaign page with just the heart for that campaign. In fact you could consider this fundraiser the first campaign we could use this system for. |
@@ -160,6 +161,11 @@ class PaymentForm(forms.Form): | |||
), | |||
) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no newline between fields (you can remove the one above expires
please)
The complexity of code without tests is starting to make me nervous. Would you like to write some? :tests: <-- where is a good icon when I need it? |
There is is: 🐐 |
Reference (et al): http://www.obeythetestinggoat.com/ |
) | ||
return redirect(donation) | ||
else: | ||
if 'amount' in form.errors: | ||
show_amount = True | ||
else: | ||
fixed_amount = request.GET.get('amount') or None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't do that, it will break with empty GET parameters.
I pushed some tests here.. the submitting donation form test doesn't work yet, mocking is not really working as it should (maybe I used wrong url?). I am too tired to work on this longer today though. Not sure about tomorrow yet. Sorry! |
|
||
response = self.client.post(reverse('fundraising:donate'), { | ||
'amount': 100, | ||
'number': '4242424242424242', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number, cvc and expires data is not submitted to our form view, the form actually only submits the stripe_token
that is set by our JavaScript. Card data never hits our servers :) So simply set a stripe_token
to something and it should be valid.
9fd9703
to
1fbcbf0
Compare
I fixed all the things you commented on, thanks! I am still not able to mock Stripe requests despite mocking all of the urls. Looking at this, there is definitely more magic involved than just trying to mock the request with |
a459d4f
to
fe54e1b
Compare
Uh finally! For some reason mocking API calls via setUpClass didn't work at all. It only worked when I added the mocking decorator directly on the test. Anyway, then together with @bmispelon we've decided that mocking API calls isn't really a good idea, because Stripe wanted us to return a very particular response. So these last tests I added are patching Stripe methods and it works. Is this all ok? |
* stripe calls in form.make_donation method instead of donate view * tests of donate view * tests of make_donation * logging if creation of stripe Customer failed
Meanwhile I and @oinopion took a look and refactor |
@asendecka The reason why I fell back to just catching Check out There is also a pretty awesome example for how to catch all the other exceptions in Python below that list errors in the Stripe docs, under "Handling errors".
I think in case a Now that you've already started the refactor, let's merge #342 into this and refactor it completely. |
Are going to be able to merge this small feature this pull request was about before this campaign ends? |
Merged in 9e9d176. |
No description provided.