summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Wenham <sam@wenhams.co.uk>2019-03-09 11:18:44 +0000
committerSam Wenham <sam@wenhams.co.uk>2019-03-09 11:18:44 +0000
commit1bac650aeeb7db415df82a9dda7a457f451856d4 (patch)
tree2d6a26d05c685e2dd3419be0c6824c706f999b8f
parent9fc80bed35a03295fad492601f802cab830144ae (diff)
downloadtroggle-1bac650aeeb7db415df82a9dda7a457f451856d4.tar.gz
troggle-1bac650aeeb7db415df82a9dda7a457f451856d4.tar.bz2
troggle-1bac650aeeb7db415df82a9dda7a457f451856d4.zip
There is no point having two functions do basicaly the same thing so make the
load all logbooks call load logbook(expo) Remove the return message from load logbook as it isn't used
-rw-r--r--core/views_logbooks.py4
-rw-r--r--parsers/logbooks.py39
-rw-r--r--templates/expedition.html4
3 files changed, 5 insertions, 42 deletions
diff --git a/core/views_logbooks.py b/core/views_logbooks.py
index 9fcc3eb..3ab55d6 100644
--- a/core/views_logbooks.py
+++ b/core/views_logbooks.py
@@ -77,8 +77,8 @@ def expedition(request, expeditionname):
message = ""
if "reload" in request.GET:
- message = LoadLogbookForExpedition(this_expedition)
- return render_with_context(request,'expedition.html', {'expedition': this_expedition, 'expeditions':expeditions, 'personexpeditiondays':personexpeditiondays, 'message':message, 'settings':settings, 'dateditems': dateditems })
+ LoadLogbookForExpedition(this_expedition)
+ return render_with_context(request,'expedition.html', {'expedition': this_expedition, 'expeditions':expeditions, 'personexpeditiondays':personexpeditiondays, 'settings':settings, 'dateditems': dateditems })
def get_absolute_url(self):
return ('expedition', (expedition.year))
diff --git a/parsers/logbooks.py b/parsers/logbooks.py
index 4554b08..22674c6 100644
--- a/parsers/logbooks.py
+++ b/parsers/logbooks.py
@@ -282,7 +282,7 @@ def LoadLogbookForExpedition(expedition):
""" Parses all logbook entries for one expedition """
expowebbase = os.path.join(settings.EXPOWEB, "years")
- year = str(expedition.year)
+ #year = str(expedition.year)
yearlinks = settings.LOGBOOK_PARSER_SETTINGS
logbook_parseable = False
@@ -311,50 +311,17 @@ def LoadLogbookForExpedition(expedition):
parser(expedition.year, expedition, txt)
SetDatesFromLogbookEntries(expedition)
- return "TOLOAD: " + year + " " + str(expedition.personexpedition_set.all()[1].logbookentry_set.count()) + " " + str(models.PersonTrip.objects.filter(personexpedition__expedition=expedition).count())
+ #return "TOLOAD: " + year + " " + str(expedition.personexpedition_set.all()[1].logbookentry_set.count()) + " " + str(models.PersonTrip.objects.filter(personexpedition__expedition=expedition).count())
def LoadLogbooks():
""" This is the master function for parsing all logbooks into the Troggle database. Requires yearlinks, which is a list of tuples for each expedition with expedition year, logbook path, and parsing function. """
-
- #Deletion has been moved to a seperate function to enable the non-destructive importing
- #models.LogbookEntry.objects.all().delete()
- expowebbase = os.path.join(settings.EXPOWEB, "years")
- #yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
- #yearlinks = [ ("1996", "1996/log.htm", Parseloghtml01),] # overwrite
-
- yearlinks = settings.LOGBOOK_PARSER_SETTINGS
expos = models.Expedition.objects.all()
for expo in expos:
print("\nLoading Logbook for: " + expo.year)
- logbook_parseable = False
-
- if expo.year in yearlinks:
- #print(yearlinks[expo.year])
- year_settings = yearlinks[expo.year]
- file_in = open(os.path.join(expowebbase, year_settings[0]))
- txt = file_in.read().decode("latin1")
- file_in.close()
- parsefunc = year_settings[1]
- logbook_parseable = True
- else:
- try:
- file_in = open(os.path.join(expowebbase, expo.year, settings.DEFAULT_LOGBOOK_FILE))
- txt = file_in.read().decode("latin1")
- file_in.close()
- logbook_parseable = True
- print("No set parser found using default")
- parsefunc = settings.DEFAULT_LOGBOOK_PARSER
- except (IOError):
- logbook_parseable = False
- print("Couldn't open default logbook file and nothing in settings for expo " + expo.year)
-
- if logbook_parseable:
- parser = globals()[parsefunc]
- parser(expo.year, expo, txt)
- SetDatesFromLogbookEntries(expo)
+ LoadLogbookForExpedition(expo)
dateRegex = re.compile(r'<span\s+class="date">(\d\d\d\d)-(\d\d)-(\d\d)</span>', re.S)
diff --git a/templates/expedition.html b/templates/expedition.html
index 318e07d..7c0ecd5 100644
--- a/templates/expedition.html
+++ b/templates/expedition.html
@@ -10,10 +10,6 @@
{% block content %}
-{% if message %}
-<p>debug message: {{message}}</p>
-{% endif %}
-
<h2>{{expedition.name}}</h2>
<p><b>Other years:</b>