Add a cron helper which clears old requests.

This applies to both email change requests, and to new user requests.
They are removed at the 3 day point (providing a gap to ensure that
we can't remove any requests that might still be valid, and also in
case the user clicks the link in that day - they'll get a nicer error).

In the case of new user requests, the cron task also emails the team
leader that requested the account, to let them know that the request
expired without being activated.

Change-Id: Ibf18341f8d0a75404da9b5e8607b896a5dfb92c6
Add a helper method to see if an email address is used.

Check the LDAP database, the new users database and the pending
email change database.

Change-Id: I647fe9bbde16277abd58a33ce9661c704295543e
More useful exceptions.

Change-Id: I5f29ea0db61a7947a2eb88996a76865242d4f46b
Break out a base sqlite wrapper that doesn't use usernames.

It's useful not to have to key these by username, and instead just
just have a base class which allows for arbitrary id keys to be used.

Change-Id: I504274bf0192b1f4d1d08495a5f010ab2fcfe8b0
Break the Aged wrapping functionality into its own class tree.

So that it can be used without the item needing to be username keyed.
Also add a class which brings it back in so that the exsting classes
continue working as they did without change.

Change-Id: I90510fa5bf8f929510adfa4901e9c5f30b326dcd
Fix variable name.

Since this is no longer username keyed, this isn't really a username.

Change-Id: Ied369d047fe8dba528597835c6fd1bbd44af7e07
Move the sqlite connection to reduce cicrular dependencies.

Change-Id: I6208455064d4511c6845e04ad87c7717c530807d
Factor out time conversion for re-use.

Change-Id: Ic206cf49fee486e65f27d6c6896885d1e763f160
Use the newer style way of fallback setting attributes.

According to the internet, this is now preferred over direct access
to __dict__.

Change-Id: I9d0b8e8f598ca48cac2b9292e03bd8bc91dede7f
Make it possible to have optional db properties.

Change-Id: I5942b590a17b7fade7fb852d09d12adeee48cbd7
Avoid filling the props collection with Nones.

If the database doesn't have a useful value for us, it's more useful
to represent this as a missing value, than to have it as a None.

Change-Id: I7d8ace7fe97fd26cc928e541bd1c54b0ff3e3483
If created without an id, get this from the db when inserted.

This is most useful when the id is a numeric incremented value.

Change-Id: Ia9589f2b26c94954bbd3e0d47dfef5d444afd136
Rename mailer methods in preparation for replacement.

Change-Id: I037b5cd924e0610fb52e10c95e3c770916ee5dbf
Add a PendingSend wrapper for emails that havne't been sent yet.

This is gonig to be used as part of a replacement mailer that doesn't
send emails as part of the web requests.

Change-Id: I9da6a3def73b6eed52c76dbf4494cb7d4e1e3370
Save emails to the db rather than sending immediately.

Introduce functionality to save requested emails into the sqlite
database rather than sending them directly. This should give us
greater control over when & how they're sent, as well as giving us
a record of what emails are sent. Add a config option which allows
for direct sending if desired (though the database will still be
populated).

Add tests for the mailer, particularly the new functionality, but
nothing as yet for actually sending the emails.

Have cron make use of a new helper function which sends the next
50 emails from the database, though we may want a specific script
that can be run more often.

Change-Id: I7efc93e68547313f5cfaa16d43288a811116457b
Remove the hacky dump-emails-to-files mechanism.

This was used for testing before emails went via the sqlite database
and is now therefore redundant. Remove it, and update all the tests
to use new helpers which query the database.

Change-Id: Ie445096a1c8899219c0aab040d3a20e2ababe5b0
Change email addresses to example.com.

This means that if we do end up send email to any of them, it won't
go anywhere. I've ignored the @srobo.org addresses, since we also
know those won't go anywhere.

Change-Id: I7e9c6c44decf1471fd80ff14aca6f8b76eeef813
Fix #2183: Reject emails that can't work.

This modifies the registration page (only) to reject emails that don't
conform to the general pattern of a@b.cc. This does not ensure that
the email is valid, but prevents wildly invalid data being entered.
Validation is done both in JS and on the backend, and the input field
is updated to make use of HTML5 validation too.

Change-Id: I8263dc9b8ecfedc6b10939f6234585e1a4df831e
Move test to own class to avoid redundant setup/teardown.

The setup/teardown aren't needed for the email validity checks, so
it may as well have its own class.

Change-Id: Ie3e52531d7bd1f84424257501c15a90b67148db9
Add a helper for logging actions.

This provides a simple way to easily log plenty of information without
needing to worry about the boilerplate formatting it.

Change-Id: I01e9158273e867c3c903877a9bce4a87b6cbb69d