Rewrite badge display logic.

This moves the badge display logic to be executed upon parse.
This way, we no longer need to perform expensive operations
on the database on page display.

Deploy: All client pages containing badges need their parser
cache purged for this to work correctly.
Change-Id: Ibf0d38f7e31fb48be7b2c2914fa34efd8f8ec373