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
This commit is contained in:
Sam Wenham
2019-04-14 22:45:31 +01:00
parent d1d0c24ed8
commit 23df89cf31
8 changed files with 37 additions and 15 deletions

View File

@@ -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