mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
add 'lastvisit' field to entrances, for the date
This commit is contained in:
parent
45f06293f5
commit
e0ac09d5ec
@ -76,6 +76,7 @@ class EntranceForm(ModelForm):
|
|||||||
attrs={"height":"80%", "rows":20, 'placeholder': "Enter page content (using HTML)"}))
|
attrs={"height":"80%", "rows":20, 'placeholder': "Enter page content (using HTML)"}))
|
||||||
location_description = forms.CharField(required = False, widget=HTMLarea(
|
location_description = forms.CharField(required = False, widget=HTMLarea(
|
||||||
attrs={"height":"80%", "rows":20, 'placeholder': "Enter page content (using HTML)"}))
|
attrs={"height":"80%", "rows":20, 'placeholder': "Enter page content (using HTML)"}))
|
||||||
|
lastvisit = forms.CharField(required=False, widget=forms.TextInput(attrs={'size': '10'}), label="Date of last visit")
|
||||||
approach = forms.CharField(required = False, widget=HTMLarea(
|
approach = forms.CharField(required = False, widget=HTMLarea(
|
||||||
attrs={"height":"80%", "rows":20, 'placeholder': "Enter page content (using HTML)"}))
|
attrs={"height":"80%", "rows":20, 'placeholder': "Enter page content (using HTML)"}))
|
||||||
underground_description = forms.CharField(required = False, widget=HTMLarea(
|
underground_description = forms.CharField(required = False, widget=HTMLarea(
|
||||||
|
@ -274,6 +274,7 @@ class Entrance(TroggleModel):
|
|||||||
explorers = models.TextField(blank=True,null=True)
|
explorers = models.TextField(blank=True,null=True)
|
||||||
map_description = models.TextField(blank=True,null=True)
|
map_description = models.TextField(blank=True,null=True)
|
||||||
location_description = models.TextField(blank=True,null=True)
|
location_description = models.TextField(blank=True,null=True)
|
||||||
|
lastvisit = models.TextField(blank=True,null=True)
|
||||||
approach = models.TextField(blank=True,null=True)
|
approach = models.TextField(blank=True,null=True)
|
||||||
underground_description = models.TextField(blank=True,null=True)
|
underground_description = models.TextField(blank=True,null=True)
|
||||||
photo = models.TextField(blank=True,null=True)
|
photo = models.TextField(blank=True,null=True)
|
||||||
|
104
parsers/caves.py
104
parsers/caves.py
@ -222,6 +222,7 @@ def readentrance(filename):
|
|||||||
explorers = getXML(entrancecontents, "explorers", maxItems = 1, context = context)
|
explorers = getXML(entrancecontents, "explorers", maxItems = 1, context = context)
|
||||||
map_description = getXML(entrancecontents, "map_description", maxItems = 1, context = context)
|
map_description = getXML(entrancecontents, "map_description", maxItems = 1, context = context)
|
||||||
location_description = getXML(entrancecontents, "location_description", maxItems = 1, context = context)
|
location_description = getXML(entrancecontents, "location_description", maxItems = 1, context = context)
|
||||||
|
lastvisit = getXML(entrancecontents, "last visit date", maxItems = 1, minItems = 0, context = context)
|
||||||
approach = getXML(entrancecontents, "approach", maxItems = 1, context = context)
|
approach = getXML(entrancecontents, "approach", maxItems = 1, context = context)
|
||||||
underground_description = getXML(entrancecontents, "underground_description", maxItems = 1, context = context)
|
underground_description = getXML(entrancecontents, "underground_description", maxItems = 1, context = context)
|
||||||
photo = getXML(entrancecontents, "photo", maxItems = 1, context = context)
|
photo = getXML(entrancecontents, "photo", maxItems = 1, context = context)
|
||||||
@ -238,59 +239,61 @@ def readentrance(filename):
|
|||||||
other_description = getXML(entrancecontents, "other_description", maxItems = 1, context = context)
|
other_description = getXML(entrancecontents, "other_description", maxItems = 1, context = context)
|
||||||
bearings = getXML(entrancecontents, "bearings", maxItems = 1, context = context)
|
bearings = getXML(entrancecontents, "bearings", maxItems = 1, context = context)
|
||||||
url = getXML(entrancecontents, "url", maxItems = 1, context = context)
|
url = getXML(entrancecontents, "url", maxItems = 1, context = context)
|
||||||
if len(non_public) == 1 and len(slugs) >= 1 and len(name) >= 1 and len(entrance_description) == 1 and len(explorers) == 1 and len(map_description) == 1 and len(location_description) == 1 and len(approach) == 1 and len(underground_description) == 1 and len(marking) == 1 and len(marking_comment) == 1 and len(findability) == 1 and len(findability_description) == 1 and len(alt) == 1 and len(northing) == 1 and len(easting) == 1 and len(tag_station) == 1 and len(exact_station) == 1 and len(other_station) == 1 and len(other_description) == 1 and len(bearings) == 1 and len(url) == 1:
|
#if len(non_public) == 1 and len(slugs) >= 1 and len(name) >= 1 and len(entrance_description) == 1 and len(explorers) == 1 and len(map_description) == 1 and len(location_description) == 1 and len(lastvisit) == 1 and len(approach) == 1 and len(underground_description) == 1 and len(marking) == 1 and len(marking_comment) == 1 and len(findability) == 1 and len(findability_description) == 1 and len(alt) == 1 and len(northing) == 1 and len(easting) == 1 and len(tag_station) == 1 and len(exact_station) == 1 and len(other_station) == 1 and len(other_description) == 1 and len(bearings) == 1 and len(url) == 1:
|
||||||
e, state = Entrance.objects.update_or_create(name = name[0],
|
e, state = Entrance.objects.update_or_create(name = name[0],
|
||||||
non_public = {"True": True, "False": False, "true": True, "false": False,}[non_public[0]],
|
non_public = {"True": True, "False": False, "true": True, "false": False,}[non_public[0]],
|
||||||
entrance_description = entrance_description[0],
|
entrance_description = entrance_description[0],
|
||||||
explorers = explorers[0],
|
explorers = explorers[0],
|
||||||
map_description = map_description[0],
|
map_description = map_description[0],
|
||||||
location_description = location_description[0],
|
location_description = location_description[0],
|
||||||
approach = approach[0],
|
lastvisit = lastvisit[0],
|
||||||
underground_description = underground_description[0],
|
approach = approach[0],
|
||||||
photo = photo[0],
|
underground_description = underground_description[0],
|
||||||
marking = marking[0],
|
photo = photo[0],
|
||||||
marking_comment = marking_comment[0],
|
marking = marking[0],
|
||||||
findability = findability[0],
|
marking_comment = marking_comment[0],
|
||||||
findability_description = findability_description[0],
|
findability = findability[0],
|
||||||
alt = alt[0],
|
findability_description = findability_description[0],
|
||||||
northing = northing[0],
|
alt = alt[0],
|
||||||
easting = easting[0],
|
northing = northing[0],
|
||||||
tag_station = tag_station[0],
|
easting = easting[0],
|
||||||
exact_station = exact_station[0],
|
tag_station = tag_station[0],
|
||||||
other_station = other_station[0],
|
exact_station = exact_station[0],
|
||||||
other_description = other_description[0],
|
other_station = other_station[0],
|
||||||
bearings = bearings[0],
|
other_description = other_description[0],
|
||||||
url = url[0],
|
bearings = bearings[0],
|
||||||
filename = filename,
|
url = url[0],
|
||||||
cached_primary_slug = slugs[0])
|
filename = filename,
|
||||||
primary = True
|
cached_primary_slug = slugs[0])
|
||||||
for slug in slugs:
|
primary = True
|
||||||
#print("entrance slug:{} filename:{}".format(slug, filename))
|
for slug in slugs:
|
||||||
try:
|
#print("entrance slug:{} filename:{}".format(slug, filename))
|
||||||
cs = EntranceSlug.objects.update_or_create(entrance = e,
|
try:
|
||||||
|
cs = EntranceSlug.objects.update_or_create(entrance = e,
|
||||||
|
slug = slug,
|
||||||
|
primary = primary)
|
||||||
|
except:
|
||||||
|
# need to cope with duplicates
|
||||||
|
message = f" ! FAILED to get precisely one ENTRANCE when updating using: cave_entrance/{filename}"
|
||||||
|
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
||||||
|
kents = EntranceSlug.objects.all().filter(entrance = e,
|
||||||
slug = slug,
|
slug = slug,
|
||||||
primary = primary)
|
primary = primary)
|
||||||
except:
|
for k in kents:
|
||||||
# need to cope with duplicates
|
message = " ! - DUPLICATE in db. entrance:"+ str(k.entrance) + ", slug:" + str(k.slug())
|
||||||
message = f" ! FAILED to get precisely one ENTRANCE when updating using: cave_entrance/{filename}"
|
|
||||||
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
||||||
kents = EntranceSlug.objects.all().filter(entrance = e,
|
print(message)
|
||||||
slug = slug,
|
for k in kents:
|
||||||
primary = primary)
|
if k.slug() != None:
|
||||||
for k in kents:
|
print(" ! - OVERWRITING this one: slug:"+ str(k.slug()))
|
||||||
message = " ! - DUPLICATE in db. entrance:"+ str(k.entrance) + ", slug:" + str(k.slug())
|
k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes
|
||||||
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
c = k
|
||||||
print(message)
|
|
||||||
for k in kents:
|
|
||||||
if k.slug() != None:
|
|
||||||
print(" ! - OVERWRITING this one: slug:"+ str(k.slug()))
|
|
||||||
k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes
|
|
||||||
c = k
|
|
||||||
primary = False
|
primary = False
|
||||||
else: # more than one item in long list
|
# else: # more than one item in long list. But this is not an error, and the max and min have been checked by getXML
|
||||||
message = f' ! {slug:12} ABORT loading this entrance. in "{filename}"'
|
# slug = Path(filename).stem
|
||||||
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
# message = f' ! ABORT loading this entrance. in "{filename}"'
|
||||||
print(message)
|
# DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
||||||
|
# print(message)
|
||||||
|
|
||||||
def readcave(filename):
|
def readcave(filename):
|
||||||
'''Assumes any area it hasn't seen before is a subarea of 1623
|
'''Assumes any area it hasn't seen before is a subarea of 1623
|
||||||
@ -458,6 +461,9 @@ def getXML(text, itemname, minItems = 1, maxItems = None, printwarnings = True,
|
|||||||
"max": maxItems} + " in file " + context
|
"max": maxItems} + " in file " + context
|
||||||
DataIssue.objects.create(parser='caves', message=message)
|
DataIssue.objects.create(parser='caves', message=message)
|
||||||
print(message)
|
print(message)
|
||||||
|
if minItems == 0:
|
||||||
|
if not items:
|
||||||
|
items = [ "" ]
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def readcaves():
|
def readcaves():
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
{% if ent.entrance.location_description %}
|
{% if ent.entrance.location_description %}
|
||||||
<dt>Location</dt><dd>{{ ent.entrance.location_description|safe }}</dd>
|
<dt>Location</dt><dd>{{ ent.entrance.location_description|safe }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if ent.entrance.lastvisit %}
|
||||||
|
<dt>Location</dt><dd>{{ ent.entrance.lastvisit|safe }}</dd>
|
||||||
|
{% endif %}
|
||||||
{% if ent.entrance.approach %}
|
{% if ent.entrance.approach %}
|
||||||
<dt>Approach</dt><dd>{{ ent.entrance.approach|safe }}</dd>
|
<dt>Approach</dt><dd>{{ ent.entrance.approach|safe }}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<explorers>{{ entrance.explorers|default_if_none:""|safe }}</explorers>
|
<explorers>{{ entrance.explorers|default_if_none:""|safe }}</explorers>
|
||||||
<map_description>{{ entrance.map_description|default_if_none:""|safe }}</map_description>
|
<map_description>{{ entrance.map_description|default_if_none:""|safe }}</map_description>
|
||||||
<location_description>{{ entrance.location_description|default_if_none:""|safe }}</location_description>
|
<location_description>{{ entrance.location_description|default_if_none:""|safe }}</location_description>
|
||||||
|
<lastvisit>{{ entrance.lastvisit|default_if_none:""|safe }}</lastvisit>
|
||||||
<approach>{{ entrance.approach|default_if_none:""|safe }}</approach>
|
<approach>{{ entrance.approach|default_if_none:""|safe }}</approach>
|
||||||
<underground_description>{{ entrance.underground_description|default_if_none:""|safe }}</underground_description>
|
<underground_description>{{ entrance.underground_description|default_if_none:""|safe }}</underground_description>
|
||||||
<photo>{{ entrance.photo|default_if_none:"<img src='/1623/000/000.jpg' />"|safe }}</photo>
|
<photo>{{ entrance.photo|default_if_none:"<img src='/1623/000/000.jpg' />"|safe }}</photo>
|
||||||
|
@ -45,6 +45,10 @@
|
|||||||
<h2>Location Description</h2>
|
<h2>Location Description</h2>
|
||||||
{{ entrance.location_description|safe }}
|
{{ entrance.location_description|safe }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if entrance.lastvisit %}
|
||||||
|
<h2>Last Visit Date</h2>
|
||||||
|
{{ entrance.llastvisit|safe }}
|
||||||
|
{% endif %}
|
||||||
{% if entrance.approach %}
|
{% if entrance.approach %}
|
||||||
<h2>Approach</h2>
|
<h2>Approach</h2>
|
||||||
{{ entrance.approach|safe }}
|
{{ entrance.approach|safe }}
|
||||||
|
Loading…
Reference in New Issue
Block a user