Update TWLight/users/views.py
Added get_valid_partner_authorizations under an else condition so that it is not used unnecessarily, and to better reflect the fact that we are dealing with a list of auths, not users.
@@ -693,15 +693,16 @@ class AuthorizedUsers(APIView):
# We're ignoring streams here, because the API operates at the partner
# level. This is fine for the use case we built it for (Wikilink tool)
- valid_partner_auths = get_valid_partner_authorizations(pk)
+ valid_partner_auths = None
- # List only those users who have been active lately,
- # that is, do not list the users who had last logged in more than two weeks ago
+ # For Bundle partners, get auths for users who logged in within the last 2 weeks.
if partner.authorization_method == partner.BUNDLE:
valid_partner_auths = valid_partner_auths.filter(
- user__editor__user__last_login__gt=timezone.now() - timedelta(weeks=2)
+ user__last_login__gt=timezone.now() - timedelta(weeks=2)
)
-
+ # Otherwise, get all valid auths for this partner.
+ else:
+ valid_partner_auths = get_valid_partner_authorizations(pk)
users = User.objects.filter(authorizations__in=valid_partner_auths).distinct()
serializer = UserSerializer(users, many=True)
