sponsor alt
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 31 Jan 2024 07:54:46 +0000 (08:54 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 31 Jan 2024 07:54:46 +0000 (08:54 +0100)
src/catalogue/forms.py
src/catalogue/models/book.py
src/catalogue/templates/catalogue/book_info.html
src/catalogue/templates/catalogue/book_text.html

index 055800e..919ff3a 100644 (file)
@@ -19,6 +19,7 @@ class BookImportForm(forms.Form):
     hidden = forms.BooleanField(required=False)
     logo = forms.CharField(required=False)
     logo_mono = forms.CharField(required=False)
     hidden = forms.BooleanField(required=False)
     logo = forms.CharField(required=False)
     logo_mono = forms.CharField(required=False)
+    logo_alt = forms.CharField(required=False)
 
     def clean(self):
         from django.core.files.base import ContentFile
 
     def clean(self):
         from django.core.files.base import ContentFile
@@ -38,6 +39,7 @@ class BookImportForm(forms.Form):
                                   findable=not self.cleaned_data['hidden'],
                                   logo=self.cleaned_data['logo'],
                                   logo_mono=self.cleaned_data['logo_mono'],
                                   findable=not self.cleaned_data['hidden'],
                                   logo=self.cleaned_data['logo'],
                                   logo_mono=self.cleaned_data['logo_mono'],
+                                  logo_alt=self.cleaned_data['logo_alt'],
                                   **kwargs)
 
 
                                   **kwargs)
 
 
index b14269f..b2d960b 100644 (file)
@@ -594,7 +594,7 @@ class Book(models.Model):
 
     @classmethod
     def from_text_and_meta(cls, raw_file, book_info, overwrite=False, dont_build=None, search_index=True,
 
     @classmethod
     def from_text_and_meta(cls, raw_file, book_info, overwrite=False, dont_build=None, search_index=True,
-                           remote_gallery_url=None, days=0, findable=True, logo=None, logo_mono=None):
+                           remote_gallery_url=None, days=0, findable=True, logo=None, logo_mono=None, logo_alt=None):
         from catalogue import tasks
 
         if dont_build is None:
         from catalogue import tasks
 
         if dont_build is None:
@@ -646,6 +646,8 @@ class Book(models.Model):
             extra['logo'] = logo
         if logo_mono:
             extra['logo_mono'] = logo_mono
             extra['logo'] = logo
         if logo_mono:
             extra['logo_mono'] = logo_mono
+        if logo_alt:
+            extra['logo_alt'] = logo_alt
         book.extra_info = json.dumps(extra)
         book.load_abstract()
         book.load_toc()
         book.extra_info = json.dumps(extra)
         book.load_abstract()
         book.load_toc()
index 424d759..838b59f 100644 (file)
@@ -42,7 +42,9 @@
 
   {% if extra_info.logo %}
     {% thumbnail extra_info.logo '300x200' as th %}
 
   {% if extra_info.logo %}
     {% thumbnail extra_info.logo '300x200' as th %}
-    <img src="{{ th.url }}" style="width: 300px; max-width: 100%;">
+    <img src="{{ th.url }}" style="width: 300px; max-width: 100%;"
+         alt="{{ extra_info.logo_alt|default:'Sponsor' }}"
+    >
   {% endthumbnail %}
   {% endif %}
 
   {% endthumbnail %}
   {% endif %}
 
index 041a07a..67372b3 100644 (file)
   </li>
 
   {% if extra_info.logo_mono %}
   </li>
 
   {% if extra_info.logo_mono %}
-  {% thumbnail extra_info.logo_mono '200x200' as th %}
-    <img src="{{ th.url }}" style="width: 100px; padding: 10px;">
+    {% thumbnail extra_info.logo_mono '200x200' as th %}
+    <img src="{{ th.url }}" style="width: 100px; padding: 10px;"
+         alt="{{ extra_info.logo_alt|default:'Sponsor' }}"
+    >
   {% endthumbnail %}
   {% endif %}
 
   {% endthumbnail %}
   {% endif %}