def _add_share_to_user(request, username, via): try: user = User.objects.get(username=username) tz_offset = request.GET.get('tz', None) if via == 't': SharingHistory.add_share_from_twitter(user.profile, tz_offset) elif via == 'fb': SharingHistory.add_share_from_facebook(user.profile, tz_offset) elif via == 'qr': SharingHistory.add_share_from_qr_code(user.profile, tz_offset) elif via == 'p': SharingHistory.add_share_from_poster(user.profile, tz_offset) else: SharingHistory.add_share(user.profile, tz_offset) # Gaining a share triggers detection of completed challenges _trigger_challenge_detection(username) return username except User.DoesNotExist: # Ignore 'shared_by' cookies if they have been tampered with # or if the parent user has deleted their account in the meantime. return None
def test_complete_2_1(self): profile = self.get_profile('bob') eq_(0, profile.total_shares) SharingHistory.add_share_from_facebook(profile) self.assert_completion(profile, '2_1')