|
5 | 5 | from django.utils.safestring import mark_safe |
6 | 6 | from django.urls import reverse |
7 | 7 | from .filters import ( |
8 | | - MinCreatedAtFiler, MaxCreatedAtFiler, MinStartFiler, MaxStartFiler, |
9 | | - MinEndFiler, MaxEndFiler, MinPriceFiler, MaxPriceFiler, |
10 | | - MinDurationFiler, MaxDurationFiler, |
11 | | - AddressFiler, ParkingZoneFiler, |
12 | | - FirstNameFiler, SecondNameFiler, ThirdNameFiler, |
13 | | - EmailFiler, IsStaffFiler, UserIdFiler, ParkingIdFiler, |
| 8 | + MinCreatedAtFilter, MaxCreatedAtFilter, MinStartFilter, MaxStartFilter, |
| 9 | + MinEndFilter, MaxEndFilter, MinPriceFilter, MaxPriceFilter, |
| 10 | + MinDurationFilter, MaxDurationFilter, |
| 11 | + AddressFilter, ParkingZoneFilter, |
| 12 | + FirstNameFilter, SecondNameFilter, ThirdNameFilter, |
| 13 | + EmailFilter, IsStaffFilter, UserIdFilter, ParkingIdFilter, |
14 | 14 | MinLatitudeFilter, MaxLatitudeFilter, MaxLongitudeFilter, |
15 | 15 | MinLongitudeFilter, MaxTotalLotsFilter, MinTotalLotsFilter, |
16 | | - MaxPricePerHourFilter, MinPricePerHourFilter |
| 16 | + MaxPricePerHourFilter, MinPricePerHourFilter, |
| 17 | + MinAvailableLotsFilter, MaxAvailableLotsFilter |
17 | 18 | ) |
18 | 19 | from pay_parking.filters import FakeFilterWithForm |
19 | 20 | from django.shortcuts import get_object_or_404 |
@@ -44,15 +45,16 @@ class PaymentAdmin(CustomModelAdmin): |
44 | 45 |
|
45 | 46 | list_filter = ( |
46 | 47 | FakeFilterWithForm, |
47 | | - MinCreatedAtFiler, MaxCreatedAtFiler, MinStartFiler, MaxStartFiler, |
48 | | - MinEndFiler, MaxEndFiler, MinPriceFiler, MaxPriceFiler, |
49 | | - MinDurationFiler, MaxDurationFiler, |
50 | | - AddressFiler, ParkingZoneFiler, |
51 | | - FirstNameFiler, SecondNameFiler, ThirdNameFiler, |
52 | | - EmailFiler, IsStaffFiler, UserIdFiler, ParkingIdFiler, |
| 48 | + MinCreatedAtFilter, MaxCreatedAtFilter, MinStartFilter, MaxStartFilter, |
| 49 | + MinEndFilter, MaxEndFilter, MinPriceFilter, MaxPriceFilter, |
| 50 | + MinDurationFilter, MaxDurationFilter, |
| 51 | + AddressFilter, ParkingZoneFilter, |
| 52 | + FirstNameFilter, SecondNameFilter, ThirdNameFilter, |
| 53 | + EmailFilter, IsStaffFilter, UserIdFilter, ParkingIdFilter, |
53 | 54 | MinLatitudeFilter, MaxLatitudeFilter, MaxLongitudeFilter, |
54 | 55 | MinLongitudeFilter, MaxTotalLotsFilter, MinTotalLotsFilter, |
55 | | - MaxPricePerHourFilter, MinPricePerHourFilter |
| 56 | + MaxPricePerHourFilter, MinPricePerHourFilter, |
| 57 | + MinAvailableLotsFilter, MaxAvailableLotsFilter |
56 | 58 | ) |
57 | 59 |
|
58 | 60 | @admin.display(description='Пользователь', ordering='user_id') |
@@ -104,16 +106,16 @@ def changelist_view(self, request, extra_context=None): |
104 | 106 | user_id = request.GET.get('user_id') |
105 | 107 | extra_context = {} |
106 | 108 | if user_id: |
107 | | - user = get_object_or_404(User, pk=user_id) |
108 | | - extra_context.update({ |
109 | | - 'title': f'Оплаты пользователя {user}' |
110 | | - }) |
| 109 | + try: |
| 110 | + extra_context['title'] = f'Оплаты {User.objects.get(pk=user_id)}' |
| 111 | + except Exception: |
| 112 | + pass |
111 | 113 | parking_id = request.GET.get('parking_id') |
112 | 114 | if parking_id: |
113 | | - parking = get_object_or_404(Parking, pk=parking_id) |
114 | | - extra_context.update({ |
115 | | - 'subtitle': f'Оплаты парковки {parking}' |
116 | | - }) |
| 115 | + try: |
| 116 | + extra_context['subtitle'] = str(Parking.objects.get(pk=parking_id)) |
| 117 | + except Exception: |
| 118 | + pass |
117 | 119 | return super().changelist_view(request, extra_context) |
118 | 120 |
|
119 | 121 | def add_view(self, request, form_url='', extra_context=None): |
|
0 commit comments