From fef16dd1d8bf56dafe48b695117fc951a5989677 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 17 Aug 2021 10:14:00 +0200 Subject: [PATCH] Show blog username/email in listing For the regular user view, just show which account and email is used for info. For the administration view, show the username and email for each individual blog, to help with tracking down misbehaving blogs. And finally, in the moderation view, also include the email (it already had the account name) to make it easier to contact an author. --- hamnadmin/hamnadmin/register/templates/index.html | 10 +++++++--- hamnadmin/hamnadmin/register/templates/moderate.html | 2 +- hamnadmin/hamnadmin/register/views.py | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hamnadmin/hamnadmin/register/templates/index.html b/hamnadmin/hamnadmin/register/templates/index.html index ac80f7b..424e620 100644 --- a/hamnadmin/hamnadmin/register/templates/index.html +++ b/hamnadmin/hamnadmin/register/templates/index.html @@ -1,7 +1,7 @@ {% extends "regbase.html" %} {%block content%} {%if blogs %} -

Your blogs

+

{{title}}

{%if messages%}
@@ -11,9 +11,11 @@
{%endif%} +{%if not isadmin%}

-You have the following blog(s) registered: +You have the following blog(s) registered on your account {{user.username}} with email address {{user.email}}.

+{%endif%} @@ -24,7 +26,9 @@ You have the following blog(s) registered: {%for blog in blogs%} - +
Name
{{blog.name}}{{blog.name}}{%if isadmin%}
+Account: {{blog.user.username}}
+Email: {{blog.user.email}}{%endif%}
{%if blog.archived%} Archived diff --git a/hamnadmin/hamnadmin/register/templates/moderate.html b/hamnadmin/hamnadmin/register/templates/moderate.html index 77c9f18..502edaf 100644 --- a/hamnadmin/hamnadmin/register/templates/moderate.html +++ b/hamnadmin/hamnadmin/register/templates/moderate.html @@ -18,7 +18,7 @@
User
-
Username: {{blog.user}}
Twitter: {{blog.twitteruser}}
Team: {{blog.team.name}}
+
Username: {{blog.user}}
Email: {{blog.user.email}}
Twitter: {{blog.twitteruser}}
Team: {{blog.team.name}}
URLs
diff --git a/hamnadmin/hamnadmin/register/views.py b/hamnadmin/hamnadmin/register/views.py index 2c805d9..0a69713 100644 --- a/hamnadmin/hamnadmin/register/views.py +++ b/hamnadmin/hamnadmin/register/views.py @@ -47,14 +47,16 @@ def issuperuser(user): @login_required def root(request): - if request.user.is_superuser and 'admin' in request.GET and request.GET['admin'] == '1': + isadmin = request.user.is_superuser and 'admin' in request.GET and request.GET['admin'] == '1' + if isadmin: blogs = Blog.objects.all().order_by('archived', 'approved', 'name') else: blogs = Blog.objects.filter(user=request.user).order_by('archived', 'approved', 'name') return render(request, 'index.html', { 'blogs': blogs, 'teams': Team.objects.filter(manager=request.user).order_by('name'), - 'title': 'Your blogs', + 'title': 'All blogs' if isadmin else 'Your blogs', + 'isadmin': isadmin, }) -- 2.39.5