diff --git a/readthedocs/projects/migrations/0127_default_to_semver.py b/readthedocs/projects/migrations/0127_default_to_semver.py new file mode 100644 index 00000000000..36a8b6a9595 --- /dev/null +++ b/readthedocs/projects/migrations/0127_default_to_semver.py @@ -0,0 +1,85 @@ +# Generated by Django 4.2.16 on 2024-10-15 16:07 +from django.db import migrations, models +from django_safemigrate import Safe + + +class Migration(migrations.Migration): + safe = Safe.always + dependencies = [ + ("projects", "0126_alter_remote_repository_description"), + ] + + operations = [ + migrations.AlterField( + model_name="addonsconfig", + name="flyout_sorting", + field=models.CharField( + choices=[ + ("alphabetically", "Alphabetically"), + ("semver-readthedocs-compatible", "SemVer (Read the Docs)"), + ("python-packaging", "Python Packaging (PEP 440 and PEP 425)"), + ("calver", "CalVer (YYYY.0M.0M)"), + ("custom-pattern", "Define your own pattern"), + ], + default="semver-readthedocs-compatible", + max_length=64, + verbose_name="Sorting of versions", + ), + ), + migrations.AlterField( + model_name="addonsconfig", + name="flyout_sorting_custom_pattern", + field=models.CharField( + blank=True, + default=None, + help_text='Sorting pattern supported by BumpVer (See examples)', + max_length=32, + null=True, + verbose_name="Custom version sorting pattern", + ), + ), + migrations.AlterField( + model_name="addonsconfig", + name="flyout_sorting_latest_stable_at_beginning", + field=models.BooleanField( + default=True, + verbose_name="Show latest and stable at the beginning", + ), + ), + migrations.AlterField( + model_name="historicaladdonsconfig", + name="flyout_sorting", + field=models.CharField( + choices=[ + ("alphabetically", "Alphabetically"), + ("semver-readthedocs-compatible", "SemVer (Read the Docs)"), + ("python-packaging", "Python Packaging (PEP 440 and PEP 425)"), + ("calver", "CalVer (YYYY.0M.0M)"), + ("custom-pattern", "Define your own pattern"), + ], + default="semver-readthedocs-compatible", + max_length=64, + verbose_name="Sorting of versions", + ), + ), + migrations.AlterField( + model_name="historicaladdonsconfig", + name="flyout_sorting_custom_pattern", + field=models.CharField( + blank=True, + default=None, + help_text='Sorting pattern supported by BumpVer (See examples)', + max_length=32, + null=True, + verbose_name="Custom version sorting pattern", + ), + ), + migrations.AlterField( + model_name="historicaladdonsconfig", + name="flyout_sorting_latest_stable_at_beginning", + field=models.BooleanField( + default=True, + verbose_name="Show latest and stable at the beginning", + ), + ), + ] diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index e0fc30ec291..fbb74fa6342 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -62,8 +62,8 @@ from readthedocs.vcs_support.backends import backend_cls from .constants import ( - ADDONS_FLYOUT_SORTING_ALPHABETICALLY, ADDONS_FLYOUT_SORTING_CHOICES, + ADDONS_FLYOUT_SORTING_SEMVER_READTHEDOCS_COMPATIBLE, DOWNLOADABLE_MEDIA_TYPES, MEDIA_TYPES, MULTIPLE_VERSIONS_WITH_TRANSLATIONS, @@ -187,8 +187,9 @@ class AddonsConfig(TimeStampedModel): # Flyout flyout_enabled = models.BooleanField(default=True) flyout_sorting = models.CharField( + verbose_name=_("Sorting of versions"), choices=ADDONS_FLYOUT_SORTING_CHOICES, - default=ADDONS_FLYOUT_SORTING_ALPHABETICALLY, + default=ADDONS_FLYOUT_SORTING_SEMVER_READTHEDOCS_COMPATIBLE, max_length=64, ) flyout_sorting_custom_pattern = models.CharField( @@ -196,12 +197,15 @@ class AddonsConfig(TimeStampedModel): default=None, null=True, blank=True, + verbose_name=_("Custom version sorting pattern"), help_text="Sorting pattern supported by BumpVer " '(See examples)', ) flyout_sorting_latest_stable_at_beginning = models.BooleanField( + verbose_name=_( + "Show latest and stable at the beginning" + ), default=True, - help_text="Show latest and stable at the beginning", ) # Hotkeys diff --git a/readthedocs/proxito/tests/test_hosting.py b/readthedocs/proxito/tests/test_hosting.py index bcda4a0383f..2ec44656332 100644 --- a/readthedocs/proxito/tests/test_hosting.py +++ b/readthedocs/proxito/tests/test_hosting.py @@ -575,15 +575,15 @@ def test_flyout_subproject_urls(self): r.json()["versions"]["active"][0]["urls"]["documentation"] == "https://project.dev.readthedocs.io/projects/subproject/en/latest/" ) - assert r.json()["versions"]["active"][1]["slug"] == "v1" + assert r.json()["versions"]["active"][1]["slug"] == "v2.3" assert ( r.json()["versions"]["active"][1]["urls"]["documentation"] - == "https://project.dev.readthedocs.io/projects/subproject/en/v1/" + == "https://project.dev.readthedocs.io/projects/subproject/en/v2.3/" ) - assert r.json()["versions"]["active"][2]["slug"] == "v2.3" + assert r.json()["versions"]["active"][2]["slug"] == "v1" assert ( r.json()["versions"]["active"][2]["urls"]["documentation"] - == "https://project.dev.readthedocs.io/projects/subproject/en/v2.3/" + == "https://project.dev.readthedocs.io/projects/subproject/en/v1/" ) assert len(r.json()["projects"]["translations"]) == 1 diff --git a/readthedocs/proxito/views/hosting.py b/readthedocs/proxito/views/hosting.py index 564ee05f928..06abc2bacb6 100644 --- a/readthedocs/proxito/views/hosting.py +++ b/readthedocs/proxito/views/hosting.py @@ -350,6 +350,7 @@ def _v1(self, project, version, build, filename, url, request): version.verbose_name, repo_type=project.repo_type, ), + reverse=True, ) elif ( project.addons.flyout_sorting == ADDONS_FLYOUT_SORTING_PYTHON_PACKAGING