Refactor attribute retrieval logic in detail serializer.
Simplify the conditional logic for fetching attributes based on user permissions. This improves code readability and maintains the same functionality.
This commit is contained in:
parent
6c04faf97b
commit
4d63bde7a3
1 changed files with 1 additions and 4 deletions
|
|
@ -78,10 +78,7 @@ class CategoryDetailSerializer(ModelSerializer):
|
|||
request = self.context.get("request")
|
||||
user = getattr(request, "user", None)
|
||||
|
||||
if user is not None and user.has_perm("view_attribute"):
|
||||
attributes = obj.attributes.all()
|
||||
else:
|
||||
attributes = obj.attributes.filter(is_active=True)
|
||||
attributes = obj.attributes.all() if user.has_perm("view_attribute") else obj.attributes.filter(is_active=True)
|
||||
|
||||
for attr in attributes:
|
||||
distinct_vals = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue