Skip to content

Commit

Permalink
Fix other thing
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasdeluna committed Oct 19, 2023
1 parent 10278d8 commit d01e557
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lego/apps/lending/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create(self, *args, **kwargs):
user = User.objects.get(pk=user_id)
notification = LendingInstanceNotification(
lending_instance=lending_instance,
user_email=user,
user=user,
)
notification.notify()

Expand Down
6 changes: 1 addition & 5 deletions lego/apps/lending/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class Meta:
def validate(self, data):
lendable_object_id = data["lendable_object"].id
lendable_object = LendableObject.objects.get(id=lendable_object_id)
user = self.request.user

user = self.context['request'].user
if not user.abakus_groups.filter(
id__in=lendable_object.responsible_groups.all().values_list("id", flat=True)
).exists():
Expand All @@ -31,7 +30,4 @@ def validate(self, data):
"Lending period exceeds maximum allowed duration"
)

# Add additional validation logic as per your use case
# ...

return data
3 changes: 1 addition & 2 deletions lego/apps/lending/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class LendingInstanceViewSet(
]

def create(self, request):
serializer = LendingInstanceSerializer(request, data=request.data)

serializer = LendingInstanceSerializer(data=request.data, context={'request': request})
if serializer.is_valid(raise_exception=True):
serializer.save()
return Response(data=serializer.data, status=status.HTTP_201_CREATED)
Expand Down

0 comments on commit d01e557

Please sign in to comment.