From afadb8da245fddb4a609ac149ca59b5f10665aa8 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Mon, 18 Mar 2019 23:04:30 +0530 Subject: [PATCH 1/4] remove description field --- readthedocs/projects/forms.py | 10 ---- readthedocs/projects/views/private.py | 3 +- .../rtd_tests/tests/test_project_forms.py | 16 ------ .../rtd_tests/tests/test_project_views.py | 50 ------------------- .../templates/core/project_details.html | 9 ---- readthedocs/templates/projects/index.rst.html | 11 ---- 6 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 readthedocs/templates/projects/index.rst.html diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py index 74ee3d15f5d..3ff97ae04c0 100644 --- a/readthedocs/projects/forms.py +++ b/readthedocs/projects/forms.py @@ -13,7 +13,6 @@ from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from guardian.shortcuts import assign -from textclassifier.validators import ClassifierValidator from readthedocs.builds.constants import TAG from readthedocs.core.utils import slugify, trigger_build @@ -21,7 +20,6 @@ from readthedocs.integrations.models import Integration from readthedocs.oauth.models import RemoteRepository from readthedocs.projects import constants -from readthedocs.projects.exceptions import ProjectSpamError from readthedocs.projects.templatetags.projects_tags import sort_version_aware from readthedocs.projects.models import ( Domain, @@ -166,7 +164,6 @@ class ProjectExtraForm(ProjectForm): class Meta: model = Project fields = ( - 'description', 'documentation_type', 'language', 'programming_language', @@ -174,12 +171,6 @@ class Meta: 'project_url', ) - description = forms.CharField( - validators=[ClassifierValidator(raises=ProjectSpamError)], - required=False, - widget=forms.Textarea, - ) - def clean_tags(self): tags = self.cleaned_data.get('tags', []) for tag in tags: @@ -289,7 +280,6 @@ class Meta: 'repo', 'repo_type', # Extra - 'description', 'language', 'programming_language', 'project_url', diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index 04d6d681b11..de33fe02a38 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -440,8 +440,7 @@ def post(self, request, *args, **kwargs): for key in ['name', 'repo', 'repo_type', 'remote_repository']: initial_data['basics'][key] = request.POST.get(key) initial_data['extra'] = {} - for key in ['description', 'project_url']: - initial_data['extra'][key] = request.POST.get(key) + initial_data['extra']['project_url'] = request.POST.get(key) request.method = 'GET' return self.wizard_class.as_view(initial_dict=initial_data)(request) diff --git a/readthedocs/rtd_tests/tests/test_project_forms.py b/readthedocs/rtd_tests/tests/test_project_forms.py index e762e4e237e..be6122f93c5 100644 --- a/readthedocs/rtd_tests/tests/test_project_forms.py +++ b/readthedocs/rtd_tests/tests/test_project_forms.py @@ -3,7 +3,6 @@ from django.test import TestCase from django.test.utils import override_settings from django_dynamic_fixture import get -from textclassifier.validators import ClassifierValidator from readthedocs.builds.constants import LATEST from readthedocs.builds.models import Version @@ -14,7 +13,6 @@ REPO_TYPE_GIT, REPO_TYPE_HG, ) -from readthedocs.projects.exceptions import ProjectSpamError from readthedocs.projects.forms import ( EnvironmentVariableForm, ProjectAdvancedForm, @@ -30,20 +28,6 @@ class TestProjectForms(TestCase): - @mock.patch.object(ClassifierValidator, '__call__') - def test_form_spam(self, mocked_validator): - """Form description field fails spam validation.""" - mocked_validator.side_effect = ProjectSpamError - - data = { - 'description': 'foo', - 'documentation_type': 'sphinx', - 'language': 'en', - } - form = ProjectExtraForm(data) - with self.assertRaises(ProjectSpamError): - form.is_valid() - def test_import_repo_url(self): """Validate different type of repository URLs on importing a Project.""" diff --git a/readthedocs/rtd_tests/tests/test_project_views.py b/readthedocs/rtd_tests/tests/test_project_views.py index f561f78acd6..77cfc2de8a0 100644 --- a/readthedocs/rtd_tests/tests/test_project_views.py +++ b/readthedocs/rtd_tests/tests/test_project_views.py @@ -42,7 +42,6 @@ def setUp(self): 'repo_type': 'git', }, 'extra': { - 'description': 'Describe foobar', 'language': 'en', 'documentation_type': 'sphinx', }, @@ -151,7 +150,6 @@ def setUp(self): super().setUp() self.step_data['basics']['advanced'] = True self.step_data['extra'] = { - 'description': 'Describe foobar', 'language': 'en', 'documentation_type': 'sphinx', 'tags': 'foo, bar, baz', @@ -205,54 +203,6 @@ def test_remote_repository_is_added(self): self.assertIsNotNone(proj) self.assertEqual(proj.remote_repository, remote_repo) - @patch( - 'readthedocs.projects.views.private.ProjectExtraForm.clean_description', - create=True, - ) - def test_form_spam(self, mocked_validator): - """Don't add project on a spammy description.""" - self.user.date_joined = timezone.now() - timedelta(days=365) - self.user.save() - mocked_validator.side_effect = ProjectSpamError - - with self.assertRaises(Project.DoesNotExist): - proj = Project.objects.get(name='foobar') - - resp = self.post_step('basics') - self.assertWizardResponse(resp, 'extra') - resp = self.post_step('extra', session=list(resp._request.session.items())) - self.assertIsInstance(resp, HttpResponseRedirect) - self.assertEqual(resp.status_code, 302) - self.assertEqual(resp['location'], '/') - - with self.assertRaises(Project.DoesNotExist): - proj = Project.objects.get(name='foobar') - self.assertFalse(self.user.profile.banned) - - @patch( - 'readthedocs.projects.views.private.ProjectExtraForm.clean_description', - create=True, - ) - def test_form_spam_ban_user(self, mocked_validator): - """Don't add spam and ban new user.""" - self.user.date_joined = timezone.now() - self.user.save() - mocked_validator.side_effect = ProjectSpamError - - with self.assertRaises(Project.DoesNotExist): - proj = Project.objects.get(name='foobar') - - resp = self.post_step('basics') - self.assertWizardResponse(resp, 'extra') - resp = self.post_step('extra', session=list(resp._request.session.items())) - self.assertIsInstance(resp, HttpResponseRedirect) - self.assertEqual(resp.status_code, 302) - self.assertEqual(resp['location'], '/') - - with self.assertRaises(Project.DoesNotExist): - proj = Project.objects.get(name='foobar') - self.assertTrue(self.user.profile.banned) - class TestImportDemoView(MockBuildTestCase): """Test project import demo view.""" diff --git a/readthedocs/templates/core/project_details.html b/readthedocs/templates/core/project_details.html index 205d296cd2a..913819053a9 100644 --- a/readthedocs/templates/core/project_details.html +++ b/readthedocs/templates/core/project_details.html @@ -75,15 +75,6 @@

{% trans "Build a version" %}

{% endif %} {% endblock %} -{% if project.description %} -
-

{% trans "Description" %}

-

- {{ project.description|restructuredtext }} -

-
-{% endif %} - {# END .module #}
diff --git a/readthedocs/templates/projects/index.rst.html b/readthedocs/templates/projects/index.rst.html deleted file mode 100644 index d4dc1e54cc9..00000000000 --- a/readthedocs/templates/projects/index.rst.html +++ /dev/null @@ -1,11 +0,0 @@ -{% load projects_tags %}{{ project.name|heading|safe }} - -{{ project.description|safe }} - -Contents: - -.. toctree:: - - {% for file in project.get_top_level_files|annotated_tree:1 %} - {{ file.denormalized_path }} - {% endfor %} From 3e8322151d11726aebeb52999f334ad91bdcf0ca Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Mon, 18 Mar 2019 23:12:07 +0530 Subject: [PATCH 2/4] remove django-textclassifier from requirements --- readthedocs/settings/base.py | 1 - requirements/pip.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index 6dfab8020c0..e8d129873f2 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -81,7 +81,6 @@ def INSTALLED_APPS(self): # noqa 'django_gravatar', 'rest_framework', 'corsheaders', - 'textclassifier', 'annoying', 'django_extensions', 'messages_extends', diff --git a/requirements/pip.txt b/requirements/pip.txt index a9a9e178763..fa63827c149 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -80,7 +80,6 @@ django-formtools==2.1 # https://github.com/rtfd/readthedocs.org/issues/3999 docker==3.1.3 # pyup: ignore -django-textclassifier==1.0 django-annoying==0.10.4 django-messages-extends==0.6.0 djangorestframework-jsonp==1.0.2 From 5c5f5c672fb8e9c7c78f35cf2ade0717ca553ae3 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Wed, 20 Mar 2019 21:50:09 +0530 Subject: [PATCH 3/4] make description field empty --- docs/api/v2.rst | 4 ++-- readthedocs/restapi/serializers.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/api/v2.rst b/docs/api/v2.rst index d11e2c28472..214b54841d8 100644 --- a/docs/api/v2.rst +++ b/docs/api/v2.rst @@ -93,7 +93,7 @@ Project details "default_branch": "master", "repo_type": "git", "repo": "https://github.com/pypa/pip", - "description": "Pip Installs Packages.", + "description": "", "language": "en", "documentation_type": "sphinx_htmldir", "canonical_url": "http://pip.pypa.io/en/stable/", @@ -109,7 +109,7 @@ Project details :>json string default_branch: The default version control branch :>json string repo_type: Version control repository of the project :>json string repo: The repository URL for the project - :>json string description: An RST description of the project + :>json string description: An empty string. This will be removed in future. :>json string language: The language code of this project :>json string documentation_type: An RST description of the project :>json string canonical_url: The canonical URL of the default docs diff --git a/readthedocs/restapi/serializers.py b/readthedocs/restapi/serializers.py index 0b9504ec74b..404a5757019 100644 --- a/readthedocs/restapi/serializers.py +++ b/readthedocs/restapi/serializers.py @@ -12,6 +12,15 @@ class ProjectSerializer(serializers.ModelSerializer): canonical_url = serializers.ReadOnlyField(source='get_docs_url') + description = serializers.SerializerMethodField() + + def get_description(self, obj): + """ + Forcing the description field to be an empty string. + + See https://github.com/rtfd/readthedocs.org/issues/3689. + """ + return '' class Meta: model = Project From 7a9776bc96248775ccafd956ab712afde8ee6a94 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Sun, 24 Mar 2019 14:24:42 +0530 Subject: [PATCH 4/4] remove redundant imports --- readthedocs/projects/forms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py index 09bce725548..7c5dd9275c0 100644 --- a/readthedocs/projects/forms.py +++ b/readthedocs/projects/forms.py @@ -19,7 +19,6 @@ from readthedocs.integrations.models import Integration from readthedocs.oauth.models import RemoteRepository from readthedocs.projects import constants -from readthedocs.projects.templatetags.projects_tags import sort_version_aware from readthedocs.projects.models import ( Domain, EmailHook,