mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
Adding QM JSON export
This commit is contained in:
parent
98066591da
commit
3011e7b114
@ -141,6 +141,9 @@ class QM(TroggleModel):
|
|||||||
All the stuff handling TICK QMs is INCOMPLETE
|
All the stuff handling TICK QMs is INCOMPLETE
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
number = models.IntegerField(
|
||||||
|
help_text="this is the sequential number in the year, only unique for CSV imports",
|
||||||
|
)
|
||||||
cave = models.ForeignKey("Cave", related_name="QMs", blank=True, null=True, on_delete=models.SET_NULL)
|
cave = models.ForeignKey("Cave", related_name="QMs", blank=True, null=True, on_delete=models.SET_NULL)
|
||||||
block = models.ForeignKey("SurvexBlock", null=True, on_delete=models.SET_NULL) # only for QMs from survex files
|
block = models.ForeignKey("SurvexBlock", null=True, on_delete=models.SET_NULL) # only for QMs from survex files
|
||||||
blockname = models.TextField(blank=True, null=True) # NB truncated copy of survexblock name with last char added
|
blockname = models.TextField(blank=True, null=True) # NB truncated copy of survexblock name with last char added
|
||||||
@ -156,9 +159,7 @@ class QM(TroggleModel):
|
|||||||
ticked_off_by = models.ForeignKey(
|
ticked_off_by = models.ForeignKey(
|
||||||
LogbookEntry, related_name="QMs_ticked_off", blank=True, null=True, on_delete=models.SET_NULL
|
LogbookEntry, related_name="QMs_ticked_off", blank=True, null=True, on_delete=models.SET_NULL
|
||||||
) # unused, ever?!
|
) # unused, ever?!
|
||||||
number = models.IntegerField(
|
|
||||||
help_text="this is the sequential number in the year, only unique for CSV imports",
|
|
||||||
)
|
|
||||||
GRADE_CHOICES = (
|
GRADE_CHOICES = (
|
||||||
("A", "A: Large obvious lead"),
|
("A", "A: Large obvious lead"),
|
||||||
("B", "B: Average lead"),
|
("B", "B: Average lead"),
|
||||||
@ -170,7 +171,8 @@ class QM(TroggleModel):
|
|||||||
grade = models.CharField(max_length=1, choices=GRADE_CHOICES)
|
grade = models.CharField(max_length=1, choices=GRADE_CHOICES)
|
||||||
location_description = models.TextField(blank=True)
|
location_description = models.TextField(blank=True)
|
||||||
nearest_station_description = models.CharField(max_length=400, blank=True, null=True)
|
nearest_station_description = models.CharField(max_length=400, blank=True, null=True)
|
||||||
nearest_station_name = models.CharField(max_length=200, blank=True, null=True)
|
nearest_station_name = models.CharField(max_length=200, blank=True, null=True)
|
||||||
|
resolution_station_name = models.CharField(max_length=200, blank=True, null=True)
|
||||||
nearest_station = models.ForeignKey("SurvexStation", blank=True, null=True, on_delete=models.SET_NULL)
|
nearest_station = models.ForeignKey("SurvexStation", blank=True, null=True, on_delete=models.SET_NULL)
|
||||||
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)
|
||||||
|
@ -3,7 +3,7 @@ from django.shortcuts import render
|
|||||||
from django.views.generic.list import ListView
|
from django.views.generic.list import ListView
|
||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry
|
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry, QM
|
||||||
from troggle.core.models.survex import SurvexBlock, SurvexFile
|
from troggle.core.models.survex import SurvexBlock, SurvexFile
|
||||||
from troggle.core.models.troggle import Expedition, Person
|
from troggle.core.models.troggle import Expedition, Person
|
||||||
from troggle.core.models.wallets import Wallet
|
from troggle.core.models.wallets import Wallet
|
||||||
@ -144,6 +144,9 @@ class Expeditions_jsonListView(ListView):
|
|||||||
template_name = "core/expeditions_json_list.html"
|
template_name = "core/expeditions_json_list.html"
|
||||||
model = Expedition
|
model = Expedition
|
||||||
|
|
||||||
|
class QMs_jsonListView(ListView):
|
||||||
|
template_name = "core/QMs_json_list.html"
|
||||||
|
model = QM
|
||||||
|
|
||||||
def person(
|
def person(
|
||||||
request,
|
request,
|
||||||
|
@ -1311,7 +1311,8 @@ class LoadingSurvex:
|
|||||||
# create a short, hopefully-unique name for this block to be used in the QM id
|
# create a short, hopefully-unique name for this block to be used in the QM id
|
||||||
blockname = survexblock.name[:6] + survexblock.name[-1:]
|
blockname = survexblock.name[:6] + survexblock.name[-1:]
|
||||||
# logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}'
|
# logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}'
|
||||||
|
qm_ticked = False # default
|
||||||
|
|
||||||
qm_no = qmline.group(1) # this is NOT unique across multiple survex files
|
qm_no = qmline.group(1) # this is NOT unique across multiple survex files
|
||||||
qm_grade = qmline.group(2).strip().upper() # TICK or [a-dA-DvVxX?]
|
qm_grade = qmline.group(2).strip().upper() # TICK or [a-dA-DvVxX?]
|
||||||
if qm_grade == "TICK":
|
if qm_grade == "TICK":
|
||||||
@ -1330,13 +1331,20 @@ class LoadingSurvex:
|
|||||||
# if qmline.group(4):
|
# if qmline.group(4):
|
||||||
# qm_nearest = qm_nearest + "." + qmline.group(4)
|
# qm_nearest = qm_nearest + "." + qmline.group(4)
|
||||||
|
|
||||||
qm_resolve_station = qmline.group(4)
|
resolution_station_name = qmline.group(4)
|
||||||
|
if (resolution_station_name=="-"):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
qm_ticked = True
|
||||||
|
print(f"{survexblock.survexfile.cave} {survexblock}:{qm_no}{qm_grade} {qmline.group(4)}", file=sys.stderr)
|
||||||
|
if resolution_station_name:
|
||||||
|
qm_ticked = True
|
||||||
# if qmline.group(6) and qmline.group(6) != "-":
|
# if qmline.group(6) and qmline.group(6) != "-":
|
||||||
# qm_resolve_station = qmline.group(6)
|
# resolution_station_name = qmline.group(6)
|
||||||
# if qmline.group(7):
|
# if qmline.group(7):
|
||||||
# qm_resolve_station = qm_resolve_station + "." + qmline.group(7)
|
# resolution_station_name = resolution_station_name + "." + qmline.group(7)
|
||||||
# else:
|
# else:
|
||||||
# qm_resolve_station = ""
|
# resolution_station_name = ""
|
||||||
qm_notes = qmline.group(5)
|
qm_notes = qmline.group(5)
|
||||||
# qm_notes = qmline.group(8)
|
# qm_notes = qmline.group(8)
|
||||||
|
|
||||||
@ -1364,8 +1372,9 @@ class LoadingSurvex:
|
|||||||
qm = QM.objects.create(
|
qm = QM.objects.create(
|
||||||
number=qm_no,
|
number=qm_no,
|
||||||
# nearest_station=a_survex_station_object, # can be null
|
# nearest_station=a_survex_station_object, # can be null
|
||||||
nearest_station_description=qm_resolve_station,
|
resolution_station_name=resolution_station_name,
|
||||||
nearest_station_name=qm_nearest,
|
nearest_station_name=qm_nearest,
|
||||||
|
ticked=qm_ticked,
|
||||||
grade=qm_grade.upper(),
|
grade=qm_grade.upper(),
|
||||||
location_description=qm_notes,
|
location_description=qm_notes,
|
||||||
block=survexblock, # only set for survex-imported QMs
|
block=survexblock, # only set for survex-imported QMs
|
||||||
@ -1378,8 +1387,9 @@ class LoadingSurvex:
|
|||||||
qms = QM.objects.filter(
|
qms = QM.objects.filter(
|
||||||
number=qm_no,
|
number=qm_no,
|
||||||
# nearest_station=a_survex_station_object, # can be null
|
# nearest_station=a_survex_station_object, # can be null
|
||||||
nearest_station_description=qm_resolve_station,
|
resolution_station_name=resolution_station_name,
|
||||||
nearest_station_name=qm_nearest,
|
nearest_station_name=qm_nearest,
|
||||||
|
ticked=qm_ticked,
|
||||||
grade=qm_grade.upper(),
|
grade=qm_grade.upper(),
|
||||||
location_description=qm_notes,
|
location_description=qm_notes,
|
||||||
block=survexblock, # only set for survex-imported QMs
|
block=survexblock, # only set for survex-imported QMs
|
||||||
|
5
templates/core/QMs_json_list.html
Normal file
5
templates/core/QMs_json_list.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{% extends "baseapi.html" %}
|
||||||
|
{% block content %}{
|
||||||
|
{% for qm in object_list %}{% if not forloop.last %}"{{qm.number}}":
|
||||||
|
["{{qm.expoyear}}","{{qm.cave}}","{{qm.blockname}}","QM{{qm.number}}","{{qm.grade}}","{{qm.get_absolute_url}}"],{% endif %}{% if forloop.last %}"{{qm.number}}": ["{{qm.expoyear}}","{{qm.cave}}","{{qm.blockname}}","QM{{qm.number}}","{{qm.grade}}","{{qm.get_absolute_url}}"]{% endif %}
|
||||||
|
{% endfor %} }{% endblock %}
|
@ -53,6 +53,17 @@
|
|||||||
{{qm.block.date}} <a href="/survexfile/{{qm.block.survexfile.path}}.svx">{{qm.block}}.svx</a>
|
{{qm.block.date}} <a href="/survexfile/{{qm.block.survexfile.path}}.svx">{{qm.block}}.svx</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if qm.ticked %}
|
||||||
|
<h3>Ticked</h3>
|
||||||
|
This QM is TICKED
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if qm.resolution_station_name %}
|
||||||
|
<h3>resolution_station_name</h3>
|
||||||
|
{{qm.resolution_station_name}}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h3>Location</h3>
|
<h3>Location</h3>
|
||||||
{% if qm.block %}
|
{% if qm.block %}
|
||||||
Survex block: {{qm.blockname}}
|
Survex block: {{qm.blockname}}
|
||||||
|
3
urls.py
3
urls.py
@ -12,7 +12,7 @@ from troggle.core.views.editor_helpers import image_selector, new_image_form
|
|||||||
from troggle.core.views.expo import (editexpopage, expofiles_redirect,
|
from troggle.core.views.expo import (editexpopage, expofiles_redirect,
|
||||||
expofilessingle, expopage, map, mapfile,
|
expofilessingle, expopage, map, mapfile,
|
||||||
mediapage, spider)
|
mediapage, spider)
|
||||||
from troggle.core.views.logbooks import (Expeditions_jsonListView,
|
from troggle.core.views.logbooks import (QMs_jsonListView, Expeditions_jsonListView,
|
||||||
Expeditions_tsvListView, expedition,
|
Expeditions_tsvListView, expedition,
|
||||||
get_logbook_entries, get_people,
|
get_logbook_entries, get_people,
|
||||||
logbookentry, notablepersons, person,
|
logbookentry, notablepersons, person,
|
||||||
@ -120,6 +120,7 @@ trogglepatterns = [
|
|||||||
re_path(r'^expedition/(\d+)$', expedition, name="expedition"),
|
re_path(r'^expedition/(\d+)$', expedition, name="expedition"),
|
||||||
re_path(r'^api/expeditions_tsv$', Expeditions_tsvListView.as_view()),
|
re_path(r'^api/expeditions_tsv$', Expeditions_tsvListView.as_view()),
|
||||||
re_path(r'^api/expeditions_json$', Expeditions_jsonListView.as_view()),
|
re_path(r'^api/expeditions_json$', Expeditions_jsonListView.as_view()),
|
||||||
|
re_path(r'^api/QMs_json$', QMs_jsonListView.as_view()),
|
||||||
|
|
||||||
# Logbook entries
|
# Logbook entries
|
||||||
re_path(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbookentry,name="logbookentry"),
|
re_path(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbookentry,name="logbookentry"),
|
||||||
|
Loading…
Reference in New Issue
Block a user