From 2add18b8d254375c64498f7e687980d3d10ebdd8 Mon Sep 17 00:00:00 2001 From: Husanjonazamov Date: Tue, 3 Mar 2026 15:23:11 +0500 Subject: [PATCH] adminka togirlandi --- apps/geology/admin/category.py | 3 +- apps/geology/admin/gallery.py | 6 +- apps/geology/admin/geology.py | 3 +- apps/geology/admin/photo.py | 3 +- apps/shared/admin.py | 32 ---- assets/static/css/tailwind.css | 278 ++----------------------------- core/config/apps.py | 8 +- core/config/unfold.py | 78 ++++----- core/config/unfold_navigation.py | 2 +- core/settings.py | 8 + requirements.txt | 1 - 11 files changed, 69 insertions(+), 353 deletions(-) diff --git a/apps/geology/admin/category.py b/apps/geology/admin/category.py index 1017f9c..32baefd 100644 --- a/apps/geology/admin/category.py +++ b/apps/geology/admin/category.py @@ -1,11 +1,10 @@ from django.contrib import admin -from unfold.admin import ModelAdmin # noqa from apps.geology.models import Category @admin.register(Category) -class CategoryAdmin(ModelAdmin): +class CategoryAdmin(admin.ModelAdmin): list_display = ("name", "created_at", "updated_at") search_fields = ("name",) list_filter = ("created_at", "updated_at") diff --git a/apps/geology/admin/gallery.py b/apps/geology/admin/gallery.py index 469c0e1..24390bb 100644 --- a/apps/geology/admin/gallery.py +++ b/apps/geology/admin/gallery.py @@ -1,20 +1,18 @@ from django.contrib import admin -from unfold.admin import ModelAdmin from apps.geology.models import GalleryCategory, Gallery @admin.register(GalleryCategory) -class GalleryCategoryAdmin(ModelAdmin): +class GalleryCategoryAdmin(admin.ModelAdmin): list_display = ("id", "name", "created_at", "updated_at") search_fields = ("name",) filter_horizontal = ("gallery",) list_filter = ("created_at", "updated_at") exclude = ("count",) - @admin.register(Gallery) -class GalleryAdmin(ModelAdmin): +class GalleryAdmin(admin.ModelAdmin): list_display = ("id", "name", "created_at", "updated_at") search_fields = ("name",) list_filter = ("created_at", "updated_at") diff --git a/apps/geology/admin/geology.py b/apps/geology/admin/geology.py index e8e77de..18696bb 100644 --- a/apps/geology/admin/geology.py +++ b/apps/geology/admin/geology.py @@ -1,11 +1,10 @@ from django.contrib import admin -from unfold.admin import ModelAdmin # noqa from apps.geology.models import Geology @admin.register(Geology) -class GeologyAdmin(ModelAdmin): +class GeologyAdmin(admin.ModelAdmin): list_display = ("name", "category", "created_at", "updated_at") search_fields = ("name", "title", "body1", "body2", "body3") list_filter = ("category", "created_at", "updated_at") diff --git a/apps/geology/admin/photo.py b/apps/geology/admin/photo.py index 700e6d7..494b75e 100644 --- a/apps/geology/admin/photo.py +++ b/apps/geology/admin/photo.py @@ -1,11 +1,10 @@ from django.contrib import admin -from unfold.admin import ModelAdmin # noqa from apps.geology.models import Photo @admin.register(Photo) -class PhotoAdmin(ModelAdmin): +class PhotoAdmin(admin.ModelAdmin): list_display = ("name", "description", "type", "size", "image", "created_at") search_fields = ("name", "description", "type", "size", "image") list_filter = ("type",) diff --git a/apps/shared/admin.py b/apps/shared/admin.py index aef89fb..694323f 100644 --- a/apps/shared/admin.py +++ b/apps/shared/admin.py @@ -1,33 +1 @@ from django.contrib import admin -from django.contrib.auth.admin import GroupAdmin as BaseGroupAdmin -from django.contrib.auth.admin import UserAdmin as BaseUserAdmin -from django.contrib.auth.models import Group, User -from unfold.admin import ModelAdmin # noqa -from unfold.forms import ( - UserChangeForm, - UserCreationForm, - AdminPasswordChangeForm, -) # noqa - -admin.site.unregister(Group) -admin.site.unregister(User) - - -@admin.register(Group) -class GroupAdmin(BaseGroupAdmin, ModelAdmin): - list_display = ("name",) - search_fields = ("name",) - filter_vertical = ("permissions",) - - -@admin.register(User) -class UserAdmin(BaseUserAdmin, ModelAdmin): - change_password_form = AdminPasswordChangeForm - add_form = UserCreationForm - form = UserChangeForm - list_display = ("username", "email", "is_active", "is_staff", "is_superuser") - list_filter = ("is_active", "is_staff", "is_superuser") - search_fields = ("username", "email") - ordering = ("username",) - list_editable = ("is_active", "is_staff", "is_superuser") - filter_vertical = ("groups", "user_permissions") diff --git a/assets/static/css/tailwind.css b/assets/static/css/tailwind.css index 5b0c2f7..2edf9ad 100644 --- a/assets/static/css/tailwind.css +++ b/assets/static/css/tailwind.css @@ -1,256 +1,4 @@ -/*! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com*/ -*, :after, :before { - box-sizing: border-box; - border: 0 solid #e5e7eb -} - -:after, :before { - --tw-content: "" -} - -:host, html { - line-height: 1.5; - -webkit-text-size-adjust: 100%; - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - font-family: ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji; - font-feature-settings: normal; - font-variation-settings: normal; - -webkit-tap-highlight-color: transparent -} - -body { - margin: 0; - line-height: inherit -} - -hr { - height: 0; - color: inherit; - border-top-width: 1px -} - -abbr:where([title]) { - -webkit-text-decoration: underline dotted; - text-decoration: underline dotted -} - -h1, h2, h3, h4, h5, h6 { - font-size: inherit; - font-weight: inherit -} - -a { - color: inherit; - text-decoration: inherit -} - -b, strong { - font-weight: bolder -} - -code, kbd, pre, samp { - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace; - font-feature-settings: normal; - font-variation-settings: normal; - font-size: 1em -} - -small { - font-size: 80% -} - -sub, sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: initial -} - -sub { - bottom: -.25em -} - -sup { - top: -.5em -} - -table { - text-indent: 0; - border-color: inherit; - border-collapse: collapse -} - -button, input, optgroup, select, textarea { - font-family: inherit; - font-feature-settings: inherit; - font-variation-settings: inherit; - font-size: 100%; - font-weight: inherit; - line-height: inherit; - letter-spacing: inherit; - color: inherit; - margin: 0; - padding: 0 -} - -button, select { - text-transform: none -} - -button, input:where([type=button]), input:where([type=reset]), input:where([type=submit]) { - -webkit-appearance: button; - background-color: initial; - background-image: none -} - -:-moz-focusring { - outline: auto -} - -:-moz-ui-invalid { - box-shadow: none -} - -progress { - vertical-align: initial -} - -::-webkit-inner-spin-button, ::-webkit-outer-spin-button { - height: auto -} - -[type=search] { - -webkit-appearance: textfield; - outline-offset: -2px -} - -::-webkit-search-decoration { - -webkit-appearance: none -} - -::-webkit-file-upload-button { - -webkit-appearance: button; - font: inherit -} - -summary { - display: list-item -} - -blockquote, dd, dl, figure, h1, h2, h3, h4, h5, h6, hr, p, pre { - margin: 0 -} - -fieldset { - margin: 0 -} - -fieldset, legend { - padding: 0 -} - -menu, ol, ul { - list-style: none; - margin: 0; - padding: 0 -} - -dialog { - padding: 0 -} - -textarea { - resize: vertical -} - -input::-moz-placeholder, textarea::-moz-placeholder { - opacity: 1; - color: #9ca3af -} - -input::placeholder, textarea::placeholder { - opacity: 1; - color: #9ca3af -} - -[role=button], button { - cursor: pointer -} - -:disabled { - cursor: default -} - -audio, canvas, embed, iframe, img, object, svg, video { - display: block; - vertical-align: middle -} - -img, video { - max-width: 100%; - height: auto -} - -[hidden] { - display: none -} - -*, ::backdrop, :after, :before { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: #3b82f680; - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; - --tw-contain-size: ; - --tw-contain-layout: ; - --tw-contain-paint: ; - --tw-contain-style: -} - +/* Custom project utility classes for Unfold admin */ .\!container { width: 100% !important } @@ -531,11 +279,13 @@ img, video { max-width: 300px } -.flex-shrink, .shrink { +.flex-shrink, +.shrink { flex-shrink: 1 } -.flex-grow, .grow { +.flex-grow, +.grow { flex-grow: 1 } @@ -556,11 +306,11 @@ img, video { } .grid-cols-1 { - grid-template-columns:repeat(1, minmax(0, 1fr)) + grid-template-columns: repeat(1, minmax(0, 1fr)) } .grid-cols-2 { - grid-template-columns:repeat(2, minmax(0, 1fr)) + grid-template-columns: repeat(2, minmax(0, 1fr)) } .flex-col { @@ -851,7 +601,8 @@ img, video { --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color) } -.shadow, .shadow-md { +.shadow, +.shadow-md { box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) } @@ -874,7 +625,8 @@ img, video { --tw-blur: blur(8px) } -.blur, .grayscale { +.blur, +.grayscale { filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow) } @@ -924,22 +676,22 @@ img, video { @media (min-width: 640px) { .sm\:grid-cols-2 { - grid-template-columns:repeat(2, minmax(0, 1fr)) + grid-template-columns: repeat(2, minmax(0, 1fr)) } } @media (min-width: 768px) { .md\:grid-cols-2 { - grid-template-columns:repeat(2, minmax(0, 1fr)) + grid-template-columns: repeat(2, minmax(0, 1fr)) } .md\:grid-cols-3 { - grid-template-columns:repeat(3, minmax(0, 1fr)) + grid-template-columns: repeat(3, minmax(0, 1fr)) } } @media (min-width: 1024px) { .lg\:grid-cols-4 { - grid-template-columns:repeat(4, minmax(0, 1fr)) + grid-template-columns: repeat(4, minmax(0, 1fr)) } } \ No newline at end of file diff --git a/core/config/apps.py b/core/config/apps.py index 0456fa1..83da38e 100644 --- a/core/config/apps.py +++ b/core/config/apps.py @@ -1,12 +1,6 @@ THIRD_PARTY_APPS = [ - # "jazzmin", - "unfold", - "unfold.contrib.filters", - "unfold.contrib.forms", - "unfold.contrib.import_export", - "unfold.contrib.guardian", - "unfold.contrib.simple_history", "modeltranslation", + "jazzmin", "django_ckeditor_5", "corsheaders", "rosetta", diff --git a/core/config/unfold.py b/core/config/unfold.py index c29a929..2aa02d1 100644 --- a/core/config/unfold.py +++ b/core/config/unfold.py @@ -65,43 +65,43 @@ UNFOLD = { "show_all_applications": True, "navigation": navigation.PAGES, }, - "TABS": [ - { - "models": [ - "geology.geology", - "geology.photo", - "geology.category", - ], - "items": [ - { - "title": _("Madanlar"), - "link": reverse_lazy("admin:geology_geology_changelist"), - }, - { - "title": _("Fotolar"), - "link": reverse_lazy("admin:geology_photo_changelist"), - }, - { - "title": _("Kategoriyalar"), - "link": reverse_lazy("admin:geology_category_changelist"), - }, - ], - }, - { - "models": [ - "geology.gallerycategory", - "geology.gallery", - ], - "items": [ - { - "title": _("Galereya kategoriyalari"), - "link": reverse_lazy("admin:geology_gallerycategory_changelist"), - }, - { - "title": _("Galereya"), - "link": reverse_lazy("admin:geology_gallery_changelist"), - }, - ], - }, - ], + # "TABS": [ + # { + # "models": [ + # "geology.geology", + # "geology.photo", + # "geology.category", + # ], + # "items": [ + # { + # "title": _("Madanlar"), + # "link": reverse_lazy("admin:geology_geology_changelist"), + # }, + # { + # "title": _("Fotolar"), + # "link": reverse_lazy("admin:geology_photo_changelist"), + # }, + # { + # "title": _("Kategoriyalar"), + # "link": reverse_lazy("admin:geology_category_changelist"), + # }, + # ], + # }, + # { + # "models": [ + # "geology.gallerycategory", + # "geology.gallery", + # ], + # "items": [ + # { + # "title": _("Galereya kategoriyalari"), + # "link": reverse_lazy("admin:geology_gallerycategory_changelist"), + # }, + # { + # "title": _("Galereya"), + # "link": reverse_lazy("admin:geology_gallery_changelist"), + # }, + # ], + # }, + # ], } diff --git a/core/config/unfold_navigation.py b/core/config/unfold_navigation.py index ce21b27..cc57f6f 100644 --- a/core/config/unfold_navigation.py +++ b/core/config/unfold_navigation.py @@ -29,7 +29,7 @@ PAGES = [ "title": _("Foydalanuvchilar"), "items": [ { - "title": _("Guruhlar"), + "title": _("Groups"), "icon": "person_add", "link": reverse_lazy("admin:auth_group_changelist"), "permission": lambda request: user_has_group_or_permission( diff --git a/core/settings.py b/core/settings.py index 25e4ec9..2ae0721 100644 --- a/core/settings.py +++ b/core/settings.py @@ -128,3 +128,11 @@ SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_PRELOAD = True + +JAZZMIN_SETTINGS = { + "site_title": "Geology Admin", + "site_header": "Geology Admin", + "site_brand": "Geology", + "welcome_sign": "Geologiya boshqaruv paneli", + "show_ui_builder": False, +} diff --git a/requirements.txt b/requirements.txt index 100a70f..dfdd047 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,6 @@ django-cors-headers==4.3.1 django-rosetta==0.10.0 colorama==0.4.6 PyJWT~=2.8.0 -django-unfold flower==2.0.1 celery django-redis