26 lines
789 B
Python
26 lines
789 B
Python
from django.contrib import admin
|
|
from .models import SharedPassword, SharedPasswordAccess
|
|
from .forms import NewSharedPasswordForm, EditSharedPasswordForm
|
|
|
|
|
|
class SharedPasswordAdmin(admin.ModelAdmin):
|
|
form = NewSharedPasswordForm
|
|
exclude = ["iv", "encrypted_password"]
|
|
list_display = ("name", "users")
|
|
|
|
def get_form(self, request, obj=None, **kwargs):
|
|
if obj is None:
|
|
kwargs["form"] = NewSharedPasswordForm
|
|
else:
|
|
kwargs["form"] = EditSharedPasswordForm
|
|
return super().get_form(request, obj, **kwargs)
|
|
|
|
|
|
admin.site.register(SharedPassword, SharedPasswordAdmin)
|
|
|
|
|
|
class SharedPasswordAccessAdmin(admin.ModelAdmin):
|
|
list_display = ("password", "user")
|
|
|
|
|
|
admin.site.register(SharedPasswordAccess, SharedPasswordAccessAdmin)
|