Skip to content

Commit 1a13261

Browse files
committed
Hide "Protected" privacy level from users
Protected causes a lot of confusions to users. I'm hiding it from the Form for now as a temporarily solution while we implement more Version states and this behavior can be easily managed. See #5321 Project/Version that are Protected will remain in the same state and everything should keep working. Although, new Project/Version are not allowed to set as Protected.
1 parent 5bdb2f8 commit 1a13261

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

docs/privacy.rst

+1-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Privacy Levels
22
==============
33

44
Read the Docs supports 3 different privacy levels on 2 different objects;
5-
Public, Protected, Private on Projects and Versions.
5+
Public, Private on Projects and Versions.
66

77
Understanding the Privacy Levels
88
--------------------------------
@@ -12,8 +12,6 @@ Understanding the Privacy Levels
1212
+============+============+===========+===========+=============+
1313
| Private | No | No | No | Yes |
1414
+------------+------------+-----------+-----------+-------------+
15-
| Protected | Yes | No | No | Yes |
16-
+------------+------------+-----------+-----------+-------------+
1715
| Public | Yes | Yes | Yes | Yes |
1816
+------------+------------+-----------+-----------+-------------+
1917

@@ -27,18 +25,6 @@ Public
2725
This is the easiest and most obvious. It is also the default.
2826
It means that everything is available to be seen by everyone.
2927

30-
Protected
31-
~~~~~~~~~
32-
33-
Protected means that your object won't show up in Listing Pages,
34-
but Detail pages still work. For example, a Project that is Protected will
35-
not show on the homepage Recently Updated list, however,
36-
if you link directly to the project, you will get a 200 and the page will display.
37-
38-
Protected Versions are similar, they won't show up in your version listings,
39-
but will be available once linked to.
40-
41-
4228
Private
4329
~~~~~~~
4430

readthedocs/builds/forms.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
from django.utils.translation import ugettext_lazy as _
77

88
from readthedocs.builds.models import Version
9+
from readthedocs.core.mixins import HideProtectedLevelMixin
910
from readthedocs.core.utils import trigger_build
1011

1112

12-
class VersionForm(forms.ModelForm):
13+
class VersionForm(HideProtectedLevelMixin, forms.ModelForm):
1314

1415
class Meta:
1516
model = Version

readthedocs/core/mixins.py

+21
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
from django.contrib.auth.decorators import login_required
66
from django.utils.decorators import method_decorator
7+
from django.utils.translation import ugettext_lazy as _
78
from vanilla import ListView
89

10+
from readthedocs.projects.constants import PRIVACY_CHOICES, PROTECTED
11+
912

1013
class ListViewWithForm(ListView):
1114

@@ -22,3 +25,21 @@ class LoginRequiredMixin:
2225
@method_decorator(login_required)
2326
def dispatch(self, *args, **kwargs):
2427
return super().dispatch(*args, **kwargs)
28+
29+
30+
class HideProtectedLevelMixin:
31+
32+
"""
33+
Hide ``protected`` privacy level from Form.
34+
35+
Remove Protected for now since it cause confusions to users.
36+
There is a better way to manage this by using Version states
37+
See: https://github.com/rtfd/readthedocs.org/issues/5321
38+
"""
39+
40+
def __init__(self, *args, **kwargs):
41+
super().__init__(*args, **kwargs)
42+
43+
privacy_level = list(PRIVACY_CHOICES)
44+
privacy_level.remove((PROTECTED, _('Protected')))
45+
self.fields['privacy_level'].choices = privacy_level

readthedocs/projects/forms.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from guardian.shortcuts import assign
1515
from textclassifier.validators import ClassifierValidator
1616

17+
from readthedocs.core.mixins import HideProtectedLevelMixin
1718
from readthedocs.core.utils import slugify, trigger_build
1819
from readthedocs.core.utils.extend import SettingsOverrideObject
1920
from readthedocs.integrations.models import Integration
@@ -189,7 +190,7 @@ def clean_tags(self):
189190
return tags
190191

191192

192-
class ProjectAdvancedForm(ProjectTriggerBuildMixin, ProjectForm):
193+
class ProjectAdvancedForm(HideProtectedLevelMixin, ProjectTriggerBuildMixin, ProjectForm):
193194

194195
"""Advanced project option form."""
195196

readthedocs/projects/models.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ class Project(models.Model):
329329
choices=constants.PRIVACY_CHOICES,
330330
default=settings.DEFAULT_PRIVACY_LEVEL,
331331
help_text=_(
332-
'Level of privacy that you want on the repository. '
333-
'Protected means public but not in listings.',
332+
'Level of privacy that you want on the repository.',
334333
),
335334
)
336335
version_privacy_level = models.CharField(

0 commit comments

Comments
 (0)