diff --git a/models/database.py b/models/database.py index c731dfa94949621b6947af4540d08a5b4ce71b2a..eee2db60687f30c93def96c8a0c46d464b97fcb6 100644 --- a/models/database.py +++ b/models/database.py @@ -170,7 +170,7 @@ class Protocol(DatabaseModel): def create_localtops(self): local_tops = [] for default_top in self.protocoltype.default_tops: - local_tops.append(LocalTOP(defaulttop_id=defaul_top.id, + local_tops.append(LocalTOP(defaulttop_id=default_top.id, protocol_id=self.id, description="")) return local_tops diff --git a/parser.py b/parser.py index bc14ef1511411150267275e1d7538dd9e062f663..9da40c77b66f8458f5869b1889170f513963c447 100644 --- a/parser.py +++ b/parser.py @@ -251,7 +251,11 @@ class Tag: # v1: matches [text without semicolons] #PATTERN = r"\[(?<content>(?:[^;\]]*;)*(?:[^;\]]*))\]" # v2: needs at least two parts separated by a semicolon - PATTERN = r"\[(?<content>(?:[^;\]]*;)+(?:[^;\]]*))\]" + #PATTERN = r"\[(?<content>(?:[^;\]]*;)+(?:[^;\]]*))\]" + # v3: also match [] without semicolons inbetween, as there is not other use for that + PATTERN = r"\[(?<content>[^\]]*)\]" + + KNOWN_TAGS = ["todo", "url", "beschluss"] class Empty(Element): @@ -514,7 +518,7 @@ def main(test_file_name=None): source = f.read() try: tree = parse(source) - tree.dump() + print(tree.dump()) except ParserException as e: print(e) else: diff --git a/server.py b/server.py index 9bb9361c3dee6d69a152dac8788df87c5e442409..f8a183a7567e49aac1f9710ef4d600312c4c9fbb 100755 --- a/server.py +++ b/server.py @@ -477,7 +477,7 @@ def new_protocol(): form.populate_obj(protocol) db.session.add(protocol) db.session.commit() - for local_top in protocol.create_localtops: + for local_top in protocol.create_localtops(): db.session.add(local_top) db.session.commit() tasks.push_tops_to_calendar(protocol) diff --git a/shared.py b/shared.py index 6492f4a2208cad78eb4ea2b63614b155a0a16729..c2aeaaa48d860f9bf29e46af3074441b81fb1735 100644 --- a/shared.py +++ b/shared.py @@ -18,8 +18,8 @@ latex_chars = [ ('_', '\\_'), ('{', '\\{'), ('}', '\\}'), - #('[', '\\['), - #(']', '\\]'), + ('[', '\\['), + (']', '\\]'), #('"', '"\''), ('~', r'$\sim{}$'), ('^', r'\textasciicircum{}'), diff --git a/tasks.py b/tasks.py index 14f99edf0549c7e243ac606c4c35972f0a4be8ae..3a4dce3bbe6f8f2cdf5ec74ceab87c3625fe7f02 100644 --- a/tasks.py +++ b/tasks.py @@ -148,6 +148,17 @@ def parse_protocol_async_inner(protocol, encoded_kwargs): db.session.add(error) db.session.commit() return + # tags + tags = tree.get_tags() + for tag in tags: + if tag.name not in Tag.KNOWN_TAGS: + error = protocol.create_error("Parsing", "Invalid tag", + "The tag in line {} has the kind '{}', which is " + "not defined. This is probably an error mit a missing " + "semicolon.".format(tag.linenumber, tag.name)) + db.session.add(error) + db.session.commit() + return # todos old_todo_number_map = {} for todo in protocol.todos: @@ -158,14 +169,14 @@ def parse_protocol_async_inner(protocol, encoded_kwargs): for todo in old_todos: protocol.todos.remove(todo) db.session.commit() - tags = tree.get_tags() todo_tags = [tag for tag in tags if tag.name == "todo"] for todo_tag in todo_tags: if len(todo_tag.values) < 2: error = protocol.create_error("Parsing", "Invalid todo-tag", "The todo tag in line {} needs at least " "information on who and what, " - "but has less than that.".format(todo_tag.linenumber)) + "but has less than that. This is probably " + "a missing semicolon.".format(todo_tag.linenumber)) db.session.add(error) db.session.commit() return