def handle(self, *args, **kwargs): accounts = Account.objects.filter(twitter_id=None) if accounts: updated = lookup_twitter_ids(accounts) sys.stdout.write("%d account(s) updated\n" % updated) else: sys.stdout.write("All accounts have their Twitter IDs\n") sys.stdout.flush()
def test_lookup_twitter_ids(self): from carson.utils import lookup_twitter_ids a = Account.objects.create(twitter_username="******") ret = lookup_twitter_ids(Account.objects.all()) self.assertEqual(ret, 1) a = Account.objects.get(twitter_username="******") self.assertEqual(a.twitter_id, 160697962)
def populate_twitter_ids(self, request, queryset): updated = lookup_twitter_ids(queryset) self.message_user(request, "%d account(s) updated" % updated)