Skip to content
Snippets Groups Projects
Commit de4fe2d3 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Fixed minor errors

parent 74811e3d
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,8 @@ class CalendarException(Exception): ...@@ -13,6 +13,8 @@ class CalendarException(Exception):
class Client: class Client:
def __init__(self, calendar=None, url=None): def __init__(self, calendar=None, url=None):
if not config.CALENDAR_ACTIVE:
return
self.url = url if url is not None else config.CALENDAR_URL self.url = url if url is not None else config.CALENDAR_URL
self.client = DAVClient(self.url) self.client = DAVClient(self.url)
self.principal = None self.principal = None
...@@ -20,10 +22,10 @@ class Client: ...@@ -20,10 +22,10 @@ class Client:
try: try:
self.principal = self.client.principal() self.principal = self.client.principal()
break break
except PropfindError as exc: except Exception as exc:
print(exc) print("Got exception {} from caldav, retrying".format(str(exc)))
if self.principal is None: if self.principal is None:
raise CalendarException("Got {} PropfindErrors from the CalDAV server.".format(config.CALENDAR_MAX_REQUESTS)) raise CalendarException("Got {} CalDAV-error from the CalDAV server.".format(config.CALENDAR_MAX_REQUESTS))
if calendar is not None: if calendar is not None:
self.calendar = self.get_calendar(calendar) self.calendar = self.get_calendar(calendar)
else: else:
...@@ -38,9 +40,9 @@ class Client: ...@@ -38,9 +40,9 @@ class Client:
calendar.name calendar.name
for calendar in self.principal.calendars() for calendar in self.principal.calendars()
] ]
except PropfindError as exc: except Exception as exc:
print(exc) print("Got exception {} from caldav, retrying".format(str(exc)))
raise CalendarException("Got {} PropfindErrors from the CalDAV server.".format(config.CALENDAR_MAX_REQUESTS)) raise CalendarException("Got {} CalDAV Errors from the CalDAV server.".format(config.CALENDAR_MAX_REQUESTS))
def get_calendar(self, calendar_name): def get_calendar(self, calendar_name):
......
...@@ -61,6 +61,7 @@ WIKI_DOMAIN = "domain" # set to None if not necessary ...@@ -61,6 +61,7 @@ WIKI_DOMAIN = "domain" # set to None if not necessary
CALENDAR_ACTIVE = True CALENDAR_ACTIVE = True
CALENDAR_URL = "https://user:password@calendar.example.com/dav/" CALENDAR_URL = "https://user:password@calendar.example.com/dav/"
CALENDAR_DEFAULT_DURATION = 3 # default meeting length in hours CALENDAR_DEFAULT_DURATION = 3 # default meeting length in hours
CALENDAR_MAX_REQUESTS = 10
SESSION_PROTECTION = "strong" # do not change SESSION_PROTECTION = "strong" # do not change
...@@ -122,6 +123,7 @@ DOCUMENTS_PATH = "documents" ...@@ -122,6 +123,7 @@ DOCUMENTS_PATH = "documents"
# keywords indicating private protocol parts # keywords indicating private protocol parts
PRIVATE_KEYWORDS = ["private", "internal", "privat", "intern"] PRIVATE_KEYWORDS = ["private", "internal", "privat", "intern"]
# list of bulletpoints to use in latex
LATEX_BULLETPOINTS = [ LATEX_BULLETPOINTS = [
r"\textbullet", r"\textbullet",
r"\normalfont \bfseries \textendash", r"\normalfont \bfseries \textendash",
......
...@@ -49,7 +49,7 @@ def make_scheduler(app, config, function): ...@@ -49,7 +49,7 @@ def make_scheduler(app, config, function):
scheduler.start() scheduler.start()
scheduler.add_job( scheduler.add_job(
func=function, func=function,
trigger=CronTrigger(hour='*'), trigger=CronTrigger(hour='*', minute=30),
id="scheduler", id="scheduler",
name="Do an action regularly", name="Do an action regularly",
replace_existing=True) replace_existing=True)
......
...@@ -25,12 +25,17 @@ def get_todostate_choices(): ...@@ -25,12 +25,17 @@ def get_todostate_choices():
for state in TodoState for state in TodoState
] ]
def get_calendar_choices(): def get_calendar_choices(protocoltype=None):
calendars = CalendarClient().get_calendars() calendars = CalendarClient().get_calendars()
choices = [] choices = []
if calendars is not None: if calendars is not None:
calendars = sorted(calendars) calendars = sorted(calendars)
choices = list(zip(calendars, calendars)) choices = list(zip(calendars, calendars))
else:
if (protocoltype is not None
and protocoltype.calendar is not None
and protocoltype.calendar != ""):
choices.append((protocoltype.calendar, protocoltype.calendar))
choices.insert(0, ("", "Kein Kalender")) choices.insert(0, ("", "Kein Kalender"))
return choices return choices
...@@ -77,7 +82,8 @@ class ProtocolTypeForm(FlaskForm): ...@@ -77,7 +82,8 @@ class ProtocolTypeForm(FlaskForm):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
self.calendar.choices = get_calendar_choices() protocoltype = kwargs["obj"] if "obj" in kwargs else None
self.calendar.choices = get_calendar_choices(protocoltype=protocoltype)
self.printer.choices = get_printer_choices() self.printer.choices = get_printer_choices()
group_choices = get_group_choices() group_choices = get_group_choices()
self.modify_group.choices = group_choices self.modify_group.choices = group_choices
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment