mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-05-14 05:15:45 +01:00
Not quite so broken QMs from survex files
This commit is contained in:
parent
2bd617b543
commit
0ea3ed1ef2
@ -498,15 +498,16 @@ class QM(TroggleModel):
|
|||||||
area = models.CharField(max_length=100,blank=True, null=True)
|
area = models.CharField(max_length=100,blank=True, null=True)
|
||||||
completion_description = models.TextField(blank=True,null=True)
|
completion_description = models.TextField(blank=True,null=True)
|
||||||
comment=models.TextField(blank=True,null=True)
|
comment=models.TextField(blank=True,null=True)
|
||||||
|
blockname=models.TextField(blank=True,null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.code()}'
|
return f'{self.code()}'
|
||||||
|
|
||||||
def code(self):
|
def code(self):
|
||||||
if self.found_by:
|
if self.found_by:
|
||||||
return f'{str(self.found_by.cave_slug)[5:]}-{self.found_by.date.year}-{self.number}'
|
return f'{str(self.found_by.cave_slug)[5:]}-{self.found_by.date.year}-{self.blockname}{self.number}{self.grade}'
|
||||||
else:
|
else:
|
||||||
return f'{self.cave.slug()[5:]}-xxxx-{self.number}'
|
return f'{self.cave.slug()[5:]}-xxxx-{self.blockname}{self.number}{self.grade}'
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
if self.found_by:
|
if self.found_by:
|
||||||
@ -514,7 +515,7 @@ class QM(TroggleModel):
|
|||||||
else:
|
else:
|
||||||
qmyear = "1986" # HACK to check if other bits work
|
qmyear = "1986" # HACK to check if other bits work
|
||||||
#return settings.URL_ROOT + '/cave/' + self.found_by.cave.kataster_number + '/' + str(self.found_by.date.year) + '-' + '%02d' %self.number
|
#return settings.URL_ROOT + '/cave/' + self.found_by.cave.kataster_number + '/' + str(self.found_by.date.year) + '-' + '%02d' %self.number
|
||||||
return urljoin(settings.URL_ROOT, reverse('qm',kwargs={'cave_id':self.cave.slug(),'year':qmyear,'qm_id':self.number,'grade':self.grade}))
|
return urljoin(settings.URL_ROOT, reverse('qm',kwargs={'cave_id':self.cave.slug(),'year':qmyear, 'blockname':self.blockname,'qm_id':self.number,'grade':self.grade}))
|
||||||
|
|
||||||
|
|
||||||
def get_next_by_id(self):
|
def get_next_by_id(self):
|
||||||
|
@ -481,31 +481,31 @@ def caveQMs(request, slug):
|
|||||||
else:
|
else:
|
||||||
return render(request,'cave_qms.html', {'cave': cave})
|
return render(request,'cave_qms.html', {'cave': cave})
|
||||||
|
|
||||||
def qm(request,cave_id,qm_id,year,grade=None):
|
def qm(request,cave_id,qm_id,year,grade=None, blockname=""):
|
||||||
'''Reports on one specific QM
|
'''Reports on one specific QM
|
||||||
Fixed and working July 2022, for both CSV imported QMs and for survex-imported QMs,
|
Fixed and working July 2022, for both CSV imported QMs and for survex-imported QMs,
|
||||||
need refactoring though.
|
needs refactoring though.
|
||||||
'''
|
'''
|
||||||
year=int(year)
|
year=int(year)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
qm=getCave(cave_id).get_QMs().get(number=qm_id,found_by__date__year=year)
|
c=getCave(cave_id)
|
||||||
return render(request,'qm.html',locals())
|
manyqms=c.get_QMs()
|
||||||
except Cave.MultipleObjectsReturned: # entirely the wrong action, REPLACE with the right display
|
qm=manyqms.get(number=qm_id,found_by__date__year=year, found_by__cave_slug=c.slug())
|
||||||
caves = Cave.objects.filter(kataster_number=cave_id)
|
return render(request,'qm.html', {'qm': qm})
|
||||||
return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves })
|
|
||||||
|
|
||||||
except QM.DoesNotExist:
|
except QM.DoesNotExist:
|
||||||
return render(request,'errors/badslug.html', {'badslug': f'{cave_id=} {year=} {qm_id=}'})
|
return render(request,'errors/badslug.html', {'badslug': f'{cave_id=} {year=} {qm_id=} {blockname=}'})
|
||||||
|
except MultipleObjectsReturned:
|
||||||
# Ouch, this does not look like what we want to do. We need to replace this with something better.
|
qm = manyqms.filter(blockname = blockname) # we could still get multiple objects..
|
||||||
url=urllib.parse.urljoin(settings.URL_ROOT, r'/admin/core/qm/add/'+'?'+ r'number=' + qm_id)
|
if qm:
|
||||||
if grade:
|
return render(request,'qm.html', {'qm': qm})
|
||||||
url += r'&grade=' + grade
|
else:
|
||||||
return HttpResponseRedirect(url)
|
return render(request,'errors/badslug.html', {'badslug': f'{cave_id=} {year=} {qm_id=} {blockname=}'})
|
||||||
|
|
||||||
def get_qms(request, caveslug):
|
def get_qms(request, caveslug):
|
||||||
'''Does not crash, but just returns a text list of the entrances for a cave.
|
'''Does not crash, but just returns a text list of the entrances for a cave.
|
||||||
Used internally by the JSON export code? Archeology required..
|
Used internally by the JSON export code? Archeology required..
|
||||||
|
cf get_entrances() above
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
cave = Cave.objects.get(caveslug__slug = caveslug)
|
cave = Cave.objects.get(caveslug__slug = caveslug)
|
||||||
|
@ -508,7 +508,8 @@ class LoadingSurvex():
|
|||||||
|
|
||||||
def LoadSurvexQM(self, survexblock, qmline):
|
def LoadSurvexQM(self, survexblock, qmline):
|
||||||
insp = self.insp
|
insp = self.insp
|
||||||
qm_no = qmline.group(1)
|
qm_no = qmline.group(1) # this may not be unique across multiple survex files
|
||||||
|
|
||||||
qm_grade = qmline.group(2)
|
qm_grade = qmline.group(2)
|
||||||
if qmline.group(3): # usual closest survey station
|
if qmline.group(3): # usual closest survey station
|
||||||
qm_nearest = qmline.group(3)
|
qm_nearest = qmline.group(3)
|
||||||
@ -537,7 +538,8 @@ class LoadingSurvex():
|
|||||||
# so we create a dummy one anyway. We should make logbook entry links optional in QMs in future and
|
# so we create a dummy one anyway. We should make logbook entry links optional in QMs in future and
|
||||||
# remove this hack.
|
# remove this hack.
|
||||||
qmyear = str(survexblock.date)[:4]
|
qmyear = str(survexblock.date)[:4]
|
||||||
logslug = f'DUM_{int(qmyear)}_{int(qm_no):03d}'
|
blockname = survexblock.name
|
||||||
|
logslug = f'DUM_{int(qmyear)}_{blockname}_{int(qm_no):03d}'
|
||||||
if survexblock.survexfile.cave:
|
if survexblock.survexfile.cave:
|
||||||
caveslug = survexblock.survexfile.cave.slug()
|
caveslug = survexblock.survexfile.cave.slug()
|
||||||
place = survexblock.survexfile.cave
|
place = survexblock.survexfile.cave
|
||||||
@ -565,6 +567,7 @@ class LoadingSurvex():
|
|||||||
nearest_station_name=qm_nearest,
|
nearest_station_name=qm_nearest,
|
||||||
grade=qm_grade.upper(),
|
grade=qm_grade.upper(),
|
||||||
location_description=qm_notes,
|
location_description=qm_notes,
|
||||||
|
blockname = blockname, # only set for survex-imported QMs
|
||||||
found_by = placeholder,
|
found_by = placeholder,
|
||||||
cave = survexblock.survexfile.cave)
|
cave = survexblock.survexfile.cave)
|
||||||
qm.save
|
qm.save
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<p>QMs are also loaded directly from the survex files (possibly buggy, July 2022), e.g. see
|
<p>QMs are also loaded directly from the survex files (possibly buggy, July 2022), e.g. see
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/cave/qms/1623-264">1623-264 QMs</a>
|
<li><a href="/cave/qms/1623-264">1623-264 QMs</a>
|
||||||
|
<li><a href="/cave/qms/1623-290">1623-290 QMs</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>For full explanation of the current status of the QM system(s), see <a href="/handbook/troggle/scriptsqms.html">scriptsqms page</a>.
|
<p>For full explanation of the current status of the QM system(s), see <a href="/handbook/troggle/scriptsqms.html">scriptsqms page</a>.
|
||||||
@ -25,7 +26,7 @@
|
|||||||
{% for QM in cave.get_QMs %}
|
{% for QM in cave.get_QMs %}
|
||||||
{% if QM.ticked_off_by %}
|
{% if QM.ticked_off_by %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a> {{QM.nearest_station_name}} :: {{QM.nearest_station_description}} {{QM.location_description}} <b>{{QM.grade}}</b></li>
|
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a> :: {{QM.nearest_station_description}} {{QM.location_description}} <b>{{QM.grade}}</b></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@ -33,7 +34,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{% for QM in cave.get_QMs %}
|
{% for QM in cave.get_QMs %}
|
||||||
{% if QM.ticked_off_by %}
|
{% if QM.ticked_off_by %}
|
||||||
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a> {{QM.nearest_station_name}} :: {{QM.nearest_station_description}} {{QM.location_description}} <b>{{QM.grade}}</b></li>
|
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a> :: {{QM.nearest_station_description}} {{QM.location_description}} <b>{{QM.grade}}</b></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<p>QMs are also loaded directly from the survex files (possibly buggy, July 2022), e.g. see
|
<p>QMs are also loaded directly from the survex files (possibly buggy, July 2022), e.g. see
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/cave/qms/1623-264">1623-264 QMs</a>
|
<li><a href="/cave/qms/1623-264">1623-264 QMs</a>
|
||||||
|
<li><a href="/cave/qms/1623-290">1623-290 QMs</a>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>For full explanation of the current status of the QM system(s), see <a href="/handbook/troggle/scriptsqms.html">scriptsqms page</a>.
|
<p>For full explanation of the current status of the QM system(s), see <a href="/handbook/troggle/scriptsqms.html">scriptsqms page</a>.
|
||||||
|
2
urls.py
2
urls.py
@ -177,7 +177,7 @@ trogglepatterns = [
|
|||||||
|
|
||||||
# QMs pages - must precede other /caves pages?
|
# QMs pages - must precede other /caves pages?
|
||||||
re_path(r'^cave/qms/([^/]+)/?$', caveQMs, name="caveQMs"), # Fixed. July 2022
|
re_path(r'^cave/qms/([^/]+)/?$', caveQMs, name="caveQMs"), # Fixed. July 2022
|
||||||
re_path(r'^cave/qms/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDXV\?]?)?$', qm, name="qm"), # Fixed. July 2022
|
re_path(r'^cave/qms/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<blockname>[^0-9]*)?(?P<qm_id>\d*)(?P<grade>[ABCDXV\?]?)?$', qm, name="qm"), # Fixed. July 2022
|
||||||
|
|
||||||
# Prospecting Guide document
|
# Prospecting Guide document
|
||||||
re_path(r'^prospecting_guide/$', prospecting), # disabled. Bad links, incompatible image package use and very, very out of date.
|
re_path(r'^prospecting_guide/$', prospecting), # disabled. Bad links, incompatible image package use and very, very out of date.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user