Skip to content

Commit

Permalink
Hide "Protected" privacy level from users
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
humitos committed Jun 27, 2019
1 parent 5bdb2f8 commit 1a13261
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
16 changes: 1 addition & 15 deletions docs/privacy.rst
Expand Up @@ -2,7 +2,7 @@ Privacy Levels
==============

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

Understanding the Privacy Levels
--------------------------------
Expand All @@ -12,8 +12,6 @@ Understanding the Privacy Levels
+============+============+===========+===========+=============+
| Private | No | No | No | Yes |
+------------+------------+-----------+-----------+-------------+
| Protected | Yes | No | No | Yes |
+------------+------------+-----------+-----------+-------------+
| Public | Yes | Yes | Yes | Yes |
+------------+------------+-----------+-----------+-------------+

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

Protected
~~~~~~~~~

Protected means that your object won't show up in Listing Pages,
but Detail pages still work. For example, a Project that is Protected will
not show on the homepage Recently Updated list, however,
if you link directly to the project, you will get a 200 and the page will display.

Protected Versions are similar, they won't show up in your version listings,
but will be available once linked to.


Private
~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion readthedocs/builds/forms.py
Expand Up @@ -6,10 +6,11 @@
from django.utils.translation import ugettext_lazy as _

from readthedocs.builds.models import Version
from readthedocs.core.mixins import HideProtectedLevelMixin
from readthedocs.core.utils import trigger_build


class VersionForm(forms.ModelForm):
class VersionForm(HideProtectedLevelMixin, forms.ModelForm):

class Meta:
model = Version
Expand Down
21 changes: 21 additions & 0 deletions readthedocs/core/mixins.py
Expand Up @@ -4,8 +4,11 @@

from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from vanilla import ListView

from readthedocs.projects.constants import PRIVACY_CHOICES, PROTECTED


class ListViewWithForm(ListView):

Expand All @@ -22,3 +25,21 @@ class LoginRequiredMixin:
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)


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
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

privacy_level = list(PRIVACY_CHOICES)
privacy_level.remove((PROTECTED, _('Protected')))
self.fields['privacy_level'].choices = privacy_level
3 changes: 2 additions & 1 deletion readthedocs/projects/forms.py
Expand Up @@ -14,6 +14,7 @@
from guardian.shortcuts import assign
from textclassifier.validators import ClassifierValidator

from readthedocs.core.mixins import HideProtectedLevelMixin
from readthedocs.core.utils import slugify, trigger_build
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.integrations.models import Integration
Expand Down Expand Up @@ -189,7 +190,7 @@ def clean_tags(self):
return tags


class ProjectAdvancedForm(ProjectTriggerBuildMixin, ProjectForm):
class ProjectAdvancedForm(HideProtectedLevelMixin, ProjectTriggerBuildMixin, ProjectForm):

"""Advanced project option form."""

Expand Down
3 changes: 1 addition & 2 deletions readthedocs/projects/models.py
Expand Up @@ -329,8 +329,7 @@ class Project(models.Model):
choices=constants.PRIVACY_CHOICES,
default=settings.DEFAULT_PRIVACY_LEVEL,
help_text=_(
'Level of privacy that you want on the repository. '
'Protected means public but not in listings.',
'Level of privacy that you want on the repository.',
),
)
version_privacy_level = models.CharField(
Expand Down

0 comments on commit 1a13261

Please sign in to comment.