Skip to content

Commit

Permalink
Admin: remove "default settings" (#11036)
Browse files Browse the repository at this point in the history
* Admin: remove "default settings"

These settings have been disabled for 6 months already.
They are useless now that we _require_ a `readthedocs.yaml` file.

Closes readthedocs/ext-theme#159

* Update readthedocs/templates/projects/project_advanced.html

Co-authored-by: Anthony <aj@ohess.org>

---------

Co-authored-by: Anthony <aj@ohess.org>
  • Loading branch information
humitos and agjohnson authored Jan 17, 2024
1 parent ae7956e commit 4a759ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 61 deletions.
52 changes: 1 addition & 51 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
from re import fullmatch
from urllib.parse import urlparse

from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Fieldset, Layout, Submit
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.db.models import Q
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -202,7 +199,7 @@ class ProjectAdvancedForm(ProjectTriggerBuildMixin, ProjectForm):

class Meta:
model = Project
per_project_settings = (
fields = (
"default_version",
"default_branch",
"privacy_level",
Expand All @@ -214,20 +211,6 @@ class Meta:
"external_builds_privacy_level",
"readthedocs_yaml_path",
)
# These that can be set per-version using a config file.
per_version_settings = (
"documentation_type",
"requirements_file",
"python_interpreter",
"install_project",
"conf_py_file",
"enable_pdf_build",
"enable_epub_build",
)
fields = (
*per_project_settings,
*per_version_settings,
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -253,43 +236,15 @@ def __init__(self, *args, **kwargs):
)
self.fields["versioning_scheme"].disabled = True

self.helper = FormHelper()
help_text = render_to_string(
'projects/project_advanced_settings_helptext.html'
)

per_project_settings = list(self.Meta.per_project_settings)

# NOTE: we are deprecating this feature.
# However, we will keep it available for projects that already using it.
# Old projects not using it already or new projects won't be able to enable.
if not self.instance.has_feature(Feature.ALLOW_VERSION_WARNING_BANNER):
self.fields.pop("show_version_warning")
per_project_settings.remove("show_version_warning")

if not settings.ALLOW_PRIVATE_REPOS:
for field in ['privacy_level', 'external_builds_privacy_level']:
self.fields.pop(field)
per_project_settings.remove(field)

# TODO: remove the "Global settings" fieldset since we only have one
# fieldset not. Also, considering merging this "Advanced settings" with
# the regular "Settings" tab. Also also, take into account that we may
# want to add a new tab for "Read the Docs Addons" to configure each of
# them from there.
field_sets = [
Fieldset(
_("Global settings"),
*per_project_settings,
),
Fieldset(
_("Default settings"),
HTML(help_text),
*self.Meta.per_version_settings,
),
]
self.helper.layout = Layout(*field_sets)
self.helper.add_input(Submit('save', _('Save')))

default_choice = (None, '-' * 9)
versions_choices = self.instance.versions(manager=INTERNAL).filter(
Expand All @@ -310,11 +265,6 @@ def __init__(self, *args, **kwargs):
else:
self.fields['default_version'].widget.attrs['readonly'] = True

# Disable "per_version_settings" because they are deprecated.
# This fieldset will be removed in the next few weeks, after giving users some time to perform the migration.
for field in self.Meta.per_version_settings:
self.fields[field].disabled = True

self.setup_external_builds_option()

def setup_external_builds_option(self):
Expand Down
5 changes: 4 additions & 1 deletion readthedocs/templates/projects/project_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
{% block project_edit_content_header %}{% trans "Advanced Settings" %}{% endblock %}

{% block project_edit_content %}
{% crispy form %}
<form method="post" action=".">{% csrf_token %}
{{ form|crispy }}
<input type="submit" value="{% trans "Save" %}">
</form>
{% endblock %}

This file was deleted.

0 comments on commit 4a759ee

Please sign in to comment.