From 842f71be9af64f2318001dd3af526206e513a6d2 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 16 Aug 2024 20:30:55 +0200 Subject: [PATCH 1/4] admin: Size and position branding logo like on front-end --- app/static/css/admin.css | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/static/css/admin.css b/app/static/css/admin.css index 727d08b6..33b7dfce 100644 --- a/app/static/css/admin.css +++ b/app/static/css/admin.css @@ -58,13 +58,12 @@ a.section:link, a.section:visited { } .header-title { - margin: 10px; + margin: 10px 2px; } .main-logo { - margin-left: 1px; - width: auto; - height: 70px; + width: 140px;; + height: 73px; } From 8dced800db6aeb776df96dd306c2df7ab75504f1 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 16 Aug 2024 20:31:23 +0200 Subject: [PATCH 2/4] admin: +favicon --- app/templates/admin/base_site.html | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/admin/base_site.html b/app/templates/admin/base_site.html index a949be66..a2f1d16a 100644 --- a/app/templates/admin/base_site.html +++ b/app/templates/admin/base_site.html @@ -13,6 +13,7 @@ {% block extrastyle %} + {% endblock %} {% block branding %} From 3c4d3a09a8c780fd07f3e20e2248d755756162aa Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 16 Aug 2024 20:35:44 +0200 Subject: [PATCH 3/4] admin: Rework comments about Django templates --- app/templates/admin/base_site.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/templates/admin/base_site.html b/app/templates/admin/base_site.html index a2f1d16a..60cf1434 100644 --- a/app/templates/admin/base_site.html +++ b/app/templates/admin/base_site.html @@ -1,10 +1,15 @@ - - {% extends "admin/base.html" %} +{% comment %} +Django Admin template +extended from: +https://github.com/django/django/blob/stable/5.0.x/django/contrib/admin/templates/admin/base.html +and +https://github.com/django/django/blob/stable/5.0.x/django/contrib/admin/templates/admin/base_site.html + +When upgrading Django, compare the changes in the above, to work out what +should be incorporated here, and update the links above that serve as the point +of comparison. +{% endcomment %} {% load static %} From 7f7ec5ee3ac782f26e0a25fb67d12645025b04b3 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Fri, 16 Aug 2024 20:45:07 +0200 Subject: [PATCH 4/4] admin: i18n One reference to "PDF" is removed to make message useful if other filetypes are supported in future. --- app/general/admin.py | 11 ++++++----- app/templates/admin/base_site.html | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/general/admin.py b/app/general/admin.py index e22ede8d..50742ef3 100644 --- a/app/general/admin.py +++ b/app/general/admin.py @@ -1,6 +1,7 @@ import magic from django.contrib import admin from django.forms import HiddenInput, ModelForm +from django.utils.translation import gettext as _ from simple_history.admin import SimpleHistoryAdmin from general.service.extract_text import GetTextError, GetTextFromPDF @@ -32,7 +33,7 @@ def clean(self): if uploaded_file: file_type = magic.from_buffer(uploaded_file.read(), mime=True) if file_type != "application/pdf": - self.add_error("uploaded_file", "Only PDF files are allowed.") + self.add_error("uploaded_file", _("Only PDF files are allowed.")) try: # Extract text from PDF file @@ -40,7 +41,7 @@ def clean(self): except GetTextError: return self.add_error( - "uploaded_file", "The uploaded PDF file is corrupted or not fully downloaded." + "uploaded_file", _("The uploaded file is corrupted or not fully downloaded.") ) cleaned_data["mime_type"] = file_type @@ -48,13 +49,13 @@ def clean(self): uploaded_file.seek(0) # Reset file pointer after read if not url and not uploaded_file: - self.add_error("url", "Either URL or uploaded file must be provided.") - self.add_error("uploaded_file", "Either URL or uploaded file must be provided.") + self.add_error("url", _("Either URL or uploaded file must be provided.")) + self.add_error("uploaded_file", _("Either URL or uploaded file must be provided.")) if uploaded_file: limit = 10 * 1024 * 1024 if uploaded_file.size and uploaded_file.size > limit: - self.add_error("uploaded_file", "File size must not exceed 10MB.") + self.add_error("uploaded_file", _("File size must not exceed 10MB.")) return cleaned_data diff --git a/app/templates/admin/base_site.html b/app/templates/admin/base_site.html index 60cf1434..2f980435 100644 --- a/app/templates/admin/base_site.html +++ b/app/templates/admin/base_site.html @@ -12,6 +12,7 @@ {% endcomment %} {% load static %} +{% load i18n %} {% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} @@ -24,7 +25,7 @@ {% block branding %}

- +

{% if user.is_anonymous %}