Swap the person membership middleware around

We run the middleware to handle the main memberships first so it doesn't
overwrite the information that the _primary membership adds.
Fix npm-shrinkwrap.json
set edit interface tab to view tab when click edit button

use the window.location.hash to work out which tab is currently selected
and make sure that tab is selected in the edit interface before
displaying it.

Fixes #522
check for id on org save redirect and fall back to _id

if there's no id then url is /organization/undefined which is a 404

This should work around #532 but the real solution is to make sure that
saving things goes through popit-api's validate-body middleware to stop
the issue happening in the first place
post_deploy_actions.bash should have a #!/bin/bash shebang line
Add "set -e" to post_deploy_actions.bash

If there are any errors (e.g. permission problems preventing the
creation of ../node) we should exit as soon as that happens.
GEM_HOME & PATH shouldn't have a relative path

This can cause confusing errors where resources packaged in gems can't
be found.
delete memberships from a person

Remove all the memberships related to a person that are not in the list
of uploaded memberships.
Does not remove primary membership yet.
make sure primary membership is deleted correctly

If deleting the primary membership then we have to remove the values in
the inputs further up the page otherwise this is recreated
Always match active tab when switching to edit view

If the tab on the view section has been programatically set then there
isn't a location hash to the existing code doesn't work. This code
resolves this by working out which tab is selected via classes.

Fixes #522
Move log files to the new applogs directory

The log directory is now only writable by root and the applogs directory
will be logrotated properly.
Update mongodb package name to mongodb-org
use fs-extra for moving image files on upload

means that even if the source and destination paths are on different
partitions it will work
do not save blank entries for other_names etc

Without this clicking add for other_names etc and then not filling in
any details and then clicking save will result in a blank entry in the
other_names field of the person. This then causes #528 to occur when
saving a photo so we remove any entries that are entirely blank.
explicitly set other_name etc to undefined when saving

We need to remove these by hand when they are empty as the set method
ignores undefined keys.

Fixes #547
use update instead of save for image operations

This means that if something is broken in the other aspects of the data,
such as other_names not having a name which was possible due to a bug,
then the photo operation will still occur without error as the
validation isn't being fired on the entire object. Without this you end
up with a 500 error and you can't delete any photos.

Fixes #528
Fix jshint errors
prevent overlap of input backgrounds on political tab

add a bit of top margin and also remove grey background from select2
elements to stop the grey backgrounds on the political tab mashing into
each other

Fixes #526
fix problems with multiple edit tabs displaying

before we match the active edit tab and the active view tab hide the
content of the currently active edit tab as the easy tabs API doesn't
seem to do this for us.

Fixes #544
Update to latest version of popit-api

This incorporates the fix for elasticsearch timing out after bulk
requests.