mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
Fixed round-trip import-export-import bugs
This commit is contained in:
parent
f80e4efed8
commit
0a4471e039
@ -52,7 +52,7 @@ data for old logbooks. New design needed, with a mechanism for flagging fixtures
|
||||
'''
|
||||
MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200
|
||||
BLOG_PARSER_SETTINGS = {
|
||||
"2017": ("ukcavingblog.html", "parser_blog"),
|
||||
# "2017": ("ukcavingblog.html", "parser_blog"), # now folded in to logbooks.html
|
||||
"2019": ("ukcavingblog.html", "parser_blog"),
|
||||
"2022": ("ukcavingblog.html", "parser_blog"),
|
||||
}
|
||||
@ -94,7 +94,7 @@ LOGBOOK_PARSER_SETTINGS = {
|
||||
"1982": ("log.htm", "parser_html_01"),
|
||||
}
|
||||
|
||||
entries = { "2022": 64, "2019": 56, "2018": 75, "2017": 61, "2016": 81, "2015": 79,
|
||||
entries = { "2022": 64, "2019": 56, "2018": 75, "2017": 76, "2016": 81, "2015": 79,
|
||||
"2014": 65, "2013": 51, "2012": 75, "2011": 68, "2010": 22, "2009": 52,
|
||||
"2008": 49, "2007": 111, "2006": 60, "2005": 55, "2004": 76, "2003": 42, "2002": 31,
|
||||
"2001": 48, "2000": 54, "1999": 79, "1998": 43, "1997": 53, "1996": 95, "1995": 42,
|
||||
@ -140,6 +140,10 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
|
||||
tripperson = "Mike Richardson"
|
||||
if tripperson =="MikeTA":
|
||||
tripperson = "Mike Richardson"
|
||||
if tripperson =="cavingpig":
|
||||
tripperson = "Elaine Oliver"
|
||||
if tripperson =="nobrotson":
|
||||
tripperson = "Rob Watson"
|
||||
|
||||
|
||||
personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower())
|
||||
@ -153,8 +157,8 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
|
||||
author = personyear
|
||||
if not author:
|
||||
if not res:
|
||||
return None, None
|
||||
author = res[-1][0]
|
||||
return "", 0
|
||||
author = res[-1][0] # the previous valid person and a time of 0 hours
|
||||
|
||||
#print(f" - {tid} [{author.person}] '{res[0][0].person}'...")
|
||||
return res, author
|
||||
@ -193,8 +197,15 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
||||
cave = GetCaveLookup().get(lplace)
|
||||
|
||||
y = str(date)[:4]
|
||||
text = text.replace('src="', f'src="/years/{y}/' )
|
||||
text = text.replace("src='", f"src='/years/{y}/" )
|
||||
|
||||
text = text.replace(' src="', f' src="/years/{y}/' )
|
||||
text = text.replace(" src='", f" src='/years/{y}/" )
|
||||
|
||||
text = text.replace(f' src="/years/{y}//years/{y}/', f' src="/years/{y}/' )
|
||||
text = text.replace(f" src='/years/{y}//years/{y}/", f" src='/years/{y}/" )
|
||||
|
||||
text = text.replace('\t', '' )
|
||||
text = text.replace('\n\n\n', '\n\n' )
|
||||
|
||||
#Check for an existing copy of the current entry, and save
|
||||
expeditionday = expedition.get_expedition_day(date)
|
||||
@ -213,7 +224,6 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
||||
|
||||
# This creates the lbo instance of LogbookEntry
|
||||
lbo, created=save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)
|
||||
|
||||
|
||||
for tripperson, time_underground in trippersons:
|
||||
# print(f" - {tid} '{tripperson}' author:{tripperson == author}")
|
||||
@ -557,9 +567,11 @@ def parser_blog(year, expedition, txt, sq=""):
|
||||
print(message)
|
||||
# fallback, ignore the timestamp bits:
|
||||
tripdate = datetime.fromisoformat(datestamp[0:10])
|
||||
print(f" - tid: {tid} '{trippeople}' '{tripdate}'")
|
||||
# print(f" - tid: {tid} '{trippeople}' '{tripdate}'")
|
||||
|
||||
tripname = f"UK Caving Blog{sq} post {logbook_entry_count}" # must be unique for a given date
|
||||
# tripname must have the location then a hyphen at the beginning as it is ignored by export function
|
||||
location = "Unknown"
|
||||
tripname = f"Expo - UK Caving Blog{sq} post {logbook_entry_count}" # must be unique for a given date
|
||||
tripcontent = trippara + f"\n\nBlog Author: {trippeople}"
|
||||
|
||||
entrytuple = (tripdate, location, tripname, tripcontent,
|
||||
|
@ -10,6 +10,9 @@
|
||||
parser. This is because we are steadily converting old formats to a new common format so that we do not need to
|
||||
maintain half a dozen parser functions.
|
||||
|
||||
Sorry about all the crap that surrounds the image tags which has been imported along with the content
|
||||
when UK Caving blogs have been parsed.
|
||||
|
||||
Exported on {% now 'Y-m-d D' %} using control panel webpage and exportlogbook() in troggle/code/views/other.py
|
||||
-->
|
||||
<body>
|
||||
@ -18,7 +21,7 @@ Exported on {% now 'Y-m-d D' %} using control panel webpage and exportlogbook()
|
||||
|
||||
<div class="tripdate" id="{{logbook_entry.slug}}">{{logbook_entry.date|date:'Y-m-d'}}</div>
|
||||
<div class="trippeople">{% for persontrip in logbook_entry.persontrip_set.all %}{% if persontrip.is_logbook_entry_author %}<u>{{persontrip.personexpedition.person}}</u>{% else %}{{ persontrip.personexpedition.person }}{% endif %}, {% endfor %}</div>
|
||||
<div class="triptitle">{{logbook_entry.place}} - {{logbook_entry.title}}</div>
|
||||
<div class="triptitle">{{logbook_entry.title}}</div>
|
||||
|
||||
{{logbook_entry.text|safe}}
|
||||
<div class="timeug">T/U: {{logbook_entry.time_underground}}</div>
|
||||
|
Loading…
Reference in New Issue
Block a user