From fb2eae301aa3428357801ddd86f27183deb22211 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 18 Aug 2020 14:23:51 +0200 Subject: [PATCH] Add drafts count and pill css --- articles/context_processors.py | 4 ++++ articles/static/style.css | 9 +++++++++ articles/templates/articles/base.html | 2 +- blog/settings.py | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/articles/context_processors.py b/articles/context_processors.py index 410ccf8..ed55370 100644 --- a/articles/context_processors.py +++ b/articles/context_processors.py @@ -3,3 +3,7 @@ from articles.models import Article, Page def pages(request): return {"pages": Page.objects.filter(status=Article.PUBLISHED)} + + +def drafts_count(request): + return {"drafts_count": Article.with_pages.filter(status=Article.DRAFT).count()} diff --git a/articles/static/style.css b/articles/static/style.css index 7a692ac..2514b89 100644 --- a/articles/static/style.css +++ b/articles/static/style.css @@ -127,6 +127,15 @@ tr:hover { background-color: var(--background2); } +.pill { + font-size: 60%; + background-color: var(--main2); + color: var(--background2); + padding: .5ex 1ex; + border-radius: 1ex; + vertical-align: 15%; +} + @media (prefers-color-scheme: dark) { :root { --accent: #226997; diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index 6b93c68..2fa4b41 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -16,7 +16,7 @@ Gab's Notes | {% if user.is_authenticated %} - View drafts + View drafts {{ drafts_count }} Admin {% else %} Log in diff --git a/blog/settings.py b/blog/settings.py index 53ad612..06725ba 100644 --- a/blog/settings.py +++ b/blog/settings.py @@ -73,6 +73,7 @@ TEMPLATES = [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "articles.context_processors.pages", + "articles.context_processors.drafts_count", ], }, },