Skip to content
Snippets Groups Projects
Verified Commit 8b2effcc authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Fix linting errors

parent 037798e5
No related branches found
No related tags found
1 merge request!326Notify sponsors of bad emails in sent invites
Pipeline #134015 passed
......@@ -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
......
......@@ -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)
......
......@@ -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(
......
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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment