Commit f5ea7c49 authored by Håvard Farestveit's avatar Håvard Farestveit
Browse files

simplify naming to increase readability

parent acd010a2
Pipeline #125671 passed with stage
in 29 seconds
......@@ -96,15 +96,13 @@ class OfferList(
serializer.save(owner=self.request.user)
@staticmethod
def filter_on_status(query_set, query_params):
status = query_params.get("status", None)
def filter_queryset_on_status(query_set, status):
if status is not None:
query_set = query_set.filter(status=status)
return query_set
@staticmethod
def filter_on_category(query_set, query_params, user):
category = query_params.get("category", None)
def filter_queryset_on_category(query_set, category, user):
if category is not None:
if category == "sent":
query_set = query_set.filter(owner=user)
......@@ -114,16 +112,17 @@ class OfferList(
def get_queryset(self):
result = Offer.objects.none()
user = self.request.user
query_params = self.request.query_params
status = query_params.get("status", None)
category = query_params.get("category", None)
if self.request.user:
if user:
query_set = Offer.objects.filter(
Q(owner=self.request.user) | Q(recipient=self.request.user)
Q(owner=user) | Q(recipient=user)
).distinct()
query_params = self.request.query_params
user = self.request.user
query_set = self.filter_on_status(query_set, query_params)
query_set = self.filter_on_category(query_set, query_params, user)
query_set = self.filter_queryset_on_status(query_set, status)
query_set = self.filter_queryset_on_category(query_set, category, user)
return query_set
return result
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment