from ckeditor_uploader.widgets import CKEditorUploadingWidget

from django import forms
from django.utils.translation import gettext_lazy as _

from .models import Member, Job, JobGroup


class MemberForm(forms.ModelForm):
    class Meta:
        model = Member
        fields = [
            "firstname",
            "surname",
            "nickname",
            "username",
            "mailaccount",
            "role",
            "description",
            "image",
            "birthday",
            "phone",
            "address",
        ]

        widgets = {"description": CKEditorUploadingWidget(config_name="default")}

        labels = {
            "description": _("Beschreibung zu der Person"),
            "image": _("Porträt"),
            "birthday": _("Geburtstag"),
            "phone": _("Telefonnummer"),
            "address": _("Wohnadresse"),
        }

        help_texts = {
            "image": _(
                "Mindestdimension: 150*150 px, maximale Größe: 10MB, "
                "erlaubtes Format: Bildformat"
            ),
            "mailaccount": _("Die Mailadresse mit '@fet.at' angeben."),
        }


class JobForm(forms.ModelForm):
    class Meta:
        model = Job
        fields = [
            "name",
            "shortterm",
            "slug",
            "job_group",
        ]

        labels = {
            "shortterm": _("Kürzel der Tätigkeit"),
            "slug": _("Permalink"),
            "job_group": _("Tätigkeitsbereich"),
        }


class JobGroupForm(forms.ModelForm):
    class Meta:
        model = JobGroup
        fields = [
            "name",
            "shortterm",
            "slug",
            "description",
            "is_pinned",
        ]

        widgets = {"description": CKEditorUploadingWidget(config_name="default")}

        labels = {
            "shortterm": _("Kürzel des Tätigkeitsbereichs"),
            "slug": _("Permalink"),
            "description": _("Beschreibung des Tätigkeitsbereichs"),
            "is_pinned": _(
                "Dieser Tätigkeitsbereich soll im Fachschaftsbereich angeheftet werden, "
                "damit es sofort ersichtlich ist."
            ),
        }
