Commit f825a887 authored by Administrator's avatar Administrator
Browse files

Fix small bugs

parent d37612e8
......@@ -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
......
......@@ -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])
......
......@@ -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):
......
......@@ -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)
......
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}}
......
......@@ -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):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment