update admin panel calendar
This commit is contained in:
parent
fb4c79c5c6
commit
1d555cd031
6 changed files with 119 additions and 7 deletions
|
|
@ -5,7 +5,7 @@ import io
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
import jdatetime
|
import jdatetime
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from rangefilter.filters import DateTimeRangeFilter
|
from .admin_filters import JalaliDateTimeRangeFilter
|
||||||
# from utils.accounts_client import get_user_detailed_info
|
# from utils.accounts_client import get_user_detailed_info
|
||||||
|
|
||||||
@admin.action(description="export excel")
|
@admin.action(description="export excel")
|
||||||
|
|
@ -94,9 +94,13 @@ def export_accounts_as_excel(modeladmin, request, queryset):
|
||||||
class TransactionAdmin(admin.ModelAdmin):
|
class TransactionAdmin(admin.ModelAdmin):
|
||||||
list_display = ['uuid', 'application', 'splited_amount', 'jalali_datetime', 'payer', 'payer_type', 'payee', 'payee_type', 'state', 'amount', 'created_at', 'updated_at']
|
list_display = ['uuid', 'application', 'splited_amount', 'jalali_datetime', 'payer', 'payer_type', 'payee', 'payee_type', 'state', 'amount', 'created_at', 'updated_at']
|
||||||
search_fields = ['uuid', 'created_at', 'updated_at', 'payer_account__owner_uuid', 'payee_account__owner_uuid', 'application__uuid']
|
search_fields = ['uuid', 'created_at', 'updated_at', 'payer_account__owner_uuid', 'payee_account__owner_uuid', 'application__uuid']
|
||||||
list_filter = ['application', 'state', ('created_at', DateTimeRangeFilter), ('updated_at', DateTimeRangeFilter),]
|
list_filter = ['application', 'state', ('created_at', JalaliDateTimeRangeFilter), ('updated_at', JalaliDateTimeRangeFilter),]
|
||||||
actions = [export_excel]
|
actions = [export_excel]
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
css = {'all': ('admin/css/django_jalali.min.css',)}
|
||||||
|
js = ('admin/js/django_jalali.min.js',)
|
||||||
|
|
||||||
class AccountAdmin(admin.ModelAdmin):
|
class AccountAdmin(admin.ModelAdmin):
|
||||||
list_display = ['uuid', 'owner_uuid', 'wallet', 'owner_type', 'balance', 'get_name']
|
list_display = ['uuid', 'owner_uuid', 'wallet', 'owner_type', 'balance', 'get_name']
|
||||||
search_fields = ['uuid', 'owner_uuid']
|
search_fields = ['uuid', 'owner_uuid']
|
||||||
|
|
|
||||||
46
apps/wallet/admin_filters.py
Normal file
46
apps/wallet/admin_filters.py
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from django.contrib.admin.widgets import AdminSplitDateTime
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from rangefilter.filters import DateTimeRangeFilter
|
||||||
|
|
||||||
|
from jalali_date.fields import SplitJalaliDateTimeField
|
||||||
|
from jalali_date.widgets import AdminSplitJalaliDateTime as _AdminSplitJalaliDateTime
|
||||||
|
|
||||||
|
|
||||||
|
class AdminSplitJalaliDateTime(_AdminSplitJalaliDateTime):
|
||||||
|
# jalali_date's own template lives under the (unused, see below) 'jalali_date'
|
||||||
|
# app, which we deliberately don't register in INSTALLED_APPS: its
|
||||||
|
# templatetags module imports the stdlib `distutils`, removed in Python 3.12+,
|
||||||
|
# and Django auto-imports every installed app's templatetags at startup.
|
||||||
|
# Django's stock split-datetime template renders subwidgets generically, so
|
||||||
|
# it works fine here without needing that app registered.
|
||||||
|
template_name = AdminSplitDateTime.template_name
|
||||||
|
|
||||||
|
|
||||||
|
class JalaliDateTimeRangeFilter(DateTimeRangeFilter):
|
||||||
|
def _get_form_fields(self):
|
||||||
|
return OrderedDict(
|
||||||
|
(
|
||||||
|
(
|
||||||
|
self.lookup_kwarg_gte,
|
||||||
|
SplitJalaliDateTimeField(
|
||||||
|
label='',
|
||||||
|
widget=AdminSplitJalaliDateTime(attrs={'placeholder': _('From date')}),
|
||||||
|
localize=True,
|
||||||
|
required=False,
|
||||||
|
initial=self.default_gte,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
self.lookup_kwarg_lte,
|
||||||
|
SplitJalaliDateTimeField(
|
||||||
|
label='',
|
||||||
|
widget=AdminSplitJalaliDateTime(attrs={'placeholder': _('To date')}),
|
||||||
|
localize=True,
|
||||||
|
required=False,
|
||||||
|
initial=self.default_lte,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
50
log/accounts.log
Normal file
50
log/accounts.log
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
2026-08-01 15:27:52,276 [INFO] django.server log 98318 6145355776 "GET /admin/login/ HTTP/1.1" 200 4068
|
||||||
|
2026-08-01 15:28:16,343 [INFO] django.server log 98318 6145355776 "GET /admin/login/ HTTP/1.1" 200 4068
|
||||||
|
2026-08-01 15:28:16,620 [INFO] django.server log 98318 6145355776 "POST /admin/login/ HTTP/1.1" 302 0
|
||||||
|
2026-08-01 15:28:16,695 [INFO] django.server log 98318 6145355776 "GET /admin/wallet/transaction/ HTTP/1.1" 200 30332
|
||||||
|
2026-08-01 15:29:03,893 [INFO] django.server log 98318 6162182144 "GET /admin/login/ HTTP/1.1" 200 4068
|
||||||
|
2026-08-01 15:29:03,994 [INFO] django.server log 98318 6145355776 "GET /static/admin/css/login.css HTTP/1.1" 200 958
|
||||||
|
2026-08-01 15:29:03,995 [INFO] django.server log 98318 6179008512 "GET /static/admin/css/dark_mode.css HTTP/1.1" 200 2682
|
||||||
|
2026-08-01 15:29:03,995 [INFO] django.server log 98318 6195834880 "GET /static/admin/css/nav_sidebar.css HTTP/1.1" 200 2810
|
||||||
|
2026-08-01 15:29:03,997 [INFO] django.server log 98318 6229487616 "GET /static/admin/js/theme.js HTTP/1.1" 200 1943
|
||||||
|
2026-08-01 15:29:03,997 [INFO] django.server log 98318 6212661248 "GET /static/admin/css/responsive.css HTTP/1.1" 200 17905
|
||||||
|
2026-08-01 15:29:03,997 [INFO] django.server log 98318 6162182144 "GET /static/admin/css/base.css HTTP/1.1" 200 21544
|
||||||
|
2026-08-01 15:29:03,998 [INFO] django.server log 98318 6229487616 "GET /static/admin/js/nav_sidebar.js HTTP/1.1" 200 3063
|
||||||
|
2026-08-01 15:29:04,565 [WARNING] django.server log 98318 6229487616 "GET /favicon.ico HTTP/1.1" 404 3758
|
||||||
|
2026-08-01 15:32:02,114 [INFO] django.server log 98318 6145355776 "GET /admin/ HTTP/1.1" 302 0
|
||||||
|
2026-08-01 15:32:02,125 [INFO] django.server log 98318 6145355776 "GET /admin/login/?next=/admin/ HTTP/1.1" 200 4081
|
||||||
|
2026-08-01 15:32:02,263 [INFO] django.server log 98318 6162182144 "GET /static/admin/css/dark_mode.css HTTP/1.1" 200 2682
|
||||||
|
2026-08-01 15:32:02,266 [INFO] django.server log 98318 6179008512 "GET /static/admin/css/nav_sidebar.css HTTP/1.1" 200 2810
|
||||||
|
2026-08-01 15:32:02,266 [INFO] django.server log 98318 6145355776 "GET /static/admin/css/base.css HTTP/1.1" 200 21544
|
||||||
|
2026-08-01 15:32:02,267 [INFO] django.server log 98318 6212661248 "GET /static/admin/js/theme.js HTTP/1.1" 200 1943
|
||||||
|
2026-08-01 15:32:02,267 [INFO] django.server log 98318 6195834880 "GET /static/admin/css/login.css HTTP/1.1" 200 958
|
||||||
|
2026-08-01 15:32:02,268 [INFO] django.server log 98318 6229487616 "GET /static/admin/css/responsive.css HTTP/1.1" 200 17905
|
||||||
|
2026-08-01 15:32:02,276 [INFO] django.server log 98318 6229487616 "GET /static/admin/js/nav_sidebar.js HTTP/1.1" 200 3063
|
||||||
|
2026-08-01 15:32:02,403 [WARNING] django.server log 98318 6229487616 "GET /favicon.ico HTTP/1.1" 404 3758
|
||||||
|
2026-08-01 15:32:17,288 [INFO] django.server log 98318 6229487616 "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
|
||||||
|
2026-08-01 15:32:17,351 [INFO] django.server log 98318 6229487616 "GET /admin/ HTTP/1.1" 200 13562
|
||||||
|
2026-08-01 15:32:17,384 [INFO] django.server log 98318 6229487616 "GET /static/admin/css/dashboard.css HTTP/1.1" 200 441
|
||||||
|
2026-08-01 15:32:17,389 [INFO] django.server log 98318 6195834880 "GET /static/admin/img/icon-changelink.svg HTTP/1.1" 200 380
|
||||||
|
2026-08-01 15:32:17,389 [INFO] django.server log 98318 6229487616 "GET /static/admin/img/icon-addlink.svg HTTP/1.1" 200 331
|
||||||
|
2026-08-01 15:32:22,629 [INFO] django.server log 98318 6229487616 "GET /admin/wallet/transaction/ HTTP/1.1" 200 30332
|
||||||
|
2026-08-01 15:32:22,649 [INFO] django.server log 98318 6162182144 "GET /static/admin/js/jquery.init.js HTTP/1.1" 200 347
|
||||||
|
2026-08-01 15:32:22,649 [INFO] django.server log 98318 6229487616 "GET /static/admin/css/changelists.css HTTP/1.1" 200 6811
|
||||||
|
2026-08-01 15:32:22,649 [INFO] django.server log 98318 6179008512 "GET /static/admin/css/django_jalali.min.css HTTP/1.1" 200 8077
|
||||||
|
2026-08-01 15:32:22,650 [INFO] django.server log 98318 6212661248 "GET /static/admin/js/django_jalali.min.js HTTP/1.1" 200 19826
|
||||||
|
2026-08-01 15:32:22,657 [INFO] django.server log 98318 6212661248 "GET /static/admin/js/actions.js HTTP/1.1" 200 8067
|
||||||
|
2026-08-01 15:32:22,658 [INFO] django.server log 98318 6229487616 "GET /static/admin/css/widgets.css HTTP/1.1" 200 11800
|
||||||
|
2026-08-01 15:32:22,658 [INFO] django.server log 98318 6162182144 "GET /static/admin/js/core.js HTTP/1.1" 200 6208
|
||||||
|
2026-08-01 15:32:22,660 [INFO] django.server log 98318 6179008512 "GET /static/admin/js/admin/RelatedObjectLookups.js HTTP/1.1" 200 9042
|
||||||
|
2026-08-01 15:32:22,660 [INFO] django.server log 98318 6145355776 "GET /static/admin/js/vendor/jquery/jquery.js HTTP/1.1" 200 285312
|
||||||
|
2026-08-01 15:32:22,666 [INFO] django.server log 98318 6145355776 "GET /static/admin/js/urlify.js HTTP/1.1" 200 7887
|
||||||
|
2026-08-01 15:32:22,666 [INFO] django.server log 98318 6212661248 "GET /static/admin/js/prepopulate.js HTTP/1.1" 200 1531
|
||||||
|
2026-08-01 15:32:22,667 [INFO] django.server log 98318 6195834880 "GET /admin/jsi18n/ HTTP/1.1" 200 3342
|
||||||
|
2026-08-01 15:32:22,667 [INFO] django.server log 98318 6229487616 "GET /static/admin/img/search.svg HTTP/1.1" 200 458
|
||||||
|
2026-08-01 15:32:22,669 [INFO] django.server log 98318 6179008512 "GET /static/admin/js/vendor/xregexp/xregexp.js HTTP/1.1" 200 325171
|
||||||
|
2026-08-01 15:32:22,679 [INFO] django.server log 98318 6179008512 "GET /static/admin/js/filters.js HTTP/1.1" 200 978
|
||||||
|
2026-08-01 15:32:22,696 [INFO] django.server log 98318 6229487616 "GET /static/admin/img/icon-viewlink.svg HTTP/1.1" 200 581
|
||||||
|
2026-08-01 15:32:22,696 [INFO] django.server log 98318 6179008512 "GET /static/admin/img/tooltag-add.svg HTTP/1.1" 200 331
|
||||||
|
2026-08-01 15:32:22,698 [INFO] django.server log 98318 6179008512 "GET /static/admin/img/sorting-icons.svg HTTP/1.1" 200 1097
|
||||||
|
2026-08-01 15:32:22,719 [INFO] django.server log 98318 6179008512 "GET /static/admin/js/calendar.js HTTP/1.1" 200 9141
|
||||||
|
2026-08-01 15:32:22,720 [INFO] django.server log 98318 6229487616 "GET /static/admin/js/admin/DateTimeShortcuts.js HTTP/1.1" 200 19319
|
||||||
|
2026-08-01 15:32:22,736 [INFO] django.server log 98318 6229487616 "GET /static/admin/img/icon-clock.svg HTTP/1.1" 200 677
|
||||||
0
log/errors.log
Normal file
0
log/errors.log
Normal file
2
static/admin/css/django_jalali.min.css
vendored
Executable file
2
static/admin/css/django_jalali.min.css
vendored
Executable file
File diff suppressed because one or more lines are too long
20
static/admin/js/django_jalali.min.js
vendored
20
static/admin/js/django_jalali.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue