run-tests: make it harder to ignore test failures

It seems that the behaviour where we wouldn't run the country-specific
test if the core tests failed was unhelpful, in that you might not
realise that some of those tests were failing.  The concern with
running them all was you might miss a test failure that had scrolled
off the top of the terminal.  To address that, while still running
all of the tests, this commit keeps track of whether any of the
commands failed, and, if so, prints out an error in red and exits
non-zero.
Catch CommandError rather than SystemExit in tests of commands.

Prior to Django 1.5, when a command raised an exception it would
be caught and a SystemExit raised instead so it was correct to
catch SystemExit when testing for this. With Django 1.5, the
CommandError itself propagates - see

https://docs.djangoproject.com/en/1.5/releases/1.5/#miscellaneous

So we should catch that.
Stop using deprecated django.utils.simplejson.

Replace import of simplejson from django.utils with a straight
import of simplejson.

Since we already had simplejson installed from requirements.txt,
this is the version which would have been used anyway by the import
from django.utils. See

https://docs.djangoproject.com/en/1.5/releases/1.5/#system-version-of-simplejson-no-longer-used

for details.

Just to note, we currently have a mix of using simplejson 3.3.2 from PyPI
and json from the standard library, which is based on simplejson 2.0.9
according to the Django 1.5 release notes. It would be nice to note where
we really need simplejson rather than just json.
Import slugify from django.utils.text rather than django.templates.

Hopefully this will have no effect at all, but it's slightly neater.
The slugify function is now available from django.utils.text - this
gives you just the function rather than one decorated as a template
filter, and is now the recommended place to get it.

I've also reordered a few other imports to make them more consistent.

A couple of tests needed updating as the argument to slugify should always
be in unicode.
Tidy up some odd whitespace.

Mostly deleting trailing whitespace, but a little bit of replacing tabs
with spaces and removing spaces in assignments and function application.
No need to load url from the future - we're in the future!

As of Django 1.5, there is no need to load the url tag from future
as that version of the tag becomes the default - for full details see

https://docs.djangoproject.com/en/dev/releases/1.5/#overview

Although it would be OK to leave these loads in for now,
given that we're targeting a single version of Django, we may as well
remove them immediately rather than having to remember to do it when we
move to Django 1.9 and url is removed from the future template tag library:

https://docs.djangoproject.com/en/dev/internals/deprecation/#deprecation-removed-in-1-9
Add ALLOWED_HOSTS setting.

Add the ALLOWED_HOSTS setting required for production Django instances
from Django 1.5. I'm doing this from the conf/general.yml file so that
we can vary it for different vhosts easily on our dev/staging sites.

Also replace calls to request.META.HTTP_HOST with request.get_host
so as to avoid bypassing this security measure. See

https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts

for details.
Change requirements to Django 1.5.5 (latest stable 1.5)
Update django version and django-nose

django-nose 1.1 is incompatible with Django 1.6, so update that too.
See:

https://github.com/django-nose/django-nose/issues/123
Change mimetype arguments to content_type in line with deprecation.

There is a deprecation warning for the mimetype argument to
render_to_response and HttpResponse, so change these arguments to
the new way which is content_type.
Switch to input type email for email input boxes.

In Django 1.6, the default widget for EmailField uses the email
input type:

https://docs.djangoproject.com/en/dev/releases/1.6/#minor-features

For consistency with automatically generated email input fields, we
should change those manually coded in our templates to match this.
Remove trailing whitespace
Add *args to get_redirect_url calls for Django 1.6.

In Django 1.6, the signature of RedirectView.get_redirect_url changed
to include *args:

https://docs.djangoproject.com/en/1.6/ref/class-based-views/base/#django.views.generic.base.RedirectView.get_redirect_url

Also a bit of whitespace tidying.
Update dependencies based on a pip-review.

Note that we're leaving mimeparse pinned to 0.1.3 as there is a
problem installing 0.1.4.
Pin version of argparse.
Pin other things installed as dependencies.
Use persistent database connections for non-staging sites.

See details of the new feature here:

https://docs.djangoproject.com/en/dev/releases/1.6/#persistent-database-connections

For now we're setting connections to last for 300 seconds on non-staging
sites. This is a number from intuition rather than evidence, so any
improvements welcome!
Load cycle and firstof from future.

By default, the current cycle and firstof template tags don't escape variables
to avoid XSS attacks. This will be fixed in Django 1.8: we may as well start
using the new style tags now.

https://docs.djangoproject.com/en/dev/releases/1.6/#changes-to-cycle-and-firstof
PEP8ification
Fix failing ZA test.

Best to create models with unicode strings.