forked from GithubBackups/healthchecks
Add admin action to log in as any user
This commit is contained in:
parent
79dc4d2e7a
commit
e46000ecdf
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
### Improvements
|
### Improvements
|
||||||
- Use multicolor channel icons for better appearance in the dark mode
|
- Use multicolor channel icons for better appearance in the dark mode
|
||||||
- Add SITE_LOGO_URL setting (#323)
|
- Add SITE_LOGO_URL setting (#323)
|
||||||
|
- Add admin action to log in as any user
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
- Fix dark mode styling issues in Cron Syntax Cheatsheet
|
- Fix dark mode styling issues in Cron Syntax Cheatsheet
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
from django.contrib import admin
|
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.admin import UserAdmin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import Count, F
|
from django.db.models import Count, F
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
@ -121,6 +123,7 @@ class ProfileAdmin(admin.ModelAdmin):
|
|||||||
NumChecksFilter,
|
NumChecksFilter,
|
||||||
"theme",
|
"theme",
|
||||||
)
|
)
|
||||||
|
actions = ("login",)
|
||||||
|
|
||||||
fieldsets = (ProfileFieldset.tuple(), TeamFieldset.tuple())
|
fieldsets = (ProfileFieldset.tuple(), TeamFieldset.tuple())
|
||||||
|
|
||||||
@ -160,6 +163,11 @@ class ProfileAdmin(admin.ModelAdmin):
|
|||||||
def sms(self, obj):
|
def sms(self, obj):
|
||||||
return "%d of %d" % (obj.sms_sent, obj.sms_limit)
|
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)
|
@admin.register(Project)
|
||||||
class ProjectAdmin(admin.ModelAdmin):
|
class ProjectAdmin(admin.ModelAdmin):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user