From 980569de68418f34a37373f50be550d341892ba2 Mon Sep 17 00:00:00 2001 From: Adarnof Date: Thu, 22 Feb 2018 17:54:35 -0500 Subject: [PATCH] Do not attempt to serialize User models --- .../services/management/commands/verify_service_accounts.py | 2 +- allianceauth/services/tasks.py | 5 +++-- allianceauth/services/tests/test_tasks.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/allianceauth/services/management/commands/verify_service_accounts.py b/allianceauth/services/management/commands/verify_service_accounts.py index ba53c80a..84f2bc49 100644 --- a/allianceauth/services/management/commands/verify_service_accounts.py +++ b/allianceauth/services/management/commands/verify_service_accounts.py @@ -9,5 +9,5 @@ class Command(BaseCommand): def handle(self, *args, **options): for u in User.objects.all(): - validate_services(u) + validate_services(u.pk) self.stdout.write(self.style.SUCCESS('Verified all user service accounts.')) diff --git a/allianceauth/services/tasks.py b/allianceauth/services/tasks.py index ec567235..d3bcdd16 100644 --- a/allianceauth/services/tasks.py +++ b/allianceauth/services/tasks.py @@ -2,7 +2,7 @@ import logging import redis from celery import shared_task - +from django.contrib.auth.models import User from .hooks import ServicesHook REDIS_CLIENT = redis.Redis() @@ -38,7 +38,8 @@ def only_one(function=None, key="", timeout=None): @shared_task(bind=True) -def validate_services(self, user): +def validate_services(self, pk): + user = User.objects.get(pk=pk) logger.debug('Ensuring user {} has permissions for active services'.format(user)) # Iterate through services hooks and have them check the validity of the user for svc in ServicesHook.get_services(): diff --git a/allianceauth/services/tests/test_tasks.py b/allianceauth/services/tests/test_tasks.py index 25dc2570..39474690 100644 --- a/allianceauth/services/tests/test_tasks.py +++ b/allianceauth/services/tests/test_tasks.py @@ -18,7 +18,7 @@ class ServicesTasksTestCase(TestCase): services_hook.get_services.return_value = [svc] - validate_services.delay(user=self.member) + validate_services.delay(self.member.pk) self.assertTrue(services_hook.get_services.called) self.assertTrue(svc.validate_user.called)