From cdb3c96cdf2e4dda308d4de43e7cdec73cb1be7c Mon Sep 17 00:00:00 2001 From: Bobby Date: Mon, 23 Jan 2023 03:22:50 -0500 Subject: allow access to user to their activity on private profile --- blog/views.py | 2 +- static/css/main.css | 4 ++++ templates/blog/activity.html | 10 +++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/blog/views.py b/blog/views.py index 0aa79b65..690eea66 100644 --- a/blog/views.py +++ b/blog/views.py @@ -250,7 +250,7 @@ def articles(request): def user_activity(request, username): user = User.objects.get(username=username) user_profile = UserProfile.objects.get(user=user) - if user_profile.is_public: + if user_profile.is_public or user == request.user: recent_comments = Comment.objects.filter(user=user).order_by('-created_at')[:5] else: recent_comments = [] diff --git a/static/css/main.css b/static/css/main.css index 9fc865a8..cd543f37 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -168,6 +168,10 @@ kbd { color: #00ff00; } +.info { + color: #65c6c6; +} + .ac { margin-right: 5px; height: 12px; diff --git a/templates/blog/activity.html b/templates/blog/activity.html index 595dd920..6d70af3b 100644 --- a/templates/blog/activity.html +++ b/templates/blog/activity.html @@ -28,10 +28,14 @@
- {% if activity_user_profile.is_public %} + {% if activity_user_profile.is_public or request.user.username == activity_user.username %} - {% if activity_recent_comments %} -

Recent Comments

+ + {% if activity_recent_comments %} +

Recent Comments

+ {% if not activity_user_profile.is_public and request.user.username == activity_user.username %} +

Your profile is not public. Only you can see this information. If you want to change this, go to your account settings.

+ {% endif %}