mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 05:58:45 +00:00
removing new_since_parsing and fixing tests
This commit is contained in:
@@ -229,10 +229,10 @@ class FixturePageTests(TestCase):
|
|||||||
response = self.client.get("/caves")
|
response = self.client.get("/caves")
|
||||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||||
content = response.content.decode()
|
content = response.content.decode()
|
||||||
ph = r"284 <em>Seetrichter (Lake bottom)</em>"
|
ph = r"Seetrichter"
|
||||||
phmatch = re.search(ph, content)
|
phmatch = re.search(ph, content)
|
||||||
# with open('_cave_fix_caves.html', 'w') as f:
|
with open('_cave_caves284.html', 'w') as f:
|
||||||
# f.write(content)
|
f.write(content)
|
||||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
||||||
|
|
||||||
# Although the Cave object exists, it looks like we get a bad slug error when trying to get a QM page.
|
# Although the Cave object exists, it looks like we get a bad slug error when trying to get a QM page.
|
||||||
|
|||||||
@@ -116,9 +116,9 @@ class URLTests(TestCase):
|
|||||||
response = self.client.get("/statistics")
|
response = self.client.get("/statistics")
|
||||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||||
content = response.content.decode()
|
content = response.content.decode()
|
||||||
with open('_test_response.html', 'w') as f:
|
with open('_test_response_statistics.html', 'w') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
ph = r"0 expeditions: 0 people, 0 caves, 0 wallets and 0 logbook entries"
|
ph = r"0 people, 0 caves, 0 wallets and 0 logbook entries"
|
||||||
phmatch = re.search(ph, content)
|
phmatch = re.search(ph, content)
|
||||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
||||||
|
|
||||||
|
|||||||
@@ -448,21 +448,11 @@ class PageTests(TestCase):
|
|||||||
response = self.client.get("/dwgfiles")
|
response = self.client.get("/dwgfiles")
|
||||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
||||||
content = response.content.decode()
|
content = response.content.decode()
|
||||||
|
# with open('_test_response_dwgallfiles.html', 'w') as f:
|
||||||
|
# f.write(content)
|
||||||
for ph in [
|
for ph in [
|
||||||
r"All Tunnel and Therion files",
|
r"All Tunnel and Therion files",
|
||||||
r"<th>Wallets</th><th>Scan files in the wallets</th><th>Frames</th></tr>",
|
r"<th>Wallets</th><th>Scan files when the drawing was created</th><th>Frames</th></tr>",
|
||||||
]:
|
|
||||||
phmatch = re.search(ph, content)
|
|
||||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
|
||||||
|
|
||||||
def test_page_dwgallfiles_empty_slash(self):
|
|
||||||
# this gets an empty page as the database has not been loaded
|
|
||||||
response = self.client.get("/dwgfiles")
|
|
||||||
self.assertEqual(response.status_code, HTTPStatus.OK)
|
|
||||||
content = response.content.decode()
|
|
||||||
for ph in [
|
|
||||||
r"All Tunnel and Therion files",
|
|
||||||
r"<th>Wallets</th><th>Scan files in the wallets</th><th>Frames</th></tr>",
|
|
||||||
]:
|
]:
|
||||||
phmatch = re.search(ph, content)
|
phmatch = re.search(ph, content)
|
||||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class TroggleModelAdmin(admin.ModelAdmin):
|
|||||||
"""overriding admin save to fill the new_since parsing_field
|
"""overriding admin save to fill the new_since parsing_field
|
||||||
|
|
||||||
new_since_parsing is not currently used in troggle. It is a fossil."""
|
new_since_parsing is not currently used in troggle. It is a fossil."""
|
||||||
obj.new_since_parsing = True
|
# obj.new_since_parsing = True
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[{"model": "core.cave", "pk": 43, "fields":
|
[{"model": "core.cave", "pk": 43, "fields":
|
||||||
{"new_since_parsing": false, "non_public": false,
|
{"non_public": false,
|
||||||
"official_name": "Schnellzughöhle",
|
"official_name": "Schnellzughöhle",
|
||||||
"kataster_code": "6/t/S/W x",
|
"kataster_code": "6/t/S/W x",
|
||||||
"kataster_number": "115",
|
"kataster_number": "115",
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
"areacode": "1623"}},
|
"areacode": "1623"}},
|
||||||
|
|
||||||
{"model": "core.cave", "pk": 350, "fields":
|
{"model": "core.cave", "pk": 350, "fields":
|
||||||
{"new_since_parsing": false, "non_public": false,
|
{"non_public": false,
|
||||||
"official_name": "Seetrichter",
|
"official_name": "Seetrichter (Lake bottom)",
|
||||||
"kataster_code": "",
|
"kataster_code": "",
|
||||||
"kataster_number": "284",
|
"kataster_number": "284",
|
||||||
"unofficial_number": "",
|
"unofficial_number": "",
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
[{"model": "core.expedition", "pk": 44, "fields":
|
[{"model": "core.expedition", "pk": 44, "fields":
|
||||||
{"new_since_parsing": false, "non_public": false,
|
{"non_public": false,
|
||||||
"year": "2019", "name": "CUCC expo 2019"}},
|
"year": "2019", "name": "CUCC expo 2019"}},
|
||||||
|
|
||||||
{"model": "core.personexpedition", "pk": 681, "fields":
|
{"model": "core.personexpedition", "pk": 681, "fields":
|
||||||
{"new_since_parsing": false, "non_public": false,
|
{"non_public": false,
|
||||||
"expedition": 44,
|
"expedition": 44,
|
||||||
"person": 250, "slugfield": null
|
"person": 250, "slugfield": null
|
||||||
}},
|
}},
|
||||||
|
|
||||||
{"model": "core.person", "pk": 250, "fields":
|
{"model": "core.person", "pk": 250, "fields":
|
||||||
{"new_since_parsing": false, "non_public": false,
|
{"non_public": false,
|
||||||
"first_name": "Michael",
|
"first_name": "Michael",
|
||||||
"last_name": "Sargent",
|
"last_name": "Sargent",
|
||||||
"slug": "michael-sargent",
|
"slug": "michael-sargent",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ There are more subclasses defined in models/caves.py models/survex.py etc.
|
|||||||
class TroggleModel(models.Model):
|
class TroggleModel(models.Model):
|
||||||
"""This class is for adding fields and methods which all of our models will have."""
|
"""This class is for adding fields and methods which all of our models will have."""
|
||||||
|
|
||||||
new_since_parsing = models.BooleanField(default=False, editable=False)
|
# new_since_parsing = models.BooleanField(default=False, editable=False)
|
||||||
non_public = models.BooleanField(default=False)
|
non_public = models.BooleanField(default=False)
|
||||||
|
|
||||||
def object_name(self):
|
def object_name(self):
|
||||||
@@ -27,6 +27,7 @@ class TroggleModel(models.Model):
|
|||||||
|
|
||||||
def get_admin_url(self):
|
def get_admin_url(self):
|
||||||
# we do not use URL_ROOT any more.
|
# we do not use URL_ROOT any more.
|
||||||
|
# replace this with pathlib..
|
||||||
return urljoin("/admin/core/" + self.object_name().lower() + "/" + str(self.pk))
|
return urljoin("/admin/core/" + self.object_name().lower() + "/" + str(self.pk))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -83,6 +84,7 @@ class Person(TroggleModel):
|
|||||||
Note that the class "User" and the class "Group
|
Note that the class "User" and the class "Group
|
||||||
are standrd Django classes
|
are standrd Django classes
|
||||||
definied in django.contrib.auth.models
|
definied in django.contrib.auth.models
|
||||||
|
but we do not use all the fields defined in those classes. This is FINE, don't try to delete those unused fields.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
input_name = models.CharField(max_length=100, blank=True, null=True)
|
input_name = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ def cavesall(request):
|
|||||||
allcaves = caves1623 + caves1624 + caves1626 + caves1627
|
allcaves = caves1623 + caves1624 + caves1626 + caves1627
|
||||||
caves_this_year = []
|
caves_this_year = []
|
||||||
for c in allcaves:
|
for c in allcaves:
|
||||||
if c.unofficial_number.startswith(current_expo()):
|
if c.unofficial_number and c.unofficial_number.startswith(current_expo()):
|
||||||
caves_this_year.append(c)
|
caves_this_year.append(c)
|
||||||
caves_this_year.sort(key=caveKey)
|
caves_this_year.sort(key=caveKey)
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,6 @@ but _also_, and peculiarly, in the troggle/admin.py files
|
|||||||
e.g.
|
e.g.
|
||||||
class TroggleModelAdmin(admin.ModelAdmin):
|
class TroggleModelAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
|
||||||
"""overriding admin save to fill the new_since parsing_field"""
|
|
||||||
obj.new_since_parsing=True
|
|
||||||
obj.save()
|
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
js = ('jquery/jquery.min.js','js/QM_helper.js')
|
js = ('jquery/jquery.min.js','js/QM_helper.js')
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,13 @@ but _also_, and peculiarly, in the troggle/admin.py files (which are dead links)
|
|||||||
i.e.
|
i.e.
|
||||||
class TroggleModelAdmin(admin.ModelAdmin):
|
class TroggleModelAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
|
||||||
"""overriding admin save to fill the new_since parsing_field"""
|
|
||||||
obj.new_since_parsing=True
|
|
||||||
obj.save()
|
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
js = ('jquery/jquery.min.js','js/QM_helper.js')
|
js = ('jquery/jquery.min.js','js/QM_helper.js')
|
||||||
|
|
||||||
NB any *Admin class is used in the Django control panel only.
|
NB any *Admin class is used in the Django control panel only.
|
||||||
|
|
||||||
The jquery links have been REMOVED from the templates as they were not used anywhere.
|
The jquery links have been REMOVED from the templates as they were not used anywhere.
|
||||||
Martin include jQuery in his HTML editor though, using the default copy provided by Djangon in the
|
Martin include jQuery in his HTML editor though, using the default copy provided by Django in the
|
||||||
/media/admin/js/vendor/jquery/ folder
|
/media/admin/js/vendor/jquery/ folder
|
||||||
which is
|
which is
|
||||||
"jQuery JavaScript Library v3.5.1"
|
"jQuery JavaScript Library v3.5.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user