Skip to content

Remove usage of project.privacy_level #7013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 3, 2020
Merged
36 changes: 0 additions & 36 deletions docs/privacy.rst

This file was deleted.

22 changes: 21 additions & 1 deletion docs/versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,33 @@ any user with a link to its docs would be able to see it.
This is useful when:

- You no longer support a version, but you don't want to remove its docs.
- You have a work in progress version and don't want to publish its docs just yet.
- You have a work in progress version and don't want to publish its docs just yet.

.. note::

Active versions that are hidden will be listed as ``Disallow: /path/to/version/``
in the default `robots.txt file <https://www.robotstxt.org/>`__ created by Read the Docs.

Privacy levels
--------------

.. note::

Privacy levels are only supported on :doc:`Read the Docs for Business </commercial/index>`.

Public
~~~~~~

This is the easiest and most obvious.
It means that everything is available to be seen by everyone.

Private
~~~~~~~

Private versions are available only to people who have permissions to see them.
They will not display on any list view, and will 404 when you link them to others.
If you want to share your docs temporarily, see :doc:`/commercial/sharing`.

Version warning
---------------

Expand Down
3 changes: 0 additions & 3 deletions readthedocs/api/v3/tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def test_import_project(self):
self.assertEqual(project.repo, 'https://github.com/rtfd/template')
self.assertEqual(project.language, 'en')
self.assertEqual(project.programming_language, 'py')
self.assertEqual(project.privacy_level, 'public')
self.assertEqual(project.project_url, 'http://template.readthedocs.io/')
self.assertIn(self.me, project.users.all())
self.assertEqual(project.builds.count(), 1)
Expand Down Expand Up @@ -201,7 +200,6 @@ def test_update_project(self):
'homepage': 'https://updated-homepage.org',
'default_version': 'stable',
'default_branch': 'updated-default-branch',
'privacy_level': 'private',
'analytics_code': 'UA-XXXXXX',
'show_version_warning': False,
'single_version': True,
Expand Down Expand Up @@ -229,7 +227,6 @@ def test_update_project(self):
self.assertEqual(self.project.project_url, 'https://updated-homepage.org')
self.assertEqual(self.project.default_version, 'stable')
self.assertEqual(self.project.default_branch, 'updated-default-branch')
self.assertEqual(self.project.privacy_level, 'public')
self.assertEqual(self.project.analytics_code, 'UA-XXXXXX')
self.assertEqual(self.project.show_version_warning, False)
self.assertEqual(self.project.single_version, True)
Expand Down
2 changes: 0 additions & 2 deletions readthedocs/core/mixins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Common mixin classes for views."""

from django.contrib.auth.mixins import LoginRequiredMixin
Expand Down
4 changes: 1 addition & 3 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from textclassifier.validators import ClassifierValidator

from readthedocs.builds.constants import INTERNAL
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 @@ -190,7 +189,7 @@ def clean_tags(self):
return tags


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

"""Advanced project option form."""

Expand All @@ -199,7 +198,6 @@ class Meta:
per_project_settings = (
'default_version',
'default_branch',
'privacy_level',
'analytics_code',
'show_version_warning',
'single_version',
Expand Down
26 changes: 2 additions & 24 deletions readthedocs/rtd_tests/tests/test_project_forms.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from unittest import mock

from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.translation import ugettext_lazy as _
from django_dynamic_fixture import get
from textclassifier.validators import ClassifierValidator

from readthedocs.builds.constants import LATEST, STABLE, EXTERNAL
from readthedocs.builds.constants import EXTERNAL, LATEST, STABLE
from readthedocs.builds.models import Version
from readthedocs.projects.constants import (
PRIVATE,
PRIVACY_CHOICES,
PROTECTED,
PUBLIC,
REPO_TYPE_GIT,
Expand Down Expand Up @@ -274,28 +274,6 @@ def test_default_version_field_if_no_active_version(self):
self.assertTrue(form.fields['default_version'].widget.attrs['readonly'])
self.assertEqual(form.fields['default_version'].initial, 'latest')

def test_hide_protected_privacy_level_new_objects(self):
"""
Test PROTECTED is only allowed in old objects.

New projects are not allowed to set the privacy level as protected.
"""
# New default object
project = get(Project)
form = ProjectAdvancedForm(instance=project)

privacy_choices = list(PRIVACY_CHOICES)
privacy_choices.remove((PROTECTED, _('Protected')))
self.assertEqual(form.fields['privacy_level'].choices, privacy_choices)

# "Old" object with privacy_level previously set as protected
project = get(
Project,
privacy_level=PROTECTED,
)
form = ProjectAdvancedForm(instance=project)
self.assertEqual(form.fields['privacy_level'].choices, list(PRIVACY_CHOICES))


class TestProjectAdvancedFormDefaultBranch(TestCase):

Expand Down
9 changes: 0 additions & 9 deletions readthedocs/templates/core/project_detail_right.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,6 @@ <h3>{% trans "Tags" %}</h3>
</p>
{% endblock %}

{% block privacy-level %}
<h3>{% trans "Project Privacy Level" %}</h3>
<div id="privacy_level">
<p>
{{ project.get_privacy_level_display }}
</p>
</div>
{% endblock %}

{% block short-urls %}
<h3>{% trans "Short URLs" %}</h3>
<p>
Expand Down