2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 00:31:55 +00:00

removed fossil URL_ROOT from active code

This commit is contained in:
Philip Sargent 2023-10-01 12:21:34 +03:00
parent c80db1a55f
commit fd94909ee7
6 changed files with 19 additions and 17 deletions

View File

@ -118,13 +118,14 @@ class Cave(TroggleModel):
# return f"{self.areacode}-{self.number()}"
def get_absolute_url(self):
# we do not use URL_ROOT any more.
if self.kataster_number:
pass
elif self.unofficial_number:
pass
else:
self.official_name.lower()
return Path(settings.URL_ROOT) / self.url # not good Django style? NEEDS actual URL
return self.url # not good Django style? NEEDS actual URL
def url_parent(self):
if self.url:

View File

@ -70,7 +70,8 @@ class LogbookEntry(TroggleModel):
return True
def get_absolute_url(self):
return urljoin(settings.URL_ROOT, reverse("logbookentry", kwargs={"date": self.date, "slug": self.slug}))
# we do not use URL_ROOT any more.
return reverse("logbookentry", kwargs={"date": self.date, "slug": self.slug})
def __str__(self):
return f"{self.date}: {self.title}"

View File

@ -223,10 +223,8 @@ class SingleScan(models.Model):
ordering = ("name",)
def get_absolute_url(self):
return urljoin(
settings.URL_ROOT,
reverse("scansingle", kwargs={"path": re.sub("#", "%23", self.wallet.walletname), "file": self.name}),
)
# we do not use URL_ROOT any more.
return reverse("scansingle", kwargs={"path": re.sub("#", "%23", self.wallet.walletname), "file": self.name})
def __str__(self):
return "Scan Image: " + str(self.name) + " in " + str(self.wallet)

View File

@ -25,7 +25,8 @@ class TroggleModel(models.Model):
return self._meta.object_name
def get_admin_url(self):
return urljoin(settings.URL_ROOT, "/admin/core/" + self.object_name().lower() + "/" + str(self.pk))
# we do not use URL_ROOT any more.
return urljoin("/admin/core/" + self.object_name().lower() + "/" + str(self.pk))
class Meta:
abstract = True
@ -71,7 +72,8 @@ class Expedition(TroggleModel):
get_latest_by = "year"
def get_absolute_url(self):
return urljoin(settings.URL_ROOT, reverse("expedition", args=[self.year]))
# we do not use URL_ROOT any more.
return reverse("expedition", args=[self.year])
class Person(TroggleModel):
"""single Person, can go on many years"""
@ -89,9 +91,8 @@ class Person(TroggleModel):
orderref = models.CharField(max_length=200) # for alphabetic
def get_absolute_url(self):
return urljoin(
settings.URL_ROOT, reverse("person", kwargs={"first_name": self.first_name, "last_name": self.last_name})
)
# we do not use URL_ROOT any more.
return reverse("person", kwargs={"first_name": self.first_name, "last_name": self.last_name})
class Meta:
verbose_name_plural = "People"
@ -158,16 +159,14 @@ class PersonExpedition(TroggleModel):
def get_absolute_url(self):
return urljoin(
settings.URL_ROOT,
reverse(
# we do not use URL_ROOT any more.
return reverse(
"personexpedition",
kwargs={
"first_name": self.person.first_name,
"last_name": self.person.last_name,
"year": self.expedition.year,
},
),
)
def surveyedleglength(self):

View File

@ -84,7 +84,8 @@ class Wallet(models.Model):
ordering = ("walletname",)
def get_absolute_url(self):
return urljoin(settings.URL_ROOT, reverse("singlewallet", kwargs={"path": re.sub("#", "%23", self.walletname)}))
# we do not use URL_ROOT any more.
return reverse("singlewallet", kwargs={"path": re.sub("#", "%23", self.walletname)})
def get_json(self):
"""Read the JSON file for the wallet and do stuff

View File

@ -187,6 +187,8 @@ def person(
first_name="",
last_name="",
):
"""Original code as it has been for years. Trying to replace with better_person()
"""
try:
this_person = Person.objects.get(first_name=first_name, last_name=last_name)
except: