Skip to content

Commit 15c9baa

Browse files
authored
Remove dead code from old footer (#11854)
Ref #11836
1 parent e9316be commit 15c9baa

File tree

6 files changed

+0
-394
lines changed

6 files changed

+0
-394
lines changed

readthedocs/builds/models.py

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,11 @@
6161
from readthedocs.notifications.models import Notification
6262
from readthedocs.projects.constants import (
6363
BITBUCKET_COMMIT_URL,
64-
BITBUCKET_URL,
6564
DOCTYPE_CHOICES,
6665
GITHUB_COMMIT_URL,
6766
GITHUB_PULL_REQUEST_COMMIT_URL,
68-
GITHUB_URL,
6967
GITLAB_COMMIT_URL,
7068
GITLAB_MERGE_REQUEST_COMMIT_URL,
71-
GITLAB_URL,
7269
MEDIA_TYPES,
7370
MKDOCS,
7471
MKDOCS_HTML,
@@ -550,121 +547,6 @@ def get_storage_paths(self):
550547

551548
return paths
552549

553-
def get_github_url(
554-
self,
555-
docroot,
556-
filename,
557-
source_suffix=".rst",
558-
action="view",
559-
):
560-
"""
561-
Return a GitHub URL for a given filename.
562-
563-
:param docroot: Location of documentation in repository
564-
:param filename: Name of file
565-
:param source_suffix: File suffix of documentation format
566-
:param action: `view` (default) or `edit`
567-
"""
568-
repo_url = self.project.repo
569-
if "github" not in repo_url:
570-
return ""
571-
572-
if not docroot:
573-
return ""
574-
575-
# Normalize /docroot/
576-
docroot = "/" + docroot.strip("/") + "/"
577-
578-
if action == "view":
579-
action_string = "blob"
580-
elif action == "edit":
581-
action_string = "edit"
582-
583-
user, repo = get_github_username_repo(repo_url)
584-
if not user and not repo:
585-
return ""
586-
587-
if not filename:
588-
# If there isn't a filename, we don't need a suffix
589-
source_suffix = ""
590-
591-
return GITHUB_URL.format(
592-
user=user,
593-
repo=repo,
594-
version=self.commit_name,
595-
docroot=docroot,
596-
path=filename,
597-
source_suffix=source_suffix,
598-
action=action_string,
599-
)
600-
601-
def get_gitlab_url(
602-
self,
603-
docroot,
604-
filename,
605-
source_suffix=".rst",
606-
action="view",
607-
):
608-
repo_url = self.project.repo
609-
if "gitlab" not in repo_url:
610-
return ""
611-
612-
if not docroot:
613-
return ""
614-
615-
# Normalize /docroot/
616-
docroot = "/" + docroot.strip("/") + "/"
617-
618-
if action == "view":
619-
action_string = "blob"
620-
elif action == "edit":
621-
action_string = "edit"
622-
623-
user, repo = get_gitlab_username_repo(repo_url)
624-
if not user and not repo:
625-
return ""
626-
627-
if not filename:
628-
# If there isn't a filename, we don't need a suffix
629-
source_suffix = ""
630-
631-
return GITLAB_URL.format(
632-
user=user,
633-
repo=repo,
634-
version=self.commit_name,
635-
docroot=docroot,
636-
path=filename,
637-
source_suffix=source_suffix,
638-
action=action_string,
639-
)
640-
641-
def get_bitbucket_url(self, docroot, filename, source_suffix=".rst"):
642-
repo_url = self.project.repo
643-
if "bitbucket" not in repo_url:
644-
return ""
645-
if not docroot:
646-
return ""
647-
648-
# Normalize /docroot/
649-
docroot = "/" + docroot.strip("/") + "/"
650-
651-
user, repo = get_bitbucket_username_repo(repo_url)
652-
if not user and not repo:
653-
return ""
654-
655-
if not filename:
656-
# If there isn't a filename, we don't need a suffix
657-
source_suffix = ""
658-
659-
return BITBUCKET_URL.format(
660-
user=user,
661-
repo=repo,
662-
version=self.commit_name,
663-
docroot=docroot,
664-
path=filename,
665-
source_suffix=source_suffix,
666-
)
667-
668550

669551
class APIVersion(Version):
670552

readthedocs/projects/constants.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,23 +371,12 @@
371371
re.compile(r"gitlab.com/(.+)/(.+)"),
372372
re.compile(r"gitlab.com:(.+)/(.+)\.git$"),
373373
]
374-
GITHUB_URL = (
375-
"https://github.com/{user}/{repo}/"
376-
"{action}/{version}{docroot}{path}{source_suffix}"
377-
)
378374
GITHUB_COMMIT_URL = "https://github.com/{user}/{repo}/commit/{commit}"
379375
GITHUB_PULL_REQUEST_URL = "https://github.com/{user}/{repo}/pull/{number}"
380376
GITHUB_PULL_REQUEST_COMMIT_URL = (
381377
"https://github.com/{user}/{repo}/pull/{number}/commits/{commit}"
382378
)
383-
BITBUCKET_URL = (
384-
"https://bitbucket.org/{user}/{repo}/src/{version}{docroot}{path}{source_suffix}"
385-
)
386379
BITBUCKET_COMMIT_URL = "https://bitbucket.org/{user}/{repo}/commits/{commit}"
387-
GITLAB_URL = (
388-
"https://gitlab.com/{user}/{repo}/"
389-
"{action}/{version}{docroot}{path}{source_suffix}"
390-
)
391380
GITLAB_COMMIT_URL = "https://gitlab.com/{user}/{repo}/commit/{commit}"
392381
GITLAB_MERGE_REQUEST_COMMIT_URL = (
393382
"https://gitlab.com/{user}/{repo}/commit/{commit}?merge_request_iid={number}"

readthedocs/projects/models.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from django.contrib.contenttypes.fields import GenericRelation
1414
from django.core.validators import MaxValueValidator, MinValueValidator
1515
from django.db import models
16-
from django.db.models import Prefetch
1716
from django.urls import reverse
1817
from django.utils import timezone
1918
from django.utils.crypto import get_random_string
@@ -47,7 +46,6 @@
4746
ProjectQuerySet,
4847
RelatedProjectQuerySet,
4948
)
50-
from readthedocs.projects.templatetags.projects_tags import sort_version_aware
5149
from readthedocs.projects.validators import (
5250
validate_build_config_file,
5351
validate_custom_prefix,
@@ -1079,43 +1077,6 @@ def active_versions(self):
10791077
active=True, uploaded=True
10801078
)
10811079

1082-
def ordered_active_versions(self, **kwargs):
1083-
"""
1084-
Get all active versions, sorted.
1085-
1086-
:param kwargs: All kwargs are passed down to the
1087-
`Version.internal.public` queryset.
1088-
"""
1089-
from readthedocs.builds.models import Version
1090-
1091-
kwargs.update(
1092-
{
1093-
"project": self,
1094-
"only_active": True,
1095-
"only_built": True,
1096-
},
1097-
)
1098-
versions = (
1099-
Version.internal.public(**kwargs)
1100-
.select_related(
1101-
"project",
1102-
"project__main_language_project",
1103-
)
1104-
.prefetch_related(
1105-
Prefetch(
1106-
"project__superprojects",
1107-
ProjectRelationship.objects.all().select_related("parent"),
1108-
to_attr="_superprojects",
1109-
),
1110-
Prefetch(
1111-
"project__domains",
1112-
Domain.objects.filter(canonical=True),
1113-
to_attr="_canonical_domains",
1114-
),
1115-
)
1116-
)
1117-
return sort_version_aware(versions)
1118-
11191080
def all_active_versions(self):
11201081
"""
11211082
Get queryset with all active versions.

readthedocs/projects/version_handling.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,6 @@ def sort_versions(version_list):
126126
return versions
127127

128128

129-
def highest_version(version_list):
130-
"""
131-
Return the highest version for a given ``version_list``.
132-
133-
:rtype: tupe(readthedocs.builds.models.Version, packaging.version.Version)
134-
"""
135-
versions = sort_versions(version_list)
136-
if versions:
137-
return versions[0]
138-
return (None, None)
139-
140-
141129
def determine_stable_version(version_list):
142130
"""
143131
Determine a stable version for version list.

readthedocs/rtd_tests/tests/test_project.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ def test_get_storage_path_for_external_versions(self):
168168
"external/htmlzip/pip/99/pip.zip",
169169
)
170170

171-
def test_ordered_active_versions_excludes_external_versions(self):
172-
self.assertNotIn(self.external_version, self.pip.ordered_active_versions())
173-
174171
def test_active_versions_excludes_external_versions(self):
175172
self.assertNotIn(self.external_version, self.pip.active_versions())
176173

0 commit comments

Comments
 (0)