def membership_status(user): """ Return membership status, irrespective of waiver status. (Companies don't care about participant waiver status, so ignore it). """ # Status is one external query per user. Expensive! (We should refactor...) membership = geardb.user_membership_expiration(user)['membership'] # We report Active/Expired, since companies don't care about waiver status if membership['active']: return 'Active' if membership['expires']: return 'Expired {}'.format(membership['expires'].isoformat()) return 'Missing'
def get(self, request, *args, **kwargs): user = self.get_object() try_cache = bool(request.GET.get('try_cache')) membership = geardb_utils.user_membership_expiration(user, try_cache) return JsonResponse(membership)
def test_expiration_no_emails(self): """ Test users with no email addresses. """ self.assertIsNone(geardb.user_membership_expiration(None)) self.assertIsNone(geardb.user_membership_expiration(AnonymousUser()))
def get(self, request, *args, **kwargs): user = self.get_object() return JsonResponse(geardb_utils.user_membership_expiration(user))