From 2c2f3f87d336feddecba482efde90f5be44b60d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Sun, 1 Oct 2023 16:24:30 +0200 Subject: [PATCH] Add a default card image when no custom one exists --- ram/portal/admin.py | 1 + ram/portal/context_processors.py | 5 +++++ ram/portal/static/coming_soon.png | Bin 0 -> 4289 bytes ram/portal/templates/cards.html | 9 ++++++--- ram/ram/__init__.py | 2 +- ram/ram/settings.py | 5 +++++ 6 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 ram/portal/context_processors.py create mode 100644 ram/portal/static/coming_soon.png diff --git a/ram/portal/admin.py b/ram/portal/admin.py index 2ab5869..cc637bb 100644 --- a/ram/portal/admin.py +++ b/ram/portal/admin.py @@ -3,6 +3,7 @@ from portal.models import SiteConfiguration, Flatpage + @admin.register(SiteConfiguration) class SiteConfigurationAdmin(SingletonModelAdmin): fieldsets = ( diff --git a/ram/portal/context_processors.py b/ram/portal/context_processors.py new file mode 100644 index 0000000..77bf723 --- /dev/null +++ b/ram/portal/context_processors.py @@ -0,0 +1,5 @@ +from django.conf import settings + + +def default_card_image(request): + return {"DEFAULT_CARD_IMAGE": settings.DEFAULT_CARD_IMAGE} diff --git a/ram/portal/static/coming_soon.png b/ram/portal/static/coming_soon.png new file mode 100644 index 0000000000000000000000000000000000000000..a68fc7a766901f535777c9c52a7dc7dfa371e838 GIT binary patch literal 4289 zcmeHLXH-*bmp-6giWe(IQ3M^7E~p?aG!-yPhd>AdA_9g$f+QgXNDx1jD@u{7l;9^N zKnzF;3V|S?W&zTTp~WBwp$GwDMEXS6`sS`RYv#`VG4pSJoU+dQto`i$?6>TF?mIcy z%1A3p0{|cczIed}0K^JK?_-j`iSA-1)eEABRMs{dtKoQ6<+!9}i-zp%_B_Iq)4g) zxAtz|2fW@cE(KgYH--PiHKBr zDjKNyA90o{Vu0OMKWz~W?62(o!u_Isp(hVq71#N1c>l!xau0f7r^q4se?{@9fBy;h zD-7+2JAlW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CA6wUvS@8b>cjKU(lN1ohuzGl4WkA(j^>F@f=@N5p=>_B%w4l@n3TI>CeHIkoS8XF!f^a!XRl7rscCLdZRYw&LB^mB!`WGL3 zVU?v6cFY15FMV57Ios2Mg>8Wa_<4*4=>}*J)KlJ1+#CeI&c9w@5E{#<${Wsnrj6_&bl(3_hn?pFM@tnN3zv2YlD=X$jiSc zy$*l;T_!gL?Qk-Q4`m9_asJzdG-~ k(To0U(Ekr$pSQ$rb!1tf3dW>FzaIdwwZnz-b60QwJMj{Y0ssI2 literal 0 HcmV?d00001 diff --git a/ram/portal/templates/cards.html b/ram/portal/templates/cards.html index 00fd87c..901de83 100644 --- a/ram/portal/templates/cards.html +++ b/ram/portal/templates/cards.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load static %} {% block header %}

Results found: {{ matches }}

@@ -9,9 +10,11 @@ {% for d in data %}
- {% for i in d.image.all %} - {% if forloop.first %}Card image cap{% endif %} - {% endfor %} + {% if d.image.count > 0 %} + {{ d }} + {% else %} + {{ d }} + {% endif %}

{{ d }} diff --git a/ram/ram/__init__.py b/ram/ram/__init__.py index a1f30fc..d83f9cb 100644 --- a/ram/ram/__init__.py +++ b/ram/ram/__init__.py @@ -1,4 +1,4 @@ from ram.utils import git_suffix -__version__ = "0.4.2" +__version__ = "0.4.3" __version__ += git_suffix(__file__) diff --git a/ram/ram/settings.py b/ram/ram/settings.py index 6c65b5c..7e44648 100644 --- a/ram/ram/settings.py +++ b/ram/ram/settings.py @@ -80,6 +80,7 @@ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "portal.context_processors.default_card_image", ], }, }, @@ -148,6 +149,10 @@ "ZZ": "Freelance", } +# Image used on cards without a custom image uploaded. +# The file must be placed in the root of the 'static' folder +DEFAULT_CARD_IMAGE = "coming_soon.png" + DECODER_INTERFACES = [ (1, "NEM651"), (2, "NEM652"),