diff --git a/app/apps/accounts/admin.py b/app/apps/accounts/admin.py index 8d75769..09f9b1e 100644 --- a/app/apps/accounts/admin.py +++ b/app/apps/accounts/admin.py @@ -1,19 +1,37 @@ 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 +from unfold.sections import TableSection, TemplateSection +from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _ -class UnfoldUserAdmin(DjangoUserAdmin, ModelAdmin): - list_display = DjangoUserAdmin.list_display + ("last_login", "date_joined") - readonly_fields = ("last_login", "date_joined") - ordering = ("-date_joined",) +from .models import Account +def __str__(self): + return f"{self.firstname} {self.lastname}" -# Unregister the default User admin and register with Unfold -try: - admin.site.unregister(User) -except admin.sites.NotRegistered: - pass +# # Register your models here. +# admin.site.register(Account) -admin.site.register(User, UnfoldUserAdmin) \ No newline at end of file +# Table for related records +class CustomTableSection(TableSection): + verbose_name = _("Keywarden Users") # Displays custom table title + height = 300 # Force the table height. Ideal for large amount of records + # related_name = "related_name_set" # Related model field name + fields = ["id", "firstname", "lastname", "joined_date"] # Fields from related model + + # # Custom field + # def custom_field(self, instance): + # return instance.pk + +# # Simple template with custom content +# class CardSection(TemplateSection): +# template_name = "keywarden/some_template.html" + +@admin.register(Account) +class SomeAdmin(ModelAdmin): + list_sections = [ + #CardSection, + CustomTableSection, + ] \ No newline at end of file diff --git a/app/apps/accounts/migrations/0001_initial.py b/app/apps/accounts/migrations/0001_initial.py new file mode 100644 index 0000000..180d264 --- /dev/null +++ b/app/apps/accounts/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 5.1 on 2025-11-11 09:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Accounts', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('firstname', models.CharField(max_length=255)), + ('lastname', models.CharField(max_length=255)), + ('email', models.CharField(max_length=255)), + ('joined_date', models.DateField(null=True)), + ], + ), + ] diff --git a/app/apps/accounts/migrations/0002_rename_accounts_account.py b/app/apps/accounts/migrations/0002_rename_accounts_account.py new file mode 100644 index 0000000..3bc61fd --- /dev/null +++ b/app/apps/accounts/migrations/0002_rename_accounts_account.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1 on 2025-11-11 09:24 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.RenameModel( + old_name='Accounts', + new_name='Account', + ), + ] diff --git a/app/apps/accounts/migrations/__init__.py b/app/apps/accounts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/apps/accounts/models.py b/app/apps/accounts/models.py index e69de29..d15c6e4 100644 --- a/app/apps/accounts/models.py +++ b/app/apps/accounts/models.py @@ -0,0 +1,7 @@ +from django.db import models + +class Account(models.Model): + firstname = models.CharField(max_length=255) + lastname = models.CharField(max_length=255) + email = models.CharField(max_length=255) + joined_date = models.DateField(null=True) diff --git a/app/keywarden/settings/base.py b/app/keywarden/settings/base.py index 0536357..985045e 100644 --- a/app/keywarden/settings/base.py +++ b/app/keywarden/settings/base.py @@ -146,24 +146,32 @@ UNFOLD = { "SITE_DROPDOWN": [ { "icon": "diamond", - "title": _("Keywarden"), + "title": _("Keywarden Development"), "link": "https://keywarden.dev.ntbx.io", "attrs": { "target": "_blank", }, }, + { + "icon": "diamond", + "title": _("Keywarden [Inactive]"), + "link": "https://keywarden.ntbx.io", + "attrs": { + "target": "_blank", + }, + }, ], # "TABS": [ # { # "models": [ - # "app_label.Accounts", + # "keywarden.accounts", # ], # "items": [ # { # "title": _("Accounts"), - # "link": reverse_lazy("admin:app_label_model_name_changelist"), - # "permission": "keywarden.settings.permission_callback", + # "link": reverse_lazy("admin:accounts"), + # "permission": "keywarden.permission_callback", # }, # ], # },