Bug 951897 - Expose ssl_only attributive of Product to REST API #34

Merged
merged 1 commit into from Jan 13, 2014

2 participants

@rail
Mozilla member

No description provided.

@rhelmer rhelmer commented on the diff Jan 13, 2014
apps/api/views.py
@@ -136,6 +136,7 @@ def product_add(request):
# check languages
langs = request.POST.getlist('languages')
locales = product_details.languages.keys()
+ ssl_only = bool(request.POST.get('ssl_only', False) == "true")
@rhelmer
Mozilla member
rhelmer added a line comment Jan 13, 2014

why is the bool(... == "true") necessary, isn't this enough?

ssl_only = request.POST.get('ssl_only', False)

? Is it because if ssl_only is set it'll be type str not bool?

@rhelmer
Mozilla member
rhelmer added a line comment Jan 13, 2014

So I think the nice way to do this would be with django forms (BooleanField), but I think this version of django is too old and still treats it as str (looks like it was fixed in 1.3, tuxedo is still 1.2) ... can wait until we upgrade, lgtm

@rail
Mozilla member
rail added a line comment Jan 13, 2014

Is it because if ssl_only is set it'll be type str not bool?

Yes.
I find that bool(...) is easier to read, kind of a return type of the code on the right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rhelmer rhelmer merged commit 6ae9084 into mozilla:master Jan 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment