from django.contrib import admin
+from django.contrib.auth.admin import UserAdmin
+from django.contrib.auth.models import User
from . import models
-@admin.register(models.Profile)
-class ProfileAdmin(admin.ModelAdmin):
- list_display = ['user', 'presence']
+class ProfileInline(admin.StackedInline):
+ model = models.Profile
+ can_delete = False
+
+
+class CustomUserAdmin(UserAdmin):
+ inlines = (ProfileInline, )
+
+ def get_inline_instances(self, request, obj=None):
+ if not obj:
+ return list()
+ return super(CustomUserAdmin, self).get_inline_instances(request, obj)
+
+admin.site.unregister(User)
+admin.site.register(User, CustomUserAdmin)
@admin.register(models.Presence)
-class ProfileAdmin(admin.ModelAdmin):
- list_display = ['user', 'timestamp', 'active']
+class PresenceAdmin(admin.ModelAdmin):
+ list_display = ['session_key', 'chunk', 'user', 'since', 'until', 'active']
+ raw_id_fields = ['chunk', 'user']