Publishing tags, and fixes.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 27 Jan 2023 15:47:20 +0000 (16:47 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 27 Jan 2023 15:47:20 +0000 (16:47 +0100)
src/catalogue/api/serializers.py
src/catalogue/api/views.py
src/catalogue/templatetags/catalogue_tags.py
src/catalogue/views.py
src/oai/handlers.py

index 02a98a1..9baba34 100644 (file)
@@ -24,7 +24,20 @@ class TagDetailSerializer(serializers.ModelSerializer):
 
     class Meta:
         model = Tag
-        fields = ['name', 'url', 'sort_key', 'description']
+        fields = [
+            'name', 'url', 'sort_key',
+            'description',
+            'description_pl',
+            'plural', 'genre_epoch_specific',
+            'adjective_feminine_singular', 'adjective_nonmasculine_plural',
+            'genitive', 'collective_noun',
+        ]
+        write_only_fields = [
+            'description_pl',
+            'plural', 'genre_epoch_specific',
+            'adjective_feminine_singular', 'adjective_nonmasculine_plural',
+            'genitive', 'collective_noun',
+        ]
 
 
 class TranslatorSerializer(serializers.Serializer):
index 5512501..c69c246 100644 (file)
@@ -320,7 +320,7 @@ class TagView(RetrieveAPIView):
                 slug=self.kwargs['slug']
             )
         except Http404:
-            if self.request.method == 'PUT':
+            if self.request.method == 'POST':
                 return Tag(
                     category=self.kwargs['category'],
                     slug=self.kwargs['slug']
@@ -330,10 +330,18 @@ class TagView(RetrieveAPIView):
 
     def post(self, request, **kwargs):
         data = json.loads(request.POST.get('data'))
-        desc = data['description_pl']
+        fields = {
+            "description_pl": "description_pl",
+            "plural": "plural",
+            "is_epoch_specific": "genre_epoch_specific",
+            "collective_noun": "collective_noun",
+            "adjective_feminine_singular": "adjective_feminine_singular",
+            "adjective_nonmasculine_plural": "adjective_nonmasculine_plural",
+        }
         obj = self.get_object()
-        obj.description_pl = desc
-        obj.save(update_fields=['description_pl'], quick=True)
+        for data_field, model_field in fields.items():
+            setattr(obj, model_field, data.get(data_field, getattr(obj, model_field)))
+        obj.save(update_fields=fields.values(), quick=True)
         return Response({})
 
 
index 1d5cee0..b45fc50 100644 (file)
@@ -131,9 +131,9 @@ def nice_title_from_tags(tags, related_tags):
     p = []
     for sublist in pieces:
         for item in sublist[:-2]:
-            p.append(item) + ','
+            p.append(item + ',')
         for item in sublist[-2:-1]:
-            p.append(item) + ' i'
+            p.append(item + ' i')
         p.append(sublist[-1])
 
     return ' '.join(p)
index 8c66af7..9d6598b 100644 (file)
@@ -154,13 +154,14 @@ def object_list(request, objects, fragments=None, related_tags=None, tags=None,
 
     is_set = len(tags) == 1 and tags[0].category == 'set'
     is_theme = len(tags) == 1 and tags[0].category == 'theme'
+    has_theme = any((x.category == 'theme' for x in tags))
     new_layout = request.EXPERIMENTS['layout']
 
     if is_set and new_layout.value:
         template = 'catalogue/2022/set_detail.html'
     elif is_theme and new_layout.value:
         template = 'catalogue/2022/theme_detail.html'
-    elif new_layout.value:
+    elif new_layout.value and not has_theme:
         template = 'catalogue/2022/author_detail.html'
     else:
         template = 'catalogue/tagged_object_list.html'
index 54a0a20..d90a560 100644 (file)
@@ -89,7 +89,7 @@ class Catalogue(common.ResumptionOAIPMH):
         md = wl_dc_reader(xml)
         m = md.getMap()
         if book.parent:
-            m['isPartOf'] = [str(WLURI.from_slug(book.parent.slug))]
+            m['isPartOf'] = [str(WLURI(book.parent.slug))]
         return m
 
     def record_for_book(self, book, headers_only=False):