summaryrefslogtreecommitdiffstats
path: root/parsers
diff options
context:
space:
mode:
authorSam Wenham <sam@wenhams.co.uk>2019-04-14 22:45:31 +0100
committerSam Wenham <sam@wenhams.co.uk>2019-04-14 22:45:31 +0100
commitf1736c53c4142c9243d5e57d77a5d7a8d62c475b (patch)
treeb2fdc953496cd2fd0b7c75fdf4e65a022b730581 /parsers
parent05c5e26e9991fb3e753759c50bc1f29e3592704e (diff)
downloadtroggle-f1736c53c4142c9243d5e57d77a5d7a8d62c475b.tar.gz
troggle-f1736c53c4142c9243d5e57d77a5d7a8d62c475b.tar.bz2
troggle-f1736c53c4142c9243d5e57d77a5d7a8d62c475b.zip
Fix CSRF issues in svx form
Set date formats Add DataIssue model and add errors to it to allow us to give people a list of stuff to fix
Diffstat (limited to 'parsers')
-rw-r--r--parsers/caves.py21
-rw-r--r--parsers/logbooks.py6
2 files changed, 19 insertions, 8 deletions
diff --git a/parsers/caves.py b/parsers/caves.py
index ba1c358..2c28365 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -6,10 +6,10 @@ import re
def readcaves():
- newArea = models.Area(short_name = "1623", parent = None)
- newArea.save()
- newArea = models.Area(short_name = "1626", parent = None)
- newArea.save()
+ area_1623 = models.Area(short_name = "1623", parent = None)
+ area_1623.save()
+ area_1626 = models.Area(short_name = "1626", parent = None)
+ area_1626.save()
print("Reading Entrances")
#print "list of <Slug> <Filename>"
for filename in os.walk(settings.ENTRANCEDESCRIPTIONS).next()[2]: #Should be a better way of getting a list of files
@@ -171,11 +171,16 @@ def readcave(filename):
def getXML(text, itemname, minItems = 1, maxItems = None, printwarnings = True, context = ""):
items = re.findall("<%(itemname)s>(.*?)</%(itemname)s>" % {"itemname": itemname}, text, re.S)
if len(items) < minItems and printwarnings:
- print("%(count)i %(itemname)s found, at least %(min)i expected" % {"count": len(items),
+ message = "%(count)i %(itemname)s found, at least %(min)i expected" % {"count": len(items),
"itemname": itemname,
- "min": minItems} + context)
+ "min": minItems} + context
+ models.DataIssue.objects.create(parser='caves', message=message)
+ print(message)
+
if maxItems is not None and len(items) > maxItems and printwarnings:
- print("%(count)i %(itemname)s found, no more than %(max)i expected" % {"count": len(items),
+ message = "%(count)i %(itemname)s found, no more than %(max)i expected" % {"count": len(items),
"itemname": itemname,
- "max": maxItems} + context)
+ "max": maxItems} + context
+ models.DataIssue.objects.create(parser='caves', message=message)
+ print(message)
return items
diff --git a/parsers/logbooks.py b/parsers/logbooks.py
index 2d1875a..bf6081f 100644
--- a/parsers/logbooks.py
+++ b/parsers/logbooks.py
@@ -7,6 +7,8 @@ from parsers.people import GetPersonExpeditionNameLookup
from parsers.cavetab import GetCaveLookup
from django.template.defaultfilters import slugify
+from django.utils.timezone import get_current_timezone
+from django.utils.timezone import make_aware
import csv
import re
@@ -36,6 +38,8 @@ def GetTripPersons(trippeople, expedition, logtime_underground):
personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower())
if not personyear:
print(" - No name match for: '%s'" % tripperson)
+ message = "No name match for: '%s' in year '%s'" % (tripperson, expedition.year)
+ models.DataIssue.objects.create(parser='logbooks', message=message)
res.append((personyear, logtime_underground))
if mul:
author = personyear
@@ -79,6 +83,8 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
trippersons, author = GetTripPersons(trippeople, expedition, logtime_underground)
if not author:
print(" - Skipping logentry: " + title + " - no author for entry")
+ message = "Skipping logentry: %s - no author for entry in year '%s'" % (title, expedition.year)
+ models.DataIssue.objects.create(parser='logbooks', message=message)
return
#tripCave = GetTripCave(place)