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

View File

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