Coverage for src/ptf_tools/views/archive.py: 23%
22 statements
« prev ^ index » next coverage.py v7.9.0, created at 2026-02-03 09:11 +0000
« prev ^ index » next coverage.py v7.9.0, created at 2026-02-03 09:11 +0000
1from django.conf import settings
2from django.http import Http404
3from django.urls import reverse
4from django.views.generic import RedirectView
6from ptf_tools.tasks import archive_trammel_collection, archive_trammel_collections
9class TrammelArchiveView(RedirectView):
10 def get_redirect_url(self, *args, **kwargs):
11 self.colid = kwargs["colid"]
12 self.mathdoc_archive = settings.MATHDOC_ARCHIVE_FOLDER
13 self.binary_files_folder = settings.MERSENNE_PROD_DATA_FOLDER
14 # Make sure archiving is not already running
16 if "progress/" in self.colid:
17 self.colid = self.colid.replace("progress/", "")
18 if "/progress" in self.colid:
19 self.colid = self.colid.replace("/progress", "")
21 if self.colid == "ALL":
22 colids = settings.MERSENNE_COLLECTIONS
23 archive_trammel_collections.delay(
24 colids,
25 mathdoc_archive=self.mathdoc_archive,
26 binary_files_folder=self.binary_files_folder,
27 )
28 return reverse("home")
29 else:
30 if self.colid not in settings.MERSENNE_COLLECTIONS:
31 raise Http404
32 archive_trammel_collection.s(
33 self.colid,
34 mathdoc_archive=self.mathdoc_archive,
35 binary_files_folder=self.binary_files_folder,
36 ).delay()
37 return reverse("collection-detail", kwargs={"pid": self.colid})