Browse Source

fix(hadis): support context date query aliases and upsert in AdminYearValueSerializer

master
Mohsen Taba 2 days ago
parent
commit
f90c47fd04
  1. 2
      apps/hadis/serializers/serializers_admin.py
  2. 8
      apps/hadis/views_admin.py

2
apps/hadis/serializers/serializers_admin.py

@ -3829,6 +3829,8 @@ class AdminYearValueSerializer(serializers.ModelSerializer):
read_only_fields = ["id", "narrators_count", "created_at", "updated_at"] read_only_fields = ["id", "narrators_count", "created_at", "updated_at"]
validators = []
def get_narrators_count(self, obj): def get_narrators_count(self, obj):

8
apps/hadis/views_admin.py

@ -828,7 +828,7 @@ class DovodiYearValueViewSet(ModelViewSet):
category = self.request.query_params.get("category")
category = self.request.query_params.get("category") or self.request.query_params.get("date_type")
if category and category != "all": if category and category != "all":
@ -836,7 +836,7 @@ class DovodiYearValueViewSet(ModelViewSet):
parse_type = self.request.query_params.get("parse_type")
parse_type = self.request.query_params.get("parse_type") or self.request.query_params.get("date_mode")
if parse_type and parse_type != "all": if parse_type and parse_type != "all":
@ -844,11 +844,11 @@ class DovodiYearValueViewSet(ModelViewSet):
# If context_only=true, deduplicate #tags by returning one representative record per raw_value
# If context_only=true or parse_type/date_mode=context, deduplicate #tags by returning one representative record per raw_value
context_only = self.request.query_params.get("context_only") context_only = self.request.query_params.get("context_only")
if context_only in ("true", "1", "True"):
if context_only in ("true", "1", "True") or parse_type == "context":
queryset = queryset.filter(parse_type="context") queryset = queryset.filter(parse_type="context")

Loading…
Cancel
Save