From 60005ea3d9a99694d4df856b7d82129ca9892401 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Fri, 11 Feb 2022 18:54:20 +0300 Subject: [PATCH] feat: debug login with given name (#900) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * cleanup: remove "pain" post type (#742) * Убран тип поста Боль * Фикс миграции Co-authored-by: Mikhail Polykovskij * Increase "ban_reason" length * Disable comments auto-subscription * feat: Badges (#704) * Badges draft * Badges CSS for comments, posts, profiles * Almost done, needs data and icons * CSS fixes + frontend bugs * More logical fixes * Fixing bugs, rename things * Add icons and initial data * fix: badge notifications + typos * feat: show subscription duration in profile (#733) * Add friends page #723 * Adds subscription status to profile * send 403 if user tries to look someones friends #723 * bring back old name for add to friends button #723 * Fixes typo, covers PR suggestions * Visual improvements Co-authored-by: ollkostin Co-authored-by: kedMertens Co-authored-by: vas3k * feat: Remove sending limits for friend's comments * Threads now public * Fix #753. Add badges to /stats/ page * fix: Increase latest_badges on stats to 20 * Add "align-items: center;" to stats/badges * feat: exclude replies from friends notifications * fix: bad gradient of badges block (#760) Signed-off-by: Vitalii Dmitriev * Add highlight to badged comments, improve CSS * Cooking achievements (#755) * Draft for cooking achievements * Fixing bg color and using proper URLs * Fixing pictures order * Fixing pastry_cook_2 * feat: add socialism and anarchism to list of tags (#637) А то сейчас доступны три правые системы взглядов и ни одной левой 🤔 * feat: remove "libertarianism" and "anarchism" tags * fix: mobile CSS bugs * feat: remove expertise from profile, move achievements * fix #764: "show all posts" link in profile is wrong * feat: remove NLTK dependency + add test docker build step * fix #714: add login button to public pages (#763) * add login button * fix css * fix url * fix css justify * Refactor daily and weekly digest renderers * Remove old supervisor config * fix: use sum of prices for top badges page * Add data archives cleanup to crontab * fix #765: css padding for upvote button * Upstream * Логин под именем указанного пользователя Co-authored-by: Mikhail Polykovskij Co-authored-by: vas3k Co-authored-by: kedMertens <39831696+kedMertens@users.noreply.github.com> Co-authored-by: ollkostin Co-authored-by: kedMertens Co-authored-by: Vitalii Dmitriev Co-authored-by: Dmitry Kochkin Co-authored-by: Ivan Mir Co-authored-by: Kamil --- auth/views/auth.py | 12 +++++++++++- club/urls.py | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/auth/views/auth.py b/auth/views/auth.py index 4c7dbf89d..4f6c5faf1 100644 --- a/auth/views/auth.py +++ b/auth/views/auth.py @@ -4,7 +4,7 @@ from django.conf import settings from django.core.cache import cache from django.http import HttpResponseNotAllowed -from django.shortcuts import redirect, render +from django.shortcuts import redirect, render, get_object_or_404 from auth.helpers import auth_required, set_session_cookie from auth.models import Session @@ -103,3 +103,13 @@ def debug_random_login(request): session = Session.create_for_user(user) return set_session_cookie(redirect("profile", user.slug), user, session) + + +def debug_login(request, user_slug): + if not (settings.DEBUG or settings.TESTS_RUN): + raise AccessDenied(title="Эта фича доступна только при DEBUG=true") + + user = get_object_or_404(User, slug=user_slug) + session = Session.create_for_user(user) + + return set_session_cookie(redirect("profile", user.slug), user, session) diff --git a/club/urls.py b/club/urls.py index 45e3bd8ec..705dd7a6b 100644 --- a/club/urls.py +++ b/club/urls.py @@ -4,7 +4,7 @@ from django.views.generic import RedirectView from auth.helpers import auth_switch -from auth.views.auth import login, logout, debug_dev_login, debug_random_login, join +from auth.views.auth import login, logout, debug_dev_login, debug_random_login, debug_login, join from auth.views.email import email_login, email_login_code from auth.views.external import external_login from auth.views.patreon import patreon_login, patreon_oauth_callback @@ -163,6 +163,7 @@ path("godmode/digest/", godmode_digest_settings, name="godmode_digest_settings"), path("godmode/dev_login/", debug_dev_login, name="debug_dev_login"), path("godmode/random_login/", debug_random_login, name="debug_random_login"), + path("godmode/login//", debug_login, name="debug_login"), # misc path("misc/calendar/ical", generate_ical_invite, name="generate_ical_invite"),