diff --git a/calendarpush.py b/calendarpush.py index 331f82a5d1ca808c90417af82dde7139c9faeed2..07df22a934862e2231f5d85dd4f477689337a260 100644 --- a/calendarpush.py +++ b/calendarpush.py @@ -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): diff --git a/config.py.example b/config.py.example index fd0c4e334ab8cc816288f54c340a4e8a19ce5144..1125981b0b6538304da4e4072632a8377934ef31 100644 --- a/config.py.example +++ b/config.py.example @@ -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", diff --git a/server.py b/server.py index 8b07694c22b76e836ea7850b6ed296a3940ef66d..045e4c471e0606d832f3c919388f6faf01b662c3 100755 --- a/server.py +++ b/server.py @@ -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) diff --git a/views/forms.py b/views/forms.py index 0f7764e11d21710b12811e15f4f5aae125e00e9e..61bba4f069ecedf386d5c589c41389960562ed34 100644 --- a/views/forms.py +++ b/views/forms.py @@ -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