diff --git a/gregui/api/views/invitation.py b/gregui/api/views/invitation.py index 47343090e05242e1fd4304959c16d5955b7f7844..cadd633dc128f23b2cd937345b326ddf41d61f39 100644 --- a/gregui/api/views/invitation.py +++ b/gregui/api/views/invitation.py @@ -282,19 +282,19 @@ class InvitedGuestView(GenericAPIView): if request.user.is_anonymous: # If the user is not logged in then tell the client to take him through the manual registration process return SessionType.INVITE - elif person.fnr and person.fnr.source == "idporten": + if person.fnr and person.fnr.source == "idporten": # If the user has logged in through ID-porten the national ID number should have been # added to the person at this stage return SessionType.ID_PORTEN - elif person.feide_id: + if person.feide_id: # User is logged in and has a Feide ID attached to him, assume information about him has come from Feide return SessionType.FEIDE - else: - # Not expected, default to invite - logger.warning( - "unexpected_state_when_determining_session_type", person_id=person.id - ) - return SessionType.INVITE + + # Not expected, default to invite + logger.warning( + "unexpected_state_when_determining_session_type", person_id=person.id + ) + return SessionType.INVITE def post(self, request, *args, **kwargs): """ @@ -385,6 +385,7 @@ class InvitedGuestView(GenericAPIView): "message": f"cannot_update_fields: {illegal_fields}", }, ) + return None @staticmethod def _illegal_updates( @@ -400,8 +401,9 @@ class InvitedGuestView(GenericAPIView): continue if ( - changed_field == "first_name" or changed_field == "last_name" - ) and session_type == SessionType.ID_PORTEN: + changed_field in ("first_name", "last_name") + and session_type == SessionType.ID_PORTEN + ): # From ID-porten only the national ID-number is given, so the name must be what the # sponsor wrote, and can be changed continue @@ -419,15 +421,14 @@ class InvitedGuestView(GenericAPIView): if not attribute: # No existing value for field, so allow change continue - else: - # Quick fix to be able compare date with string - if changed_field == "date_of_birth": - if attribute.strftime("%Y-%m-%d") != person_data[changed_field]: - # There is an existing date value - illegal_field_updates.append(changed_field) - elif attribute != person_data[changed_field]: - # There is an existing value + # Quick fix to be able compare date with string + if changed_field == "date_of_birth": + if attribute.strftime("%Y-%m-%d") != person_data[changed_field]: + # There is an existing date value illegal_field_updates.append(changed_field) + elif attribute != person_data[changed_field]: + # There is an existing value + illegal_field_updates.append(changed_field) return illegal_field_updates @@ -478,9 +479,9 @@ class ResendInvitationView(UpdateModelMixin, APIView): invitemailer.queue_mail(link) else: # All the invitation links have expired, create a new one - invitations_to_resend = set( - [invitation_link.invitation for invitation_link in invitation_links] - ) + invitations_to_resend = { + invitation_link.invitation for invitation_link in invitation_links + } if len(invitations_to_resend) > 1: # Do not expected that a person has several open invitations, it could happen diff --git a/gregui/api/views/person.py b/gregui/api/views/person.py index 1d34920343c786f25aa32941b722cedaf710ec3b..0ebb8c35516a5d08fa65201b21a2c269f59c12a8 100644 --- a/gregui/api/views/person.py +++ b/gregui/api/views/person.py @@ -58,7 +58,7 @@ class PersonViewSet(mixins.RetrieveModelMixin, mixins.UpdateModelMixin, GenericV if getattr(instance, "_prefetched_objects_cache", None): # If 'prefetch_related' has been applied to a queryset, we need to # forcibly invalidate the prefetch cache on the instance. - instance._prefetched_objects_cache = {} + instance._prefetched_objects_cache = {} # pylint: disable=protected-access return Response(serializer.data) diff --git a/gregui/api/views/role.py b/gregui/api/views/role.py index da4b24c89768143cc52ca5d5217b0632325bb1ce..2c842f775bbcc30a29248a058ad1bb4e3f3d8223 100644 --- a/gregui/api/views/role.py +++ b/gregui/api/views/role.py @@ -17,9 +17,9 @@ class RoleInfoViewSet(ModelViewSet): permission_classes = [IsAuthenticated, IsSponsor] serializer_class = RoleSerializerUi - def partial_update(self, request, pk): + def partial_update(self, request, *args, **kwargs): try: - role = Role.objects.get(pk=pk) + role = Role.objects.get(pk=kwargs["pk"]) except Role.DoesNotExist: return Response(status=status.HTTP_400_BAD_REQUEST) sponsor = GregUserProfile.objects.get(user=self.request.user).sponsor @@ -34,7 +34,7 @@ class RoleInfoViewSet(ModelViewSet): serializer.update(role, serializer.validated_data) return Response(status=status.HTTP_200_OK) - def create(self, request): + def create(self, request, *args, **kwargs): sponsor = GregUserProfile.objects.get(user=self.request.user).sponsor with transaction.atomic(): serializer = self.serializer_class( diff --git a/gregui/api/views/userinfo.py b/gregui/api/views/userinfo.py index d07f249f08b1209c496baf9da234f97f9cec81a1..385a17095f221732c9122546dcbb5c721b2ed506 100644 --- a/gregui/api/views/userinfo.py +++ b/gregui/api/views/userinfo.py @@ -1,5 +1,5 @@ -from rest_framework.authentication import BaseAuthentication, SessionAuthentication -from rest_framework.permissions import AllowAny, BasePermission +from rest_framework.authentication import SessionAuthentication +from rest_framework.permissions import AllowAny from rest_framework.status import HTTP_403_FORBIDDEN from rest_framework.views import APIView from rest_framework.response import Response @@ -19,7 +19,7 @@ class UserInfoView(APIView): authentication_classes = [SessionAuthentication] permission_classes = [AllowAny] - def get(self, request, format=None): + def get(self, request, format=None): # pylint: disable=redefined-builtin """ Get info about the visiting user.