learning-unlimited/ESP-Website — pull request #897 by jmoldow (2014-01-05 21:01:11+00:00)
Title: Fixes various bugs with user types code

Partially resolves Github issue #646. Changes
Program.setup_user_filters() to be a classmethod, and calls it at class
definition time. This should eliminate any caching bugs that would cause
Program.students(), etc. to be undefined after retrieving a Program
directly from the cache.

Defines the classmethod ESPUser.create_membership_methods(), and calls
it from ESPUser.__init__() rather than having the code directly included
in __init__(). Unfortunately, this method cannot be called at class
definition time in order to resolve #646; see the commit message for
commit 2874259dbcc3 for the reason why. But now that this method exists,
it can be called at cache retrieval time if necessary, though this
commit does not do that.

Adds optional parameter use_tag to ESPUser.getAllUserTypes() and
ESPUser.getTypes(). It defaults to True, but when it is False, the
user_types Tag is ignored and the default user types are always
returned.

Extends ESPUser.create_membership_methods() to make sure that all of the
default user types have membership methods defined, because some (such
as isStudent()) are used in the code even if that user type isn't
included in the Tag override. It starts by defining all the membership
methods for the default types as returning False, and then overwrites
them as necessary. This fixes a bug in the splashcon.learningu.org
website, where no pages could be loaded because ESPAuthMiddleware always
calls ESPUser.getGrade(), which always calls ESPUser.isStudent(); but
splashcon.learningu.org did not have the Student user type defined in
its user_types Tag.