Refactored file structure to fix docker build, fixed Unfold configuration.
This commit is contained in:
0
app/apps/accounts/__init__.py
Normal file
0
app/apps/accounts/__init__.py
Normal file
19
app/apps/accounts/admin.py
Normal file
19
app/apps/accounts/admin.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
|
||||
from unfold.admin import ModelAdmin
|
||||
|
||||
|
||||
class UnfoldUserAdmin(DjangoUserAdmin, ModelAdmin):
|
||||
list_display = DjangoUserAdmin.list_display + ("last_login", "date_joined")
|
||||
readonly_fields = ("last_login", "date_joined")
|
||||
ordering = ("-date_joined",)
|
||||
|
||||
|
||||
# Unregister the default User admin and register with Unfold
|
||||
try:
|
||||
admin.site.unregister(User)
|
||||
except admin.sites.NotRegistered:
|
||||
pass
|
||||
|
||||
admin.site.register(User, UnfoldUserAdmin)
|
||||
0
app/apps/accounts/forms.py
Normal file
0
app/apps/accounts/forms.py
Normal file
0
app/apps/accounts/models.py
Normal file
0
app/apps/accounts/models.py
Normal file
0
app/apps/accounts/serialisers.py
Normal file
0
app/apps/accounts/serialisers.py
Normal file
0
app/apps/accounts/templates/accounts/login.html
Normal file
0
app/apps/accounts/templates/accounts/login.html
Normal file
0
app/apps/accounts/templates/accounts/profile.html
Normal file
0
app/apps/accounts/templates/accounts/profile.html
Normal file
0
app/apps/accounts/tests/test_auth.py
Normal file
0
app/apps/accounts/tests/test_auth.py
Normal file
0
app/apps/accounts/urls.py
Normal file
0
app/apps/accounts/urls.py
Normal file
0
app/apps/accounts/views.py
Normal file
0
app/apps/accounts/views.py
Normal file
0
app/apps/core/__init.py
Normal file
0
app/apps/core/__init.py
Normal file
0
app/apps/core/models.py
Normal file
0
app/apps/core/models.py
Normal file
0
app/apps/core/utils.py
Normal file
0
app/apps/core/utils.py
Normal file
53
app/apps/dashboard/admin.py
Normal file
53
app/apps/dashboard/admin.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# apps/dashboard/admin.py
|
||||
from django.contrib import admin
|
||||
|
||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from django.contrib.auth.admin import GroupAdmin as BaseGroupAdmin
|
||||
from django.contrib.auth.models import User, Group
|
||||
|
||||
from unfold.forms import AdminPasswordChangeForm, UserChangeForm, UserCreationForm
|
||||
from unfold.admin import ModelAdmin
|
||||
|
||||
|
||||
# Unregister the default Group admin and register with Unfold
|
||||
try:
|
||||
admin.site.unregister(Group)
|
||||
admin.site.unregister(User)
|
||||
except admin.sites.NotRegistered:
|
||||
pass
|
||||
|
||||
@admin.register(User)
|
||||
class UserAdmin(BaseUserAdmin, ModelAdmin):
|
||||
# Forms loaded from `unfold.forms`
|
||||
form = UserChangeForm
|
||||
add_form = UserCreationForm
|
||||
change_password_form = AdminPasswordChangeForm
|
||||
|
||||
# Set to False, to enable filter as "sidebar"
|
||||
list_filter_sheet = True
|
||||
|
||||
# Display fields in changeform in compressed mode
|
||||
compressed_fields = True # Default: False
|
||||
|
||||
# Warn before leaving unsaved changes in changeform
|
||||
warn_unsaved_form = True # Default: False
|
||||
|
||||
|
||||
@admin.register(Group)
|
||||
class GroupAdmin(BaseGroupAdmin, ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
# # Custom dashboard view
|
||||
# def custom_dashboard(request):
|
||||
# context = {
|
||||
# "user_count": get_user_model().objects.count(),
|
||||
# "group_count": auth_models.Group.objects.count(),
|
||||
# }
|
||||
# return render(request, "unfold/dashboard.html", context)
|
||||
|
||||
|
||||
# # Add the URL to admin
|
||||
# admin.site.get_urls = (
|
||||
# lambda self: [path("", custom_dashboard, name="index")] + self.get_urls()
|
||||
# ).__get__(admin.site)
|
||||
Reference in New Issue
Block a user