Permalink
Browse files

Bug 951897 - Expose ssl_only attributive of Product to REST API

  • Loading branch information...
1 parent 897ab22 commit 5a101b579c9ebfd63716dffecffe94b6c1fe8fe5 @rail rail committed Jan 8, 2014
Showing with 4 additions and 1 deletion.
  1. +2 −0 apps/api/templates/api/docs/product_add.html
  2. +2 −1 apps/api/views.py
@@ -14,6 +14,8 @@
* ``languages``: Language code for this product. Add this parameter multiple
times for multiple languages. If undefined or empty, location is is considered
not language-specific. (Known languages: {{ languages|join:", " }})
+* ``ssl_only``: Use "true" to serve the product over HTTPS only. Any other
+ value is interpreted as false.
{% endblock %}
{% block errorcodes %}
View
@@ -136,14 +136,15 @@ 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")
if [l for l in langs if l not in locales]:
return xml.error('invalid language code(s)', errno=103)
# save new product
products = Product.objects.filter(name__exact=prodname)
if not products:
try:
- prod = Product(name=prodname)
+ prod = Product(name=prodname, ssl_only=ssl_only)
prod.save()
for lang in langs:
prod.languages.create(lang=lang)

0 comments on commit 5a101b5

Please sign in to comment.