Commit 32f6cef7 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

README and correct coercing for todostates

parent 1023b45a
# Protokollsystem 3
System zur Verwaltung von Protokollen und Sitzungen.
* Planung der Tagesordnung
* Einladungsmails
* Kompilieren vom Protokollquelltext
* PDF-Protokoll mit LaTeX
* Protokollversand samt Anhang
* automatisches Hochladen ins Wiki
* Etherpadanbindung
* Todoverwaltung mit mehr Zuständen
* Beschlussverwaltung
* Rechteverwaltung (interne Abschnitte)
* Hochladen der Tagesordnung in einen Kalender
* externe Protokolle ohne Protokollsyntax
......@@ -5,7 +5,7 @@ import math
from io import StringIO, BytesIO
from enum import Enum
from shared import db, date_filter, escape_tex, DATE_KEY, START_TIME_KEY, END_TIME_KEY, AUTHOR_KEY, PARTICIPANTS_KEY, LOCATION_KEY
from shared import db, date_filter, date_filter_short, escape_tex, DATE_KEY, START_TIME_KEY, END_TIME_KEY, AUTHOR_KEY, PARTICIPANTS_KEY, LOCATION_KEY
from utils import random_string, url_manager, get_etherpad_url, split_terms
from models.errors import DateNotMatchingException
......@@ -411,6 +411,11 @@ class Todo(db.Model):
self.id, self.number, self.who, self.description, self.state, self.date)
def is_done(self):
if self.state.needs_date():
if self.state == TodoState.after:
return datetime.now().date() >= self.date
elif self.state == TodoState.before:
return datetime.now().date() <= self.date
return self.state.is_done()
def get_id(self):
......@@ -433,7 +438,7 @@ class Todo(db.Model):
def get_state_plain(self):
result = self.state.get_name()
if self.state.needs_date():
result = "{} {}".format(result, date_filter(self.state.date))
result = "{} {}".format(result, date_filter_short(self.date))
return result
def get_state_tex(self):
return self.get_state_plain()
......
......@@ -16,7 +16,7 @@ def get_protocoltype_choices(protocoltypes, add_all=True):
def get_todostate_choices():
return [
(state.value, state.get_name())
(state, state.get_name())
for state in TodoState
]
......@@ -26,6 +26,12 @@ def get_calendar_choices():
for calendar in CalendarClient().get_calendars()
]
def coerce_todostate(key):
if isinstance(key, str):
class_part, key_part = key.split(".")
key = TodoState[key_part]
return key
class LoginForm(FlaskForm):
username = StringField("Benutzer", validators=[InputRequired("Bitte gib deinen Benutzernamen ein.")])
password = PasswordField("Passwort", validators=[InputRequired("Bitte gib dein Passwort ein.")])
......@@ -44,7 +50,11 @@ class ProtocolTypeForm(FlaskForm):
use_wiki = BooleanField("Wiki benutzen")
wiki_only_public = BooleanField("Wiki ist öffentlich")
printer = SelectField("Drucker", choices=list(zip(config.PRINTING_PRINTERS, config.PRINTING_PRINTERS)))
calendar = SelectField("Kalender", choices=get_calendar_choices())
calendar = SelectField("Kalender", choices=[])
def __init__(self, **kwargs):
super().__init__(self, **kwargs)
self.calendar.choices = get_calendar_choices()
class DefaultTopForm(FlaskForm):
name = StringField("Name", validators=[InputRequired("Du musst einen Namen angeben.")])
......@@ -124,10 +134,11 @@ class NewTodoForm(FlaskForm):
class TodoForm(FlaskForm):
who = StringField("Person")
description = StringField("Aufgabe", validators=[InputRequired("Bitte gib an, was erledigt werden soll.")])
state = SelectField("Status", choices=[], coerce=int, validators=[CheckTodoDateByState()])
state = SelectField("Status", choices=[], coerce=coerce_todostate, validators=[CheckTodoDateByState()])
date = DateField("Datum", format="%d.%m.%Y", validators=[Optional()])
def __init__(self):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.state.choices = get_todostate_choices()
class TodoMailForm(FlaskForm):
......
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