openhatch/oh-mainline — pull request #54 by e2jk (2012-08-12 16:13:45+00:00)
Title: Fix saving a portfolio entry (fixes issue #748)

When creating a new project from `/+portfolio/editor/`, the code was trying to get the pk of the project by getting it from `request.POST['portfolio_entry__pk']`. However for new projects there is no such element, so a MultiValueDictKeyError exception was launched, and since it was not catched it resulted in a 500 error.

My change uses the `.get` function of the `request.POST` object to retrieve that value, and gives it the value of `undefined` if it's not present. The next line already checks `if pk == 'undefined':`, so now there is no more exception being triggered, and the new project can be created.

This fixes https://openhatch.org/bugs/issue748