File tree 3 files changed +75
-1
lines changed
3 files changed +75
-1
lines changed Original file line number Diff line number Diff line change 27
27
28
28
29
29
class AdminDisplayBug35Admin (admin .ModelAdmin ):
30
- list_display = ("text_enum" , "int_enum" )
30
+ list_display = (
31
+ "text_enum" ,
32
+ "int_enum" ,
33
+ "status_basic" ,
34
+ "status_basic_int" ,
35
+ "status_str" ,
36
+ "status_int" ,
37
+ )
31
38
readonly_fields = ("text_enum" , "int_enum" , "blank_int" , "blank_txt" )
32
39
33
40
Original file line number Diff line number Diff line change @@ -398,3 +398,61 @@ class GNSSConstellation(IntFlag):
398
398
GALILEO = 1 << 2
399
399
BEIDOU = 1 << 3
400
400
QZSS = 1 << 4
401
+
402
+
403
+ class NestStatusBasic (Enum ):
404
+ INIT = "INIT"
405
+ LOADED = "LOADED"
406
+ ACTIVE = "ACTIVE"
407
+ DONE = "DONE"
408
+ REJECTED = "REJECTED"
409
+ CANCELLED = "CANCELLED"
410
+
411
+ def __hash__ (self ):
412
+ return hash (self .value )
413
+
414
+ def __eq__ (self , value ) -> bool :
415
+ if isinstance (value , self .__class__ ):
416
+ return self .value == value .value
417
+ try :
418
+ return self .value == self .__class__ (value ).value
419
+ except (ValueError , TypeError ):
420
+ return False
421
+
422
+
423
+ class NestStatusStr (str , Enum ):
424
+ INIT = "INIT"
425
+ LOADED = "LOADED"
426
+ ACTIVE = "ACTIVE"
427
+ DONE = "DONE"
428
+ REJECTED = "REJECTED"
429
+ CANCELLED = "CANCELLED"
430
+
431
+
432
+ class NestStatusBasicInt (Enum ):
433
+ INIT = 0
434
+ LOADED = 1
435
+ ACTIVE = 2
436
+ DONE = 3
437
+ REJECTED = 4
438
+ CANCELLED = 5
439
+
440
+ def __hash__ (self ):
441
+ return hash (self .value )
442
+
443
+ def __eq__ (self , value ) -> bool :
444
+ if isinstance (value , self .__class__ ):
445
+ return self .value == value .value
446
+ try :
447
+ return self .value == self .__class__ (value ).value
448
+ except (ValueError , TypeError ):
449
+ return False
450
+
451
+
452
+ class NestStatusInt (int , Enum ):
453
+ INIT = 0
454
+ LOADED = 1
455
+ ACTIVE = 2
456
+ DONE = 3
457
+ REJECTED = 4
458
+ CANCELLED = 5
Original file line number Diff line number Diff line change 41
41
TimeEnum ,
42
42
NullableConstants ,
43
43
GNSSConstellation ,
44
+ NestStatusBasic ,
45
+ NestStatusInt ,
46
+ NestStatusBasicInt ,
47
+ NestStatusStr ,
44
48
)
45
49
46
50
@@ -159,6 +163,11 @@ class AdminDisplayBug35(models.Model):
159
163
160
164
blank_txt = EnumField (TextEnum , null = True , default = None )
161
165
166
+ status_basic = EnumField (NestStatusBasic , null = True , default = None )
167
+ status_basic_int = EnumField (NestStatusBasicInt , null = True , default = None )
168
+ status_int = EnumField (NestStatusInt , null = True , default = None )
169
+ status_str = EnumField (NestStatusStr , null = True , default = None )
170
+
162
171
163
172
class EmptyEnumValueTester (models .Model ):
164
173
class BlankTextEnum (TextChoices ):
You can’t perform that action at this time.
0 commit comments