crits/crits — pull request #262 by thelok (2014-10-02 14:15:35+00:00)
Title: Targets case sensitivity issue

This is a minor change yet a fairly large change if you're suffering from this issue.

Some parts of the code used target emails in a case sensitive manner, while other areas used it in a case insensitive manner (e.g. bob@gmail.com might be different than Bob@gmail.com).

I wrote a quick management command script to test if you have duplicate targets. If you do, then you will need to resolve the issue either by letting the script delete the duplicate by passing in the -d option or by manually merging your data. By default the script does not modify any data, it merely prints out any duplicates detected by comparing email addresses of targets.

There were multiple consequences if you were suffering from this issue:

* When listing the Targets jtable, the email counts might have been lower than expected (e.g. bob@gmail.com might have 4 referenced emails and Bob@gmail.com might have 2 referenced emails, but the correct number for that single target should really be 6, which is the sum of the numbers)
* The campaigns details page, if you click on the targets tab then valid targets might not show up if they have been duplicated due to the case sensitivity.
* When you access a target that has duplicates due to the email case sensitivity issue, then you might be accessing a different target than expected.

This pull request makes the following fixes:

* Added a command to remove duplicate targets that might have existed due to the case sensitivity (identified by comparing the email_address field).
* The counts should now be accurate when listing targets.
* When displaying Campaign details, targets in the "to:" field of emails should now appear in the "Targets" tab.
* When accessing targets by email address, the search should now be case insensitive (e.g. no difference between Bob@gmail.com and bob@gmail.com). Also within URL requests such as listing the details pages for the emails.