Keep showing Protected only for objects that are already set as that
@@ -33,13 +33,21 @@ class HideProtectedLevelMixin:
Hide ``protected`` privacy level from Form.
Remove Protected for now since it cause confusions to users.
- There is a better way to manage this by using Version states
- See: https://github.com/rtfd/readthedocs.org/issues/5321
+
+ If the current ``privacy_level`` is ``protected`` we show it (so users keep
+ seeing consistency values), and hide it otherwise (so it can't be selected).
+
+ There is a better way to manage this by using Version states See:
+ https://github.com/rtfd/readthedocs.org/issues/5321
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ if any([
+ not self.instance,
+ self.instance and self.instance.privacy_level != PROTECTED,
+ ]):
privacy_level = list(PRIVACY_CHOICES)
privacy_level.remove((PROTECTED, _('Protected')))
self.fields['privacy_level'].choices = privacy_level
