2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Allow QMS to be rendered to a string, if the case that an optional parameter is missing

This commit is contained in:
Martin Green 2022-07-11 23:29:59 +01:00
parent c416de6e1e
commit 5582d545a1

View File

@ -505,9 +505,22 @@ class QM(TroggleModel):
return f'{self.code()}'
def code(self):
return f'{str(self.cave.slug())[5:]}-{self.expoyear}-{self.blockname}{self.number}{self.grade}'
if self.cave:
cavestr = str(self.cave.slug())[5:]
else:
cavestr = ""
if self.expoyear:
expoyearstr = str(self.cave.slug())[5:]
else:
expoyearstr = self.expoyear
if self.blockname:
blocknamestr = self.blockname
else:
blocknamestr = ""
return f'{cavestr}-{expoyearstr}-{blocknamestr}{self.number}{self.grade}'
def newslug(self):
qmslug = f'{str(self.cave)}-{self.expoyear}-{self.blockname}{self.number}{self.grade}'
return qmslug