File tree 3 files changed +24
-5
lines changed 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -404,6 +404,8 @@ def update_visibility(self):
404
404
By default, listings are visible to everyone (for now). Rejected listings aren't publicly visible,
405
405
and listings with inactive packages aren't visible at all.
406
406
"""
407
+ original_visibility_bitstring = self .visibility .bitstring ()
408
+
407
409
self .visibility .public_detail = True
408
410
self .visibility .public_list = True
409
411
self .visibility .owner_detail = True
@@ -444,7 +446,8 @@ def update_visibility(self):
444
446
if versions .exclude (visibility__moderator_list = False ).count () == 0 :
445
447
self .visibility .moderator_list = False
446
448
447
- self .visibility .save ()
449
+ if self .visibility .bitstring != original_visibility_bitstring :
450
+ self .visibility .save ()
448
451
449
452
450
453
signals .post_save .connect (PackageListing .post_save , sender = PackageListing )
Original file line number Diff line number Diff line change @@ -35,3 +35,16 @@ def __str__(self) -> str:
35
35
if isinstance (field , models .BooleanField ) and getattr (self , field .name )
36
36
)
37
37
return ", " .join (flag_fields ) or "None"
38
+
39
+ def bitstring (self ) -> str :
40
+ fields = [
41
+ self .public_list ,
42
+ self .public_detail ,
43
+ self .owner_list ,
44
+ self .owner_detail ,
45
+ self .moderator_list ,
46
+ self .moderator_detail ,
47
+ self .admin_list ,
48
+ self .admin_detail ,
49
+ ]
50
+ return "" .join ("1" if field else "0" for field in fields )
Original file line number Diff line number Diff line change @@ -438,6 +438,8 @@ def update_visibility(self):
438
438
By default, versions are visible to everyone (for now). Rejected versions aren't publicly visible,
439
439
and inactive versions or versions with inactive packages aren't visible at all.
440
440
"""
441
+ original_visibility_bitstring = self .visibility .bitstring ()
442
+
441
443
self .visibility .public_detail = True
442
444
self .visibility .public_list = True
443
445
self .visibility .owner_detail = True
@@ -460,10 +462,11 @@ def update_visibility(self):
460
462
self .visibility .public_detail = False
461
463
self .visibility .public_list = False
462
464
463
- self .visibility .save ()
464
- for listing in self .package .community_listings .all ():
465
- listing .update_visibility ()
466
- self .package .recache_latest ()
465
+ if self .visibility .bitstring != original_visibility_bitstring :
466
+ self .visibility .save ()
467
+ for listing in self .package .community_listings .all ():
468
+ listing .update_visibility ()
469
+ self .package .recache_latest ()
467
470
468
471
469
472
signals .post_save .connect (PackageVersion .post_save , sender = PackageVersion )
You can’t perform that action at this time.
0 commit comments