fixes
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 20 Dec 2021 14:17:09 +0000 (15:17 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 20 Dec 2021 14:17:09 +0000 (15:17 +0100)
src/depot/models.py
src/documents/models/book.py
src/documents/templates/documents/book_detail.html
src/documents/templates/documents/book_stats.html

index 12bd9c2..c654d1b 100644 (file)
@@ -45,8 +45,10 @@ class Package(models.Model):
 
     def build(self):
         f = tempfile.NamedTemporaryFile(prefix='depot-', suffix='.zip', mode='wb', delete=False)
 
     def build(self):
         f = tempfile.NamedTemporaryFile(prefix='depot-', suffix='.zip', mode='wb', delete=False)
+        book_count = self.books.all().count()
         with zipfile.ZipFile(f, 'w') as z:
         with zipfile.ZipFile(f, 'w') as z:
-            for book in self.books.all():
+            for i, book in enumerate(self.books.all()):
+                print(f'{i}/{book_count} {book.slug}')
                 self.build_for(book, z)
         f.close()
         with open(f.name, 'rb') as ff:
                 self.build_for(book, z)
         f.close()
         with open(f.name, 'rb') as ff:
@@ -94,16 +96,20 @@ class Package(models.Model):
                 output = EpubBuilder(
                     cover=cover,
                     base_url=base_url,
                 output = EpubBuilder(
                     cover=cover,
                     base_url=base_url,
-#                    fundraising=[]
+                    fundraising=item.get('fundraising', []),
                 ).build(wldoc2)
 
             elif item['type'] == 'mobi':
                 output = MobiBuilder(
                     cover=cover,
                     base_url=base_url,
                 ).build(wldoc2)
 
             elif item['type'] == 'mobi':
                 output = MobiBuilder(
                     cover=cover,
                     base_url=base_url,
+                    fundraising=item.get('fundraising', []),
                 ).build(wldoc2)
 
                 ).build(wldoc2)
 
-            fname = f'{slug}/{slug}.{ext}'
+            fname = f'{slug}/{slug}.'
+            if 'slug' in item:
+                fname += item['slug'] + '.'
+            fname += ext
 
             z.writestr(
                 fname,
 
             z.writestr(
                 fname,
index 0e696e4..d5724a2 100644 (file)
@@ -413,7 +413,7 @@ class Book(models.Model):
         from librarian.parser import WLDocument
         from librarian.document import WLDocument as WLDocument2
 
         from librarian.parser import WLDocument
         from librarian.document import WLDocument as WLDocument2
 
-        provider = RedakcjaDocProvider(publishable=publishable),
+        provider = RedakcjaDocProvider(publishable=publishable)
         xml = self.materialize(publishable=publishable, changes=changes).encode('utf-8')
         
         if librarian2:
         xml = self.materialize(publishable=publishable, changes=changes).encode('utf-8')
         
         if librarian2:
index 85da536..55da225 100644 (file)
@@ -145,8 +145,8 @@ OkÅ‚adka w rozmiarze
               {% trans "book" %}
             </th>
             <th>{% trans "characters" %}</th>
               {% trans "book" %}
             </th>
             <th>{% trans "characters" %}</th>
-            <th>{% trans "words" %}</th>
             <th>{% trans "characters (with footnotes)" %}</th>
             <th>{% trans "characters (with footnotes)" %}</th>
+            <th>{% trans "words" %}</th>
             <th>{% trans "words (with footnotes)" %}</th>
           </tr>
         </thead>
             <th>{% trans "words (with footnotes)" %}</th>
           </tr>
         </thead>
index 084627f..793eaa2 100644 (file)
@@ -1,19 +1,19 @@
 <tr>
   <td style="padding-left: {{ depth}}.75em;">{{ book.book_info.title|default:"???" }}</td>
 <tr>
   <td style="padding-left: {{ depth}}.75em;">{{ book.book_info.title|default:"???" }}</td>
-  <td>{{ stats.self.chars|default_if_none:"?" }}</td>
-  <td>{{ stats.self.words|default_if_none:"?" }}</td>
   <td>{{ stats.self.chars_with_fn|default_if_none:"?" }}</td>
   <td>{{ stats.self.chars_with_fn|default_if_none:"?" }}</td>
+  <td>{{ stats.self.chars|default_if_none:"?" }}</td>
   <td>{{ stats.self.words_with_fn|default_if_none:"?" }}</td>
   <td>{{ stats.self.words_with_fn|default_if_none:"?" }}</td>
+  <td>{{ stats.self.words|default_if_none:"?" }}</td>
 </tr>
 {% if stats.parts %}
   {% for part, partstats in stats.parts %}
     {% include 'documents/book_stats.html' with book=part stats=partstats depth=depth|add:1 %}
   {% endfor %}
   <tr>
 </tr>
 {% if stats.parts %}
   {% for part, partstats in stats.parts %}
     {% include 'documents/book_stats.html' with book=part stats=partstats depth=depth|add:1 %}
   {% endfor %}
   <tr>
-    <td>&Sigma;</td>
-    <td>{{ stats.total.chars }}</td>
-    <td>{{ stats.total.words }}</td>
+    <td style="padding-left: {{ depth}}.75em;">&Sigma;</td>
     <td>{{ stats.total.chars_with_fn }}</td>
     <td>{{ stats.total.chars_with_fn }}</td>
+    <td>{{ stats.total.chars }}</td>
     <td>{{ stats.total.words_with_fn }}</td>
     <td>{{ stats.total.words_with_fn }}</td>
+    <td>{{ stats.total.words }}</td>
   </tr>
 {% endif %}
   </tr>
 {% endif %}