Skip to content
Snippets Groups Projects
Commit f825a887 authored by Administrator's avatar Administrator
Browse files

Fix small bugs

parent d37612e8
Branches
No related tags found
No related merge requests found
...@@ -41,7 +41,8 @@ class LdapManager: ...@@ -41,7 +41,8 @@ class LdapManager:
def groups(self, username): def groups(self, username):
result = [] 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]) result.append(result_dict["cn"][0])
return result return result
......
...@@ -7,11 +7,6 @@ from shared import db ...@@ -7,11 +7,6 @@ from shared import db
import config 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): def lookup_todo_id(old_candidates, new_who, new_description):
# Check for perfect matches # Check for perfect matches
for candidate in old_candidates: for candidate in old_candidates:
...@@ -29,11 +24,11 @@ def lookup_todo_id(old_candidates, new_who, new_description): ...@@ -29,11 +24,11 @@ def lookup_todo_id(old_candidates, new_who, new_description):
best_match, best_match_score = process.extractOne( best_match, best_match_score = process.extractOne(
new_description, content_to_number.keys()) new_description, content_to_number.keys())
if best_match_score >= config.FUZZY_MIN_SCORE: 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)) new_description, best_match, best_match_score))
return content_to_number[best_match] return content_to_number[best_match]
else: 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)) new_description, best_match, best_match_score))
return None return None
...@@ -122,7 +117,7 @@ def import_old_todos(sql_text): ...@@ -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): for old_id, protocol_id, who, what, start_time, end_time, done in _split_insert_line(todo_line):
protocol_id = int(protocol_id) protocol_id = int(protocol_id)
if protocol_id not in protocol_id_to_key: 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 continue
todo = OldTodo(old_id=old_id, who=who, description=what, todo = OldTodo(old_id=old_id, who=who, description=what,
protocol_key=protocol_id_to_key[protocol_id]) protocol_key=protocol_id_to_key[protocol_id])
......
...@@ -89,6 +89,9 @@ class ProtocolType(db.Model): ...@@ -89,6 +89,9 @@ class ProtocolType(db.Model):
or (self.private_group != "" and self.private_group in user.groups)))) or (self.private_group != "" and self.private_group in user.groups))))
def has_private_view_right(self, user): 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) return (user is not None and self.private_group != "" and self.private_group in user.groups)
def has_modify_right(self, user): def has_modify_right(self, user):
......
...@@ -379,6 +379,7 @@ def compile_async(content, protocol_id, show_private=False, use_decision=False, ...@@ -379,6 +379,7 @@ def compile_async(content, protocol_id, show_private=False, use_decision=False,
document.filename = target_filename document.filename = target_filename
shutil.copy(os.path.join(compile_dir, protocol_target_filename), os.path.join(config.DOCUMENTS_PATH, target_filename)) shutil.copy(os.path.join(compile_dir, protocol_target_filename), os.path.join(config.DOCUMENTS_PATH, target_filename))
db.session.commit() db.session.commit()
shutil.copy(os.path.join(compile_dir, log_filename), "/tmp/proto-tex.log")
except subprocess.SubprocessError: except subprocess.SubprocessError:
log = "" log = ""
total_log_filename = os.path.join(compile_dir, log_filename) total_log_filename = os.path.join(compile_dir, log_filename)
......
Protocol der {{protocol.name}} vom {{protocol.date|datify}} Protocol der {{protocol.name}} vom {{protocol.date|datify}}
Datum: {{protocol.date|datify_long}} 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}} Zeit: von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}
{% endif %}
Protokoll: {{protocol.author}} Protokoll: {{protocol.author}}
Anwesende: {{protocol.participants}} Anwesende: {{protocol.participants}}
......
...@@ -78,9 +78,13 @@ class ProtocolsTable(Table): ...@@ -78,9 +78,13 @@ class ProtocolsTable(Table):
result.append("Fertig" if protocol.is_done() else "Geplant") result.append("Fertig" if protocol.is_done() else "Geplant")
elif protocol in self.search_results: elif protocol in self.search_results:
result.append(Markup(self.search_results[protocol])) result.append(Markup(self.search_results[protocol]))
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): 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("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()))) 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 return result
class ProtocolTypesTable(Table): class ProtocolTypesTable(Table):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment