Skip to content

Commit

Permalink
Project: merge basic and advanced forms (#11169)
Browse files Browse the repository at this point in the history
* Project: merge basic and advanced forms

Closes #11084

* Fix tests

* Remove banner and re-order the form fields

* Remove from navbar

* Lint

* Link to new page

* Update docs

* Fix tests on .com?

* Uppercase
  • Loading branch information
stsewd committed Feb 29, 2024
1 parent b9d9cf0 commit 1517e12
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 134 deletions.
4 changes: 2 additions & 2 deletions docs/user/analytics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Enabling Google Analytics on your project
Read the Docs has native support for Google Analytics.
You can enable it by:

* Going to :guilabel:`Admin` > :guilabel:`Advanced Settings` in your project.
* Going to :guilabel:`Admin` > :guilabel:`Settings` in your project.
* Fill in the **Analytics code** heading with your Google Tracking ID (example `UA-123456674-1`)

.. figure:: /_static/images/google-analytics-options.png
Expand Down Expand Up @@ -65,7 +65,7 @@ Disabling Google Analytics on your project
Google Analytics can be completely disabled on your own projects.
To disable Google Analytics:

* Going to :guilabel:`Admin` > :guilabel:`Advanced Settings` in your project.
* Going to :guilabel:`Admin` > :guilabel:`Settings` in your project.
* Check the box **Disable Analytics**.

Your documentation will need to be rebuilt for this change to take effect.
2 changes: 1 addition & 1 deletion docs/user/commercial/privacy-level.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ By default, only users that belong to your organization can see the dashboard of
If you want users outside your organization and anonymous users to be able to see the dashboard of your project,
and the build output of *public versions* you can set the privacy level of your project to ``Public``.

You can administer this in your :term:`dashboard` by navigating to :menuselection:`Admin --> Advanced Settings`
You can administer this in your :term:`dashboard` by navigating to :menuselection:`Admin --> Settings`
and changing :guilabel:`Privacy level` to `Public`.

.. note::
Expand Down
4 changes: 2 additions & 2 deletions docs/user/guides/build-troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ terminal prompts disabled
fatal: could not read Username for 'https://github.com': terminal prompts disabled
**Resolution:** This error can be quite misleading. It usually occurs when a repository could not be found because of a typo in the reposistory name or because the repository has been deleted. Verify your repository URL in :guilabel:`Admin > Advanced Settings`.
**Resolution:** This error can be quite misleading. It usually occurs when a repository could not be found because of a typo in the reposistory name or because the repository has been deleted. Verify your repository URL in :guilabel:`Admin > Settings`.

This error also occurs if you have changed a ``public`` repository to ``private`` and you are using ``https://`` in your git repository URL.

Expand All @@ -35,7 +35,7 @@ error: pathspec
error: pathspec 'main' did not match any file(s) known to git
**Resolution:** A specified branch does not exist in the git repository.
This might be because the git repository was recently created (and has no commits nor branches) or because the default branch has changed name. If for instance, the default branch on GitHub changed from ``master`` to ``main``, you need to visit :guilabel:`Admin > Advanced Settings` to change the name of the default branch that Read the Docs expects to find when cloning the repository.
This might be because the git repository was recently created (and has no commits nor branches) or because the default branch has changed name. If for instance, the default branch on GitHub changed from ``master`` to ``main``, you need to visit :guilabel:`Admin > Settings` to change the name of the default branch that Read the Docs expects to find when cloning the repository.


Permission denied (publickey)
Expand Down
4 changes: 2 additions & 2 deletions docs/user/guides/pull-requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ See `Limitations`_ for more information.
If your account is already connected:

#. Go to your project dashboard
#. Go to :guilabel:`Admin`, then :guilabel:`Advanced settings`
#. Go to :guilabel:`Admin`, then :guilabel:`Settings`
#. Enable the :guilabel:`Build pull requests for this project` option
#. Click on :guilabel:`Save`

Expand Down Expand Up @@ -43,7 +43,7 @@ while private previews are only available to users with access to the Read the D
To change the privacy level:

#. Go to your project dashboard
#. Go to :guilabel:`Admin`, then :guilabel:`Advanced settings`
#. Go to :guilabel:`Admin`, then :guilabel:`Settings`
#. Select your option in :guilabel:`Privacy level of builds from pull requests`
#. Click on :guilabel:`Save`

Expand Down
2 changes: 1 addition & 1 deletion docs/user/guides/setup/monorepo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Setting the custom build configuration file
-------------------------------------------

Once you have added a Git repository to a project that needs a custom configuration file path,
navigate to :menuselection:`Admin --> Advanced Settings` and add the path to the :guilabel:`Build configuration file` field.
navigate to :menuselection:`Admin --> Settings` and add the path to the :guilabel:`Build configuration file` field.

.. image:: /img/screenshot-howto-build-configuration-file.png
:alt: Screenshot of where to find the :guilabel:`Build configuration file` setting.
Expand Down
2 changes: 1 addition & 1 deletion docs/user/guides/setup/versioning-schemes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Changing the versioning scheme
------------------------------

#. Go the :guilabel:`Admin` tab of your project.
#. Click on :guilabel:`Advanced Settings`.
#. Click on :guilabel:`Settings`.
#. Select the new versioning scheme in the :guilabel:`Versioning scheme` dropdown.
#. Click on :guilabel:`Save`.
6 changes: 3 additions & 3 deletions docs/user/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Trigger a build from a pull request
Read the Docs allows you to :doc:`trigger builds from GitHub pull requests </pull-requests>`
and gives you a preview of how the documentation would look like with those changes.

To enable that functionality, first click on the :guilabel:`Advanced Settings` link on the left
To enable that functionality, first click on the :guilabel:`Settings` link on the left
under the :guilabel:`⚙ Admin` menu, check the "Build pull requests for this project" checkbox,
and click the :guilabel:`Save` button at the bottom of the page.

Expand Down Expand Up @@ -520,7 +520,7 @@ so that users see the ``stable`` documentation
when they visit the :term:`root URL` of your documentation
(while still being able to change the version in the flyout menu).

For that, go to the :guilabel:`Advanced Settings` link
For that, go to the :guilabel:`Settings` link
under the :guilabel:`⚙ Admin` menu of your project home,
choose ``stable`` in the "Default version*" dropdown,
and hit :guilabel:`Save` at the bottom.
Expand Down Expand Up @@ -579,7 +579,7 @@ and a new build will be triggered for it.
From this point, ``1.0.x`` version is no longer the most up to date one.
To display a warning to your readers, go to the :guilabel:`⚙ Admin` menu of your project home,
click on the :guilabel:`Advanced Settings` link on the left,
click on the :guilabel:`Settings` link on the left,
enable the "Show version warning" checkbox, and click the :guilabel:`Save` button.
If you now browse the ``1.0.x`` documentation, you will see a warning on top
Expand Down
2 changes: 1 addition & 1 deletion docs/user/versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ a more stable version of the documentation available. Specifically:


This feature is enabled by default on projects using the new beta addons.
The beta addons can be enabled by using ``build.commands`` config key or via the new beta dashboard (https://beta.readthedocs.org) going to the admin section of your docs (:guilabel:`Admin` > :guilabel:`Advanced Settings`)
The beta addons can be enabled by using ``build.commands`` config key or via the new beta dashboard (https://beta.readthedocs.org) going to the admin section of your docs (:guilabel:`Admin` > :guilabel:`Settings`)

.. note::

Expand Down
2 changes: 2 additions & 0 deletions readthedocs/core/tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def test_extra_historical_fields_with_request(self):
"name": "Changed!",
"repo": "https://github.com/readthedocs/readthedocs",
"repo_type": self.project.repo_type,
"default_version": self.project.default_version,
"language": self.project.language,
"versioning_scheme": self.project.versioning_scheme,
},
headers={"user-agent": "Firefox"},
)
Expand Down
103 changes: 38 additions & 65 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def clean_prevalidation(self):

class ProjectBasicsForm(ProjectForm):

"""Form for basic project fields."""
"""Form used when importing a project."""

class Meta:
model = Project
Expand Down Expand Up @@ -264,39 +264,6 @@ def placehold_repo(self):
)


class ProjectExtraForm(ProjectForm):

"""Additional project information form."""

class Meta:
model = Project
fields = (
"description",
"documentation_type",
"language",
"programming_language",
"tags",
"project_url",
)

description = forms.CharField(
required=False,
max_length=150,
widget=forms.Textarea,
)

def clean_tags(self):
tags = self.cleaned_data.get("tags", [])
for tag in tags:
if len(tag) > 100:
raise forms.ValidationError(
_(
"Length of each tag must be less than or equal to 100 characters.",
),
)
return tags


class ProjectConfigForm(forms.Form):

"""Simple intermediate step to communicate about the .readthedocs.yaml file."""
Expand All @@ -307,28 +274,47 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)


class ProjectAdvancedForm(ProjectTriggerBuildMixin, ProjectForm):
class UpdateProjectForm(
ProjectTriggerBuildMixin,
ProjectBasicsForm,
):

"""Advanced project option form."""
"""Main project settings form."""

class Meta:
model = Project
fields = (
"default_version",
# Basics and repo settings
"name",
"repo",
"repo_type",
"default_branch",
"language",
"description",
# Project related settings
"default_version",
"privacy_level",
"analytics_code",
"analytics_disabled",
"show_version_warning",
"versioning_scheme",
"external_builds_enabled",
"external_builds_privacy_level",
"readthedocs_yaml_path",
"analytics_code",
"analytics_disabled",
"show_version_warning",
# Meta data
"programming_language",
"project_url",
"tags",
)

description = forms.CharField(
required=False,
max_length=150,
widget=forms.Textarea,
)

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

# Remove the nullable option from the form
self.fields["analytics_disabled"].widget = forms.CheckboxInput()
self.fields["analytics_disabled"].empty_value = False
Expand Down Expand Up @@ -491,30 +477,6 @@ def get_all_active_versions(self):
return all_versions
return None


class UpdateProjectForm(
ProjectTriggerBuildMixin,
ProjectBasicsForm,
ProjectExtraForm,
):

"""Basic project settings form for Admin."""

class Meta: # noqa
model = Project
fields = (
# Basics
"name",
"repo",
"repo_type",
# Extra
"description",
"language",
"programming_language",
"project_url",
"tags",
)

def clean_language(self):
"""Ensure that language isn't already active."""
language = self.cleaned_data["language"]
Expand Down Expand Up @@ -544,6 +506,17 @@ def clean_language(self):
)
return language

def clean_tags(self):
tags = self.cleaned_data.get("tags", [])
for tag in tags:
if len(tag) > 100:
raise forms.ValidationError(
_(
"Length of each tag must be less than or equal to 100 characters.",
),
)
return tags


class ProjectRelationshipForm(forms.ModelForm):

Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setUp(self):
integration_type=Integration.GITHUB_WEBHOOK,
project=self.project,
)
self.url = reverse("projects_advanced", args=[self.project.slug])
self.url = reverse("projects_edit", args=[self.project.slug])
self.client.force_login(self.user)

def test_unsuported_integration(self):
Expand Down
5 changes: 3 additions & 2 deletions readthedocs/projects/urls/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
IntegrationExchangeDetail,
IntegrationList,
IntegrationWebhookSync,
ProjectAdvancedUpdate,
ProjectAdvertisingUpdate,
ProjectDashboard,
ProjectDelete,
Expand Down Expand Up @@ -84,7 +83,9 @@
),
re_path(
r"^(?P<project_slug>[-\w]+)/advanced/$",
ProjectAdvancedUpdate.as_view(),
login_required(
RedirectView.as_view(pattern_name="projects_edit", permanent=True),
),
name="projects_advanced",
),
re_path(
Expand Down
10 changes: 0 additions & 10 deletions readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
EmailHookForm,
EnvironmentVariableForm,
IntegrationForm,
ProjectAdvancedForm,
ProjectAdvertisingForm,
ProjectAutomaticForm,
ProjectBasicsForm,
Expand Down Expand Up @@ -169,15 +168,6 @@ def get_success_url(self):
return reverse("projects_detail", args=[self.object.slug])


class ProjectAdvancedUpdate(ProjectMixin, UpdateView):
form_class = ProjectAdvancedForm
success_message = _("Project settings updated")
template_name = "projects/project_advanced.html"

def get_success_url(self):
return reverse("projects_detail", args=[self.object.slug])


class AddonsConfigUpdate(ProjectAdminMixin, PrivateViewMixin, CreateView, UpdateView):
form_class = AddonsConfigForm
success_message = _("Project addons updated")
Expand Down
3 changes: 3 additions & 0 deletions readthedocs/rtd_tests/tests/test_privacy_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class PublicProjectMixin(ProjectMixin):
"/projects/pip/badge/": {"status_code": 200},
"/projects/invalid_slug/": {"status_code": 302},
"/projects/pip/search/": {"status_code": 302},
"/dashboard/pip/advanced/": {"status_code": 301},
}

def test_public_urls(self):
Expand Down Expand Up @@ -303,6 +304,7 @@ class PrivateProjectAdminAccessTest(PrivateProjectMixin, TestCase):
"/dashboard/import/manual/demo/": {"status_code": 302},
"/dashboard/pip/": {"status_code": 301},
"/dashboard/pip/subprojects/delete/sub/": {"status_code": 302},
"/dashboard/pip/advanced/": {"status_code": 301},
# 405's where we should be POST'ing
"/dashboard/pip/users/delete/": {"status_code": 405},
"/dashboard/pip/notifications/delete/": {"status_code": 405},
Expand Down Expand Up @@ -350,6 +352,7 @@ class PrivateProjectUserAccessTest(PrivateProjectMixin, TestCase):
"/dashboard/import/": {"status_code": 200},
"/dashboard/import/manual/": {"status_code": 200},
"/dashboard/import/manual/demo/": {"status_code": 302},
"/dashboard/pip/advanced/": {"status_code": 301},
# Unauth access redirect for non-owners
"/dashboard/pip/": {"status_code": 301},
# 405's where we should be POST'ing
Expand Down

0 comments on commit 1517e12

Please sign in to comment.