Updated and fixes.
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 10 Jan 2023 14:40:13 +0000 (15:40 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 10 Jan 2023 14:40:13 +0000 (15:40 +0100)
requirements/requirements.txt
src/catalogue/templates/catalogue/book_text.html
src/catalogue/templatetags/catalogue_tags.py
src/education/models.py
src/search/index.py
src/wolnelektury/settings/apps.py

index 2dec1cc..c78c3f5 100644 (file)
@@ -40,7 +40,7 @@ mutagen==1.45.1
 sorl-thumbnail==12.8.0
 
 # home-brewed & dependencies
-librarian==2.4.1
+librarian==2.4.9
 
 # celery tasks
 celery[redis]==5.2.7
index 9d28bd7..78067d7 100644 (file)
            "label": "{{ ref.entity.label }}",
            "description": "{{ ref.entity.description }}",
            "wikipedia_link": "{{ ref.entity.wikipedia_link }}"
-       }{% if not forloop.last %},{% endif %}
+       },
        {% endif %}
        {% endfor %}
+       "": null
   }
   </script>
   {% endlocalize %}
index 6ee1777..1d5cee0 100644 (file)
@@ -106,7 +106,7 @@ def nice_title_from_tags(tags, related_tags):
             # No info on genre, but there's only one kind related.
             subpieces = []
             pieces.append([
-                t.collective_noun or t.name for t in self['kind']
+                t.collective_noun or t.name for t in related_tags['kind']
             ])
             plural = False
         else:
index 5d11004..33064a1 100644 (file)
@@ -49,15 +49,18 @@ class YPlaylist(models.Model):
         super().save()
         self.download()
     
-    def download(self):
-        response = YouTubeToken.objects.first().call(
-            "GET",
-            "https://www.googleapis.com/youtube/v3/playlistItems",
-            params={
+    def download(self, page_token=None):
+        params = {
                 'part': 'snippet',
                 'playlistId': self.youtube_id,
                 'maxResults': 50,
-            },
+            }
+        if page_token:
+            params['pageToken'] = page_token
+        response = YouTubeToken.objects.first().call(
+            "GET",
+            "https://www.googleapis.com/youtube/v3/playlistItems",
+            params=params
         )
         data = response.json()
         for item in data['items']:
@@ -68,6 +71,8 @@ class YPlaylist(models.Model):
                     'order': item['snippet']['position'],
                 }
             )
+        if data.get('nextPageToken'):
+            self.download(page_token=data['nextPageToken'])
 
 
 
index 2be60fd..68a2b3b 100644 (file)
@@ -9,6 +9,9 @@ import os
 import re
 from django.conf import settings
 from librarian import dcparser
+import librarian.meta.types.date
+import librarian.meta.types.person
+import librarian.meta.types.text
 from librarian.parser import WLDocument
 from lxml import etree
 import scorched
@@ -318,21 +321,20 @@ class Index(SolrIndex):
             if hasattr(book_info, field.name):
                 if not getattr(book_info, field.name):
                     continue
-                # since no type information is available, we use validator
-                type_indicator = field.validator
-                if type_indicator == dcparser.as_unicode:
+                type_indicator = field.value_type
+                if issubclass(type_indicator, librarian.meta.types.text.TextValue):
                     s = getattr(book_info, field.name)
                     if field.multiple:
                         s = ', '.join(s)
                     fields[field.name] = s
-                elif type_indicator == dcparser.as_person:
+                elif issubclass(type_indicator, librarian.meta.types.person.Person):
                     p = getattr(book_info, field.name)
-                    if isinstance(p, dcparser.Person):
+                    if isinstance(p, librarian.meta.types.person.Person):
                         persons = str(p)
                     else:
                         persons = ', '.join(map(str, p))
                     fields[field.name] = persons
-                elif type_indicator == dcparser.as_date:
+                elif issubclass(type_indicator, librarian.meta.types.date.DateValue):
                     dt = getattr(book_info, field.name)
                     fields[field.name] = dt
 
index ad0ff15..fe42e04 100644 (file)
@@ -11,6 +11,7 @@ INSTALLED_APPS_OUR = [
     'catalogue',
     'chunks',
     'dictionary',
+    'education',
     'experiments',
     'infopages',
     'lesmianator',