improve error messages
This commit is contained in:
parent
e02caa06d9
commit
cc3ede4ed5
@ -12,18 +12,36 @@ class EventsImporter:
|
||||
|
||||
try:
|
||||
structure = json.loads(json_structure)
|
||||
|
||||
self.url = structure["header"]["url"]
|
||||
self.date = structure["header"]["date"]
|
||||
except:
|
||||
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
|
||||
for event in structure["events"]:
|
||||
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):
|
||||
# TODO
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user