improve error messages
This commit is contained in:
parent
e02caa06d9
commit
cc3ede4ed5
@ -12,18 +12,36 @@ class EventsImporter:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
structure = json.loads(json_structure)
|
structure = json.loads(json_structure)
|
||||||
|
|
||||||
self.url = structure["header"]["url"]
|
|
||||||
self.date = structure["header"]["date"]
|
|
||||||
except:
|
except:
|
||||||
return (False, "JSON file is not correctly structured")
|
return (False, "JSON file is not correctly structured")
|
||||||
|
|
||||||
|
if not "header" in structure:
|
||||||
|
return (False, "JSON is not correctly structured: missing header")
|
||||||
|
|
||||||
|
if "url" in structure["header"]:
|
||||||
|
self.url = structure["header"]["url"]
|
||||||
|
else:
|
||||||
|
return (False, "JSON is not correctly structured: missing url in header")
|
||||||
|
|
||||||
|
if "url" in structure["header"]:
|
||||||
|
self.date = structure["header"]["date"]
|
||||||
|
|
||||||
# load events
|
# load events
|
||||||
for event in structure["events"]:
|
for event in structure["events"]:
|
||||||
self.import_event(event)
|
self.import_event(event)
|
||||||
|
|
||||||
|
# update object with infos from header, and with the list of imported objects
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# events that are missing from the import but in database are turned into drafts
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
return (True, "")
|
||||||
|
|
||||||
|
|
||||||
def import_event(self, event):
|
def import_event(self, event):
|
||||||
|
# TODO
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user