diff options
author | Sam Wenham <sam@wenhams.co.uk> | 2019-04-14 22:45:31 +0100 |
---|---|---|
committer | Sam Wenham <sam@wenhams.co.uk> | 2019-04-14 22:45:31 +0100 |
commit | 23df89cf319f05cbad4cb769c05c5699fe9d3f4a (patch) | |
tree | b2fdc953496cd2fd0b7c75fdf4e65a022b730581 /parsers/caves.py | |
parent | d1d0c24ed8864e88f1f6e74c5ac5776fdeaf6f5a (diff) | |
download | troggle-23df89cf319f05cbad4cb769c05c5699fe9d3f4a.tar.gz troggle-23df89cf319f05cbad4cb769c05c5699fe9d3f4a.tar.bz2 troggle-23df89cf319f05cbad4cb769c05c5699fe9d3f4a.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/caves.py')
-rw-r--r-- | parsers/caves.py | 21 |
1 files changed, 13 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 |