From f825a887428031333cbca48f2b0ed20cc83d66d5 Mon Sep 17 00:00:00 2001 From: FSMPI Admin-Team <admin@fsmpi.rwth-aachen.de> Date: Fri, 3 Mar 2017 21:13:24 +0100 Subject: [PATCH] Fix small bugs --- auth.py | 3 ++- legacy.py | 11 +++-------- models/database.py | 3 +++ tasks.py | 1 + templates/protocol-mail.txt | 2 ++ views/tables.py | 10 +++++++--- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/auth.py b/auth.py index 23d5a15..d5e7faa 100644 --- a/auth.py +++ b/auth.py @@ -41,7 +41,8 @@ class LdapManager: def groups(self, username): result = [] - for _, result_dict in self.connection.search_s(self.base, ldap.SCOPE_SUBTREE, "(memberUid={})".format(username), ["cn"]): + # use username.lower() since memberUid is case sensitive here + for _, result_dict in self.connection.search_s(self.base, ldap.SCOPE_SUBTREE, "(memberUid={})".format(username.lower()), ["cn"]): result.append(result_dict["cn"][0]) return result diff --git a/legacy.py b/legacy.py index 9127450..2b7c5ca 100644 --- a/legacy.py +++ b/legacy.py @@ -7,11 +7,6 @@ from shared import db import config -def log_fuzzy(text): - #with tempfile.NamedTemporaryFile(delete=False, mode="w") as tmpfile: - # tmpfile.write(text + "\n\n") - print(text) - def lookup_todo_id(old_candidates, new_who, new_description): # Check for perfect matches for candidate in old_candidates: @@ -29,11 +24,11 @@ def lookup_todo_id(old_candidates, new_who, new_description): best_match, best_match_score = process.extractOne( new_description, content_to_number.keys()) if best_match_score >= config.FUZZY_MIN_SCORE: - log_fuzzy("Used fuzzy matching on '{}', got '{}' with score {}.".format( + print("Used fuzzy matching on '{}', got '{}' with score {}.".format( new_description, best_match, best_match_score)) return content_to_number[best_match] else: - log_fuzzy("Best match for '{}' is '{}' with score {}, rejecting.".format( + print("Best match for '{}' is '{}' with score {}, rejecting.".format( new_description, best_match, best_match_score)) return None @@ -122,7 +117,7 @@ def import_old_todos(sql_text): for old_id, protocol_id, who, what, start_time, end_time, done in _split_insert_line(todo_line): protocol_id = int(protocol_id) if protocol_id not in protocol_id_to_key: - #print("Missing protocol with ID {} for Todo {}".format(protocol_id, what)) + print("Missing protocol with ID {} for Todo {}".format(protocol_id, what)) continue todo = OldTodo(old_id=old_id, who=who, description=what, protocol_key=protocol_id_to_key[protocol_id]) diff --git a/models/database.py b/models/database.py index 102a63d..ef496f5 100644 --- a/models/database.py +++ b/models/database.py @@ -89,6 +89,9 @@ class ProtocolType(db.Model): or (self.private_group != "" and self.private_group in user.groups)))) def has_private_view_right(self, user): + print(user, self.private_group) + if user is not None: + print(user.groups) return (user is not None and self.private_group != "" and self.private_group in user.groups) def has_modify_right(self, user): diff --git a/tasks.py b/tasks.py index d52a173..64000d7 100644 --- a/tasks.py +++ b/tasks.py @@ -379,6 +379,7 @@ def compile_async(content, protocol_id, show_private=False, use_decision=False, document.filename = target_filename shutil.copy(os.path.join(compile_dir, protocol_target_filename), os.path.join(config.DOCUMENTS_PATH, target_filename)) db.session.commit() + shutil.copy(os.path.join(compile_dir, log_filename), "/tmp/proto-tex.log") except subprocess.SubprocessError: log = "" total_log_filename = os.path.join(compile_dir, log_filename) diff --git a/templates/protocol-mail.txt b/templates/protocol-mail.txt index c1e4a51..12e2529 100644 --- a/templates/protocol-mail.txt +++ b/templates/protocol-mail.txt @@ -1,7 +1,9 @@ Protocol der {{protocol.name}} vom {{protocol.date|datify}} Datum: {{protocol.date|datify_long}} +{% if protocol.start_time is not none and protocol.end_time is not none %} Zeit: von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}} +{% endif %} Protokoll: {{protocol.author}} Anwesende: {{protocol.participants}} diff --git a/views/tables.py b/views/tables.py index 9599273..682aa92 100644 --- a/views/tables.py +++ b/views/tables.py @@ -78,9 +78,13 @@ class ProtocolsTable(Table): result.append("Fertig" if protocol.is_done() else "Geplant") elif protocol in self.search_results: result.append(Markup(self.search_results[protocol])) - if user is not None and protocol.protocoltype.has_private_view_right(user): - result.append(Table.link(url_for("show_type", type_id=protocol.protocoltype.id), protocol.protocoltype.short_name)) - result.append(Table.link(url_for("delete_protocol", protocol_id=protocol.id), "Löschen", confirm="Bist du dir sicher, dass du das Protokoll {} löschen möchtest?".format(protocol.get_identifier()))) + print(user, protocol.protocoltype.has_private_view_right(user)) + if check_login(): + if user is not None and protocol.protocoltype.has_private_view_right(user): + result.append(Table.link(url_for("show_type", type_id=protocol.protocoltype.id), protocol.protocoltype.short_name)) + result.append(Table.link(url_for("delete_protocol", protocol_id=protocol.id), "Löschen", confirm="Bist du dir sicher, dass du das Protokoll {} löschen möchtest?".format(protocol.get_identifier()))) + else: + result.extend(["", ""]) return result class ProtocolTypesTable(Table): -- GitLab