mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 07:06:18 +00:00
primary key now UUID on SurvexBlock
This commit is contained in:
@@ -260,7 +260,15 @@ class QM(TroggleModel):
|
||||
)
|
||||
grade = models.CharField(max_length=1, blank=True, null=True, help_text="A/B/C/D/X")
|
||||
cave = models.ForeignKey("Cave", related_name="QMs", blank=True, null=True, on_delete=models.SET_NULL)
|
||||
block = models.ForeignKey("SurvexBlock", null=True, on_delete=models.SET_NULL) # only for QMs from survex files
|
||||
|
||||
# only for QMs from survex files
|
||||
block = models.ForeignKey(
|
||||
"SurvexBlock",
|
||||
to_field="_blockid", # Explicitly point to the UUID field
|
||||
null=True,
|
||||
on_delete=models.SET_NULL
|
||||
)
|
||||
# block = models.ForeignKey("SurvexBlock", null=True, on_delete=models.SET_NULL)
|
||||
blockname = models.TextField(blank=True, null=True) # NB truncated copy of survexblock name with last char added
|
||||
expoyear = models.CharField(max_length=4, blank=True, null=True)
|
||||
ticked = models.BooleanField(default=False)
|
||||
|
||||
@@ -15,7 +15,6 @@ from troggle.core.utils import height_from_utm, throw
|
||||
|
||||
class SurvexFile(models.Model):
|
||||
path = models.CharField(max_length=200)
|
||||
#survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True, on_delete=models.SET_NULL)
|
||||
primary = models.ForeignKey(
|
||||
"SurvexFile", related_name="primarysurvex", blank=True, null=True, on_delete=models.SET_NULL
|
||||
)
|
||||
@@ -222,7 +221,8 @@ class SurvexBlock(models.Model):
|
||||
# This ID is generated as soon as you call SurvexBlock((). So we can use it while assembling the data
|
||||
# into the survexblock without having to keep doing a database transaction
|
||||
_blockid = models.UUIDField(
|
||||
primary_key=False,
|
||||
primary_key=True,
|
||||
unique=True,
|
||||
default=uuid.uuid4,
|
||||
editable=False
|
||||
)
|
||||
@@ -249,10 +249,10 @@ class SurvexBlock(models.Model):
|
||||
foreigners = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
ordering = ("id",)
|
||||
ordering = ("_blockid",)
|
||||
|
||||
def __str__(self):
|
||||
return self.name and str(self.name) or "no_name-#" + str(self.id)
|
||||
return self.name and str(self.name) or "no_name-#" + str(self.pk) #pk is primary key
|
||||
|
||||
def isSurvexBlock(self): # Function used in templates
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user