forked from expo/troggle
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
|
MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200
|
||||||
BLOG_PARSER_SETTINGS = {
|
BLOG_PARSER_SETTINGS = {
|
||||||
"2017": ("ukcavingblog.html", "parser_blog"),
|
# "2017": ("ukcavingblog.html", "parser_blog"), # now folded in to logbooks.html
|
||||||
"2019": ("ukcavingblog.html", "parser_blog"),
|
"2019": ("ukcavingblog.html", "parser_blog"),
|
||||||
"2022": ("ukcavingblog.html", "parser_blog"),
|
"2022": ("ukcavingblog.html", "parser_blog"),
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ LOGBOOK_PARSER_SETTINGS = {
|
|||||||
"1982": ("log.htm", "parser_html_01"),
|
"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,
|
"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,
|
"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,
|
"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"
|
tripperson = "Mike Richardson"
|
||||||
if tripperson =="MikeTA":
|
if tripperson =="MikeTA":
|
||||||
tripperson = "Mike Richardson"
|
tripperson = "Mike Richardson"
|
||||||
|
if tripperson =="cavingpig":
|
||||||
|
tripperson = "Elaine Oliver"
|
||||||
|
if tripperson =="nobrotson":
|
||||||
|
tripperson = "Rob Watson"
|
||||||
|
|
||||||
|
|
||||||
personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower())
|
personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower())
|
||||||
@ -153,8 +157,8 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
|
|||||||
author = personyear
|
author = personyear
|
||||||
if not author:
|
if not author:
|
||||||
if not res:
|
if not res:
|
||||||
return None, None
|
return "", 0
|
||||||
author = res[-1][0]
|
author = res[-1][0] # the previous valid person and a time of 0 hours
|
||||||
|
|
||||||
#print(f" - {tid} [{author.person}] '{res[0][0].person}'...")
|
#print(f" - {tid} [{author.person}] '{res[0][0].person}'...")
|
||||||
return res, author
|
return res, author
|
||||||
@ -193,9 +197,16 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
|||||||
cave = GetCaveLookup().get(lplace)
|
cave = GetCaveLookup().get(lplace)
|
||||||
|
|
||||||
y = str(date)[:4]
|
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
|
#Check for an existing copy of the current entry, and save
|
||||||
expeditionday = expedition.get_expedition_day(date)
|
expeditionday = expedition.get_expedition_day(date)
|
||||||
lookupAttribs={'date':date, 'title':title}
|
lookupAttribs={'date':date, 'title':title}
|
||||||
@ -214,7 +225,6 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
|||||||
# This creates the lbo instance of LogbookEntry
|
# This creates the lbo instance of LogbookEntry
|
||||||
lbo, created=save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)
|
lbo, created=save_carefully(LogbookEntry, lookupAttribs, nonLookupAttribs)
|
||||||
|
|
||||||
|
|
||||||
for tripperson, time_underground in trippersons:
|
for tripperson, time_underground in trippersons:
|
||||||
# print(f" - {tid} '{tripperson}' author:{tripperson == author}")
|
# print(f" - {tid} '{tripperson}' author:{tripperson == author}")
|
||||||
lookupAttribs={'personexpedition':tripperson, 'logbook_entry':lbo}
|
lookupAttribs={'personexpedition':tripperson, 'logbook_entry':lbo}
|
||||||
@ -557,9 +567,11 @@ def parser_blog(year, expedition, txt, sq=""):
|
|||||||
print(message)
|
print(message)
|
||||||
# fallback, ignore the timestamp bits:
|
# fallback, ignore the timestamp bits:
|
||||||
tripdate = datetime.fromisoformat(datestamp[0:10])
|
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}"
|
tripcontent = trippara + f"\n\nBlog Author: {trippeople}"
|
||||||
|
|
||||||
entrytuple = (tripdate, location, tripname, tripcontent,
|
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
|
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.
|
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
|
Exported on {% now 'Y-m-d D' %} using control panel webpage and exportlogbook() in troggle/code/views/other.py
|
||||||
-->
|
-->
|
||||||
<body>
|
<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="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="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}}
|
{{logbook_entry.text|safe}}
|
||||||
<div class="timeug">T/U: {{logbook_entry.time_underground}}</div>
|
<div class="timeug">T/U: {{logbook_entry.time_underground}}</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user