radremedy/radremedy — pull request #158 by radioprotector (2014-11-14 06:51:33+00:00)
Title: User management enhancements

Closes #114, #141, #142, and #144.

Most changes are described in [issue 141](https://github.com/radremedy/radremedy/issues/141#issuecomment-62293497).

The default location changes are outlined in [issue 142](https://github.com/radremedy/radremedy/issues/142#issuecomment-62665266).

The following new environment variables are required and accessed in the configs:
- `RAD_EMAIL_USERNAME` - Username of email account (such as info).
- `RAD_EMAIL_ADDRESS` - Full address of email account (such as info@radremedy.org).
- `RAD_EMAIL_PASSWORD` - Self-explanatory.
- `RAD_EMAIL_SERVER` - Address of the email server.
- `RAD_SECRET_KEY` - Secret key used for Flask session management. Only required for production configs.

I was able to get the emails in a consolidated location - `email_utils.py`. This doesn't require any additional dependencies. The actual generation of emails support both plain-text and HTML.

To this end, there's a new `remedy/templates/email` folder. We're re-using the Jinja2 templating engine to generate these emails, so we get all the nice features with that. Each email has a separate `.txt` and `.html` template so we're not forcing the user to view only plain-text or HTML-formatted emails. For HTML-formatted emails (you can see a sample screenshot on [issue 141](https://github.com/radremedy/radremedy/issues/141#issuecomment-63003098)), there's a base `email-layout.html` file used by all the templates.

A couple of other general things I did:
- Ensuring that we're consistently using `url_for` to generate links in our templates.
- Fixed up the CSS used by select2 so that the placeholder text uses the same font as the rest of the application.
- Removed name and email as required fields for submitting a resource error. I think we might want to consider locking this down so that only authenticated users can use it. Since we don't have a CAPTCHA or anything else on the form, it's likely to be a source of spam.