diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/TESTS/test_urls.py | 4 | ||||
-rw-r--r-- | core/forms.py | 25 | ||||
-rw-r--r-- | core/models/wallets.py | 8 | ||||
-rw-r--r-- | core/views/caves.py | 8 | ||||
-rw-r--r-- | core/views/scans.py | 12 | ||||
-rw-r--r-- | core/views/survex.py | 2 |
6 files changed, 31 insertions, 28 deletions
diff --git a/core/TESTS/test_urls.py b/core/TESTS/test_urls.py index 861ae2c..3070d66 100644 --- a/core/TESTS/test_urls.py +++ b/core/TESTS/test_urls.py @@ -116,7 +116,9 @@ class URLTests(TestCase): response = self.client.get("/statistics") self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() - ph = r"0 expeditions: 0 people, 0 caves and 0 logbook entries." + with open('_test_response.html', 'w') as f: + f.write(content) + ph = r"0 expeditions: 0 people, 0 caves, 0 wallets and 0 logbook entries" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") diff --git a/core/forms.py b/core/forms.py index b9a8c1f..ccdd307 100644 --- a/core/forms.py +++ b/core/forms.py @@ -103,7 +103,7 @@ class CaveForm(ModelForm): length = forms.CharField(required=False, label="Length (m)", widget=forms.TextInput(attrs={"placeholder": "usually blank"})) depth = forms.CharField(required=False, label="Depth (m)", widget=forms.TextInput(attrs={"placeholder": "usually blank"})) extent = forms.CharField(required=False, label="Extent (m)", widget=forms.TextInput(attrs={"placeholder": "usually blank"})) - areacode = forms.CharField(required=False, label="Area code", widget=forms.TextInput(attrs={"placeholder": "e.g. 1623"})) + areacode = forms.CharField(required=False, label="Area code", widget=forms.TextInput(attrs={"placeholder": "e.g. 1623"})) # should be required=True? subarea = forms.CharField(required=False, label="Subarea (do not use for new caves)", widget=forms.TextInput(attrs={"placeholder": "usually blank, archaic"})) #cave_slug = forms.CharField() @@ -143,16 +143,11 @@ class CaveForm(ModelForm): self._errors["unofficial_number"] = self.error_class( ["Either the kataster or unoffical number is required."] ) - # if self.cleaned_data.get("kataster_number") != "" and self.cleaned_data.get("official_name") == "": - # self._errors["official_name"] = self.error_class(["This field is required when there is a kataster number."]) - # if cleaned_data.get("url") == []: - # self._errors["url"] = self.error_class(["This field is required."]) - # if cleaned_data.get("url") and cleaned_data.get("url").startswith("/"): - # self._errors["url"] = self.error_class(["This field cannot start with a /."]) - if self.data.get("areacode") == "": + if self.data.get("areacode") not in ["1623", "1626", "1627", "1624"]: self._errors["areacode"] = self.error_class( - ["An areacode, e.g. 1623, is required."] + ["An Austrian kataster areacode, i.e. 1623, 1626, 1627, or 1624 is required."] ) + return cleaned_data @@ -261,10 +256,14 @@ class EntranceForm(ModelForm): ) def clean(self): - # if self.cleaned_data.get("url"): # can remove this as the form does not have a url field any more, which was never used anyway - # if self.cleaned_data.get("url").startswith("/"): - # self._errors["url"] = self.error_class(["This field cannot start with a /."]) - return self.cleaned_data + cleaned_data = super(EntranceForm, self).clean() # where is this code hidden? How does this work?? + for station in ["tag_station", "other_station"]: + print(f"{station} -- {self.data.get(station)[:4]}") + if self.data.get(station)[:5] not in ["1623.", "1626.", "1627.", "1624.", ""]: + self._errors[station] = self.error_class( + ["An Austrian kataster areacode, i.e. 1623, 1626, 1627, or 1624 prefix is required."] + ) + return self.cleaned_data # # This next line is sufficient to create an entire entry for for the cave fields automatically diff --git a/core/models/wallets.py b/core/models/wallets.py index d9a140d..9e54f4e 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -380,8 +380,10 @@ class Wallet(models.Model): if waldata["survex not required"]: survexok = "green" ticks["S"] = "green" - else: - if waldata["survex file"]: + else: + if "survex file" not in waldata: + ticks["S"] = "darkred" + else: if not type(waldata["survex file"]) == list: # a string also is a sequence type, so do it this way waldata["survex file"] = [waldata["survex file"]] ngood = 0 @@ -403,7 +405,7 @@ class Wallet(models.Model): elif nbad >= 1 and ngood == 0: # all bad ticks["S"] = "red" elif nbad == 0 and ngood == 0: # list of blank strings - ticks["S"] = "red" + ticks["S"] = "crimson" else: ticks["S"] = "fuchsia" # have fun working out what this means diff --git a/core/views/caves.py b/core/views/caves.py index 856c2cd..2498fb4 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -657,6 +657,8 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): nextletter = chr(ord(letter)+1) return check_new_slugname_ok(slug, nextletter) + entletter = "" # default to stop crashes + entletterform = None if not (cave:= get_cave_from_slug(caveslug)): # walrus operator return render(request, "errors/badslug.html", {"badslug": f"for cave {caveslug} - from edit_entrance()"}) @@ -720,10 +722,10 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): entranceletter="" if not entform.is_valid(): - message = f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} entletterform valid:{entletterform.is_valid()}" - entrance = entform.save(commit=False) + message = f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} " + # entrance = entform.save(commit=False) print(message) - return render(request, "errors/generic.html", {"message": message}) + # return render(request, "errors/generic.html", {"message": message}) else: print(f"'edit_entrance(): POST is valid {caveslug=} Editing {entslug=} {entranceletter=} {path=}") diff --git a/core/views/scans.py b/core/views/scans.py index 62251de..4263c2c 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -215,13 +215,11 @@ def walletslistperson(request, slug): if w in manywallets: # we already know this is a wallet we need to report on continue + if not w.people(): # bug? skip + # msg = f"{w} no w.people() found " + # print(msg) + continue for n in w.people(): - # if n.lower().startswith("lydia"): - # print(f"{w} {n=} ") - # for x in crew: - # if x.lower()==n.lower(): - # print(f"{w} {n=} {x=}") - if n.lower() in crew: if crew[n.lower()] == person_expo: manywallets.add(w) @@ -248,7 +246,7 @@ def walletslistperson(request, slug): expeditions = Expedition.objects.all() length_ug = 0.0 for w in manywallets: - print(w.persons) + print(f"{w}: no .persons in this wallet but people() is {w.people()}") for sb in w.survexblock_set.all(): length_ug += sb.legslength return render( diff --git a/core/views/survex.py b/core/views/survex.py index 075c426..44fdf45 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -67,7 +67,7 @@ survextemplatefile = """; *** THIS IS A TEMPLATE FILE - NOT WHAT YOU MIGHT BE EX *team [Badger] Notes *team ["Fred Fossa"] insts *team [Grumpy] Pics -instrument [SAP #+Laser Tape/DistoX/Compass # ; Clino #] +[*instrument tape "CUCC Fisco Ranger open reel"] ; <-- CHANGE THIS to actual instrument ; Calibration: [Where, readings] *ref [2040#00] ; <-- CHANGE THIS TOO ; the #number is on the clear pocket containing the original notes |