Merge pull request #87 from Chunjie/master

[Bug 48052499] fix bug
[48134037] fix crash without assigning a JD to candiate and clicking 'save'

This is caused by without checking the selection_opening_id == 0.

Fix it, and also code refactor to split the func from action 'api'

Signed-off-by: Henry Chen <hchen@vmware.com>
Merge pull request #89 from Henry-CF/bugfix2

[48134037] fix crash without assigning a JD to candiate and clicking 'save'
[Bug 48135749] fix bug

  "We're sorry, but something went wrong." by deleting a user