diff options
Diffstat (limited to 'core/models/wallets.py')
-rw-r--r-- | core/models/wallets.py | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/core/models/wallets.py b/core/models/wallets.py index 0335524..2de8f9d 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -99,8 +99,7 @@ class Wallet(models.Model): walletdate = models.DateField(blank=True, null=True) walletyear = models.DateField(blank=True, null=True) caves = models.ManyToManyField("Cave", related_name="wallets") - # not yet - #persons = models.ManyToManyField("Person", related_name="wallets") + persons = models.ManyToManyField("Person", related_name="wallets") class Meta: ordering = ("walletname",) @@ -126,6 +125,8 @@ class Wallet(models.Model): return newstuff if stuff: return [stuff] # single object, not a string, but now in a list. + + return [] def get_absolute_url(self): @@ -220,25 +221,7 @@ class Wallet(models.Model): except: print(f"FAIL adding cave to wallet.caves '{i}'") pass - - # if type(cavelist) is list: - # for i in cavelist: - # if i != "": - # i = i.replace("/", "-") - # caveobject = get_cave_leniently(i) - # self.caves.add(caveobject) # new many-to-many field - # else: - # # either single cave or the square barckets have been removed and it s a singoe string - # ids = cavelist.split(",") - # for i in ids: - # j = i.replace("'","").replace("/", "-").strip('[] "') - # if i != "": - # try: - # caveobject = get_cave_leniently(j) # may fail if garbage value ,e.g. space, in wallet data - # self.caves.add(caveobject) - # except: - # print(f"FAIL adding cave to wallet.caves '{j}'") - # pass + def year(self): """This gets the year syntactically without opening and reading the JSON""" if len(self.walletname) < 5: @@ -294,6 +277,15 @@ class Wallet(models.Model): return None return jsondata["name"] + + def survexfiles(self): + if not (jsondata := self.get_json()): # WALRUS + return None + + filelist = Wallet.input_to_list(jsondata["survex file"]) + #print(f"'{self} {jsondata['survex file']}' => {filelist}") + return filelist + def get_fnames(self): '''Filenames without the suffix, i.e. without the ".jpg"''' dirpath = Path(settings.SCANS_ROOT, self.fpath) # does nowt as fpath is a rooted path already |