mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +00:00
For a cave, force users to enter are and have a unique URL. Cope better if area not defined
This commit is contained in:
parent
0a3a6934c4
commit
31a60ce85c
@ -81,7 +81,7 @@ class CaveAndEntrance(models.Model):
|
|||||||
|
|
||||||
class Cave(TroggleModel):
|
class Cave(TroggleModel):
|
||||||
# too much here perhaps,
|
# too much here perhaps,
|
||||||
area = models.ManyToManyField(Area, blank=True)
|
area = models.ManyToManyField(Area, blank=False)
|
||||||
depth = models.CharField(max_length=100, blank=True, null=True)
|
depth = models.CharField(max_length=100, blank=True, null=True)
|
||||||
description_file = models.CharField(max_length=200, blank=True, null=True)
|
description_file = models.CharField(max_length=200, blank=True, null=True)
|
||||||
entrances = models.ManyToManyField("Entrance", through="CaveAndEntrance")
|
entrances = models.ManyToManyField("Entrance", through="CaveAndEntrance")
|
||||||
@ -101,7 +101,7 @@ class Cave(TroggleModel):
|
|||||||
underground_centre_line = models.TextField(blank=True, null=True)
|
underground_centre_line = models.TextField(blank=True, null=True)
|
||||||
underground_description = models.TextField(blank=True, null=True)
|
underground_description = models.TextField(blank=True, null=True)
|
||||||
unofficial_number = models.CharField(max_length=60, blank=True, null=True)
|
unofficial_number = models.CharField(max_length=60, blank=True, null=True)
|
||||||
url = models.CharField(max_length=200, blank=True, null=True)
|
url = models.CharField(max_length=200, blank=True, null=True, unique = True)
|
||||||
|
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# unique_together = (("area", "kataster_number"), ("area", "unofficial_number"))
|
# unique_together = (("area", "kataster_number"), ("area", "unofficial_number"))
|
||||||
@ -188,9 +188,12 @@ class Cave(TroggleModel):
|
|||||||
return qms # a QuerySet
|
return qms # a QuerySet
|
||||||
|
|
||||||
def kat_area(self):
|
def kat_area(self):
|
||||||
for a in self.area.all():
|
try:
|
||||||
if a.kat_area():
|
for a in self.area.all():
|
||||||
return a.kat_area()
|
if a.kat_area():
|
||||||
|
return a.kat_area()
|
||||||
|
except:
|
||||||
|
return ""
|
||||||
|
|
||||||
def entrances(self):
|
def entrances(self):
|
||||||
return CaveAndEntrance.objects.filter(cave=self)
|
return CaveAndEntrance.objects.filter(cave=self)
|
||||||
|
Loading…
Reference in New Issue
Block a user