Commit de4fe2d3 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Fixed minor errors

parent 74811e3d
......@@ -13,6 +13,8 @@ class CalendarException(Exception):
class Client:
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.client = DAVClient(self.url)
self.principal = None
......@@ -20,10 +22,10 @@ class Client:
try:
self.principal = self.client.principal()
break
except PropfindError as exc:
print(exc)
except Exception as exc:
print("Got exception {} from caldav, retrying".format(str(exc)))
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:
self.calendar = self.get_calendar(calendar)
else:
......@@ -38,9 +40,9 @@ class Client:
calendar.name
for calendar in self.principal.calendars()
]
except PropfindError as exc:
print(exc)
raise CalendarException("Got {} PropfindErrors from the CalDAV server.".format(config.CALENDAR_MAX_REQUESTS))
except Exception as exc:
print("Got exception {} from caldav, retrying".format(str(exc)))
raise CalendarException("Got {} CalDAV Errors from the CalDAV server.".format(config.CALENDAR_MAX_REQUESTS))
def get_calendar(self, calendar_name):
......
......@@ -61,6 +61,7 @@ WIKI_DOMAIN = "domain" # set to None if not necessary
CALENDAR_ACTIVE = True
CALENDAR_URL = "https://user:password@calendar.example.com/dav/"
CALENDAR_DEFAULT_DURATION = 3 # default meeting length in hours
CALENDAR_MAX_REQUESTS = 10
SESSION_PROTECTION = "strong" # do not change
......@@ -122,6 +123,7 @@ DOCUMENTS_PATH = "documents"
# keywords indicating private protocol parts
PRIVATE_KEYWORDS = ["private", "internal", "privat", "intern"]
# list of bulletpoints to use in latex
LATEX_BULLETPOINTS = [
r"\textbullet",
r"\normalfont \bfseries \textendash",
......
......@@ -49,7 +49,7 @@ def make_scheduler(app, config, function):
scheduler.start()
scheduler.add_job(
func=function,
trigger=CronTrigger(hour='*'),
trigger=CronTrigger(hour='*', minute=30),
id="scheduler",
name="Do an action regularly",
replace_existing=True)
......
......@@ -25,12 +25,17 @@ def get_todostate_choices():
for state in TodoState
]
def get_calendar_choices():
def get_calendar_choices(protocoltype=None):
calendars = CalendarClient().get_calendars()
choices = []
if calendars is not None:
calendars = sorted(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"))
return choices
......@@ -77,7 +82,8 @@ class ProtocolTypeForm(FlaskForm):
def __init__(self, **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()
group_choices = get_group_choices()
self.modify_group.choices = group_choices
......
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