Browse Source

Add admin action to log in as any user

pull/545/head
Pēteris Caune 3 years ago
parent
commit
e46000ecdf
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 9 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +8
    -0
      hc/accounts/admin.py

+ 1
- 0
CHANGELOG.md View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
### Improvements
- Use multicolor channel icons for better appearance in the dark mode
- Add SITE_LOGO_URL setting (#323)
- Add admin action to log in as any user
### Bug Fixes
- Fix dark mode styling issues in Cron Syntax Cheatsheet


+ 8
- 0
hc/accounts/admin.py View File

@ -1,7 +1,9 @@
from django.contrib import admin
from django.contrib.auth import login as auth_login
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.db.models import Count, F
from django.shortcuts import redirect
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.html import escape
@ -121,6 +123,7 @@ class ProfileAdmin(admin.ModelAdmin):
NumChecksFilter,
"theme",
)
actions = ("login",)
fieldsets = (ProfileFieldset.tuple(), TeamFieldset.tuple())
@ -160,6 +163,11 @@ class ProfileAdmin(admin.ModelAdmin):
def sms(self, obj):
return "%d of %d" % (obj.sms_sent, obj.sms_limit)
def login(self, request, qs):
profile = qs.get()
auth_login(request, profile.user, "hc.accounts.backends.EmailBackend")
return redirect("hc-index")
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):


Loading…
Cancel
Save