# Path: sipa/backends/extension.py
# def evaluates_uniquely(objects, func) -> bool:
#     def __init__(self):
#     def init_app(self, app: Flask):
#     def register(self, datasource: DataSource):
#     def _activate_datasource(self, name: str):
#     def _register_dormitory(self, dormitory: Dormitory):
#     def pre_init_hook(self) -> Callable[[Callable], Callable]:  # Decorators are fun :-)
#         def decorator(f):
#     def init_backends(self):
#     def datasources(self) -> List[DataSource]:
#     def dormitories(self) -> List[Dormitory]:
#     def all_dormitories(self) -> List[Dormitory]:
#     def dormitories_short(self) -> List[_dorm_summary]:
#     def supported_dormitories_short(self) -> List[_dorm_summary]:
#     def get_dormitory(self, name: str) -> Optional[Dormitory]:
#     def get_first_dormitory(self) -> Optional[Dormitory]:
#     def get_datasource(self, name: str) -> Optional[DataSource]:
#     def dormitory_from_ip(self, ip: str) -> Optional[Dormitory]:
#     def preferred_dormitory_name(self) -> Optional[str]:
#     def user_from_ip(self, ip: str) -> Optional[UserLike]:
#     def current_dormitory(self) -> Optional[Dormitory]:
#     def current_datasource(self) -> Optional[DataSource]:
# class Backends:


import re
from datetime import date
from operator import itemgetter
from flask_babel import gettext, lazy_gettext
from flask import flash
from flask_login import current_user
from flask_wtf import FlaskForm
from werkzeug.local import LocalProxy
from wtforms import (BooleanField, HiddenField, PasswordField, SelectField,
                     StringField, TextAreaField, RadioField, IntegerField, DateField, SubmitField)
from wtforms.validators import (AnyOf, DataRequired, Email, EqualTo, InputRequired,
                                Regexp, ValidationError, NumberRange, Optional, Length)
from sipa.backends.extension import backends, _dorm_summary
    # This field must not be filled out to submit the form.
    # We're using 'website' as the field-name since we won't give bots a hint.
    website = SpamCheckField(label="", validators=[Length(0, 0, "You seem to like honey.")])


class ContactForm(SpamProtectedForm):
    email = EmailField(label=lazy_gettext("Deine E-Mail-Adresse"))
    type = SelectField(label=lazy_gettext("Kategorie"), choices=[
        ("frage", lazy_gettext("Allgemeine Fragen")),
        ("stoerung", lazy_gettext("Störung im Netzwerk")),
        ("finanzen", lazy_gettext("Finanzfragen (Beiträge, Gebühren)")),
        ("eigene-technik", lazy_gettext("Probleme mit privater Technik"))
    ])
    subject = StrippedStringField(label=lazy_gettext("Betreff"), validators=[
        DataRequired(lazy_gettext("Betreff muss angegeben werden!"))])
    message = TextAreaField(label=lazy_gettext("Nachricht"), validators=[
        DataRequired(lazy_gettext("Nachricht fehlt!"))
    ])


class AnonymousContactForm(SpamProtectedForm):
    email = EmailField(label=lazy_gettext("Deine E-Mail-Adresse"))
    name = StringField(
        label=lazy_gettext("Dein Name"),
        validators=[DataRequired(lazy_gettext("Bitte gib einen Namen an!"))],
    )
    dormitory = SelectField(
        label=lazy_gettext("Wohnheim"),
        # TODO set dormitory.choices in view function
        # choices=LocalProxy(lambda: backends.dormitories_short),

# Path: sipa/backends/extension.py
# def evaluates_uniquely(objects, func) -> bool:
#     def __init__(self):
#     def init_app(self, app: Flask):
#     def register(self, datasource: DataSource):
#     def _activate_datasource(self, name: str):
#     def _register_dormitory(self, dormitory: Dormitory):
#     def pre_init_hook(self) -> Callable[[Callable], Callable]:  # Decorators are fun :-)
#         def decorator(f):
#     def init_backends(self):
#     def datasources(self) -> List[DataSource]:
#     def dormitories(self) -> List[Dormitory]:
#     def all_dormitories(self) -> List[Dormitory]:
#     def dormitories_short(self) -> List[_dorm_summary]:
#     def supported_dormitories_short(self) -> List[_dorm_summary]:
#     def get_dormitory(self, name: str) -> Optional[Dormitory]:
#     def get_first_dormitory(self) -> Optional[Dormitory]:
#     def get_datasource(self, name: str) -> Optional[DataSource]:
#     def dormitory_from_ip(self, ip: str) -> Optional[Dormitory]:
#     def preferred_dormitory_name(self) -> Optional[str]:
#     def user_from_ip(self, ip: str) -> Optional[UserLike]:
#     def current_dormitory(self) -> Optional[Dormitory]:
#     def current_datasource(self) -> Optional[DataSource]:
# class Backends:


# Path: sipa/forms.py
import re
from datetime import date
from operator import itemgetter
from flask_babel import gettext, lazy_gettext
from flask import flash
from flask_login import current_user
from flask_wtf import FlaskForm
from werkzeug.local import LocalProxy
from wtforms import (BooleanField, HiddenField, PasswordField, SelectField,
                     StringField, TextAreaField, RadioField, IntegerField, DateField, SubmitField)
from wtforms.validators import (AnyOf, DataRequired, Email, EqualTo, InputRequired,
                                Regexp, ValidationError, NumberRange, Optional, Length)
from sipa.backends.extension import backends, _dorm_summary

    # This field must not be filled out to submit the form.
    # We're using 'website' as the field-name since we won't give bots a hint.
    website = SpamCheckField(label="", validators=[Length(0, 0, "You seem to like honey.")])


class ContactForm(SpamProtectedForm):
    email = EmailField(label=lazy_gettext("Deine E-Mail-Adresse"))
    type = SelectField(label=lazy_gettext("Kategorie"), choices=[
        ("frage", lazy_gettext("Allgemeine Fragen")),
        ("stoerung", lazy_gettext("Störung im Netzwerk")),
        ("finanzen", lazy_gettext("Finanzfragen (Beiträge, Gebühren)")),
        ("eigene-technik", lazy_gettext("Probleme mit privater Technik"))
    ])
    subject = StrippedStringField(label=lazy_gettext("Betreff"), validators=[
        DataRequired(lazy_gettext("Betreff muss angegeben werden!"))])
    message = TextAreaField(label=lazy_gettext("Nachricht"), validators=[
        DataRequired(lazy_gettext("Nachricht fehlt!"))
    ])


class AnonymousContactForm(SpamProtectedForm):
    email = EmailField(label=lazy_gettext("Deine E-Mail-Adresse"))
    name = StringField(
        label=lazy_gettext("Dein Name"),
        validators=[DataRequired(lazy_gettext("Bitte gib einen Namen an!"))],
    )
    dormitory = SelectField(
        label=lazy_gettext("Wohnheim"),
        # TODO set dormitory.choices in view function
        # choices=LocalProxy(lambda: backends.dormitories_short),

        default=LocalProxy(lambda: backends.preferred_dormitory_name()),