summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/views/logbooks.py8
-rw-r--r--parsers/QMs.py5
-rw-r--r--parsers/logbooks.py4
3 files changed, 14 insertions, 3 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 2ec6991..fe78cb6 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -187,6 +187,14 @@ def logbookentry(request, date, slug):
return render(request, 'object_list.html',{'object_list':this_logbookentry})
else:
this_logbookentry=this_logbookentry[0]
+ y = str(this_logbookentry.date)[:4]
+ fix = f'src="/years/{y}/'
+ print(f'LOGBOOK ENTRY {this_logbookentry.date} /years/{y}')
+ this_logbookentry.text = this_logbookentry.text.replace('src="', fix )
+ this_logbookentry.text = this_logbookentry.text.replace("src='", f"src='/years/{y}/" )
+ print(this_logbookentry.text)
+ this_logbookentry.save()
+
return render(request, 'logbookentry.html', {'logbookentry': this_logbookentry})
else:
msg =(f' Logbook entry slug:"{slug}" not found in database on date:"{date}" ')
diff --git a/parsers/QMs.py b/parsers/QMs.py
index fe796a0..be180b2 100644
--- a/parsers/QMs.py
+++ b/parsers/QMs.py
@@ -57,13 +57,16 @@ def parseCaveQMs(cave,inputFile):
qmCSVContents.seek(0,0)
qmReader = csv.reader(qmCSVContents,dialect=dialect)
next(qmReader) # Skip header row
+ n = 0
for line in qmReader:
try:
+ n += 1
year=int(line[0][1:5])
+ logslug = f'PH_{int(year)}_{int(n):02d}'
#check if placeholder exists for given year, create it if not
message = " ! - "+ str(year) + " logbook: placeholder entry for '" + cave + "' created. Should be re-attached to the actual trip."
if cave=='204-steinBH':
- placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="204", title="placeholder for QMs in 204", text=message, defaults={"date": date(year, 1, 1),"cave_slug":str(steinBr)})
+ placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="204", title="placeholder for QMs in 204", text=message, defaults={"date": date(year, 1, 1),"cave_slug":str(steinBr), "slug": logslug})
elif cave=='234-Hauch':
placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="234", title="placeholder for QMs in 234", text=message, defaults={"date": date(year, 1, 1),"cave_slug":str(hauchHl)})
# if hadToCreate:
diff --git a/parsers/logbooks.py b/parsers/logbooks.py
index 8237bdc..3bb49b5 100644
--- a/parsers/logbooks.py
+++ b/parsers/logbooks.py
@@ -59,7 +59,7 @@ trips ={}
# the logbook loading section
#
def set_trip_id(year, seq):
- tid= f"{year}.s{seq:02d}"
+ tid= f"{year}_s{seq:02d}"
return tid
@@ -135,7 +135,7 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
# but it is a db query which we should try to avoid - rewrite this
#NEW slug for a logbook entry here! Use the unique id, not the title !!!
- slug = tid + "." + slugify(title)[:10]
+ slug = tid + "_" + slugify(title)[:10].replace('-','_')
nonLookupAttribs={'place':place, 'text':text, 'expedition':expedition, 'cave_slug':str(cave), 'slug': slug, 'entry_type':entry_type}
lbo, created=save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)