This commit is contained in:
@@ -2,6 +2,58 @@ from __future__ import annotations
|
||||
|
||||
from django import forms
|
||||
|
||||
from .models import MailboxConnection
|
||||
|
||||
|
||||
class MailboxConnectionForm(forms.ModelForm):
|
||||
password = forms.CharField(
|
||||
required=False,
|
||||
label="App-wachtwoord",
|
||||
help_text="Laat leeg bij wijzigen om het bestaande app-wachtwoord te behouden.",
|
||||
widget=forms.PasswordInput(
|
||||
attrs={"autocomplete": "new-password", "placeholder": "App-wachtwoord"},
|
||||
render_value=False,
|
||||
),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = MailboxConnection
|
||||
fields = (
|
||||
"platform",
|
||||
"provider",
|
||||
"custom_host",
|
||||
"port",
|
||||
"username",
|
||||
"mailbox",
|
||||
"poll_interval_minutes",
|
||||
"enabled",
|
||||
)
|
||||
labels = {
|
||||
"platform": "Vacatureplatform",
|
||||
"provider": "Mailboxprovider",
|
||||
"custom_host": "Aangepaste IMAP-host",
|
||||
"port": "IMAP-poort",
|
||||
"username": "Mailboxaccount",
|
||||
"mailbox": "Map",
|
||||
"poll_interval_minutes": "Controlefrequentie",
|
||||
"enabled": "Automatisch synchroniseren",
|
||||
}
|
||||
widgets = {
|
||||
"username": forms.EmailInput(attrs={"autocomplete": "username"}),
|
||||
"custom_host": forms.TextInput(
|
||||
attrs={"autocomplete": "off", "placeholder": "imap.provider.be"}
|
||||
),
|
||||
"mailbox": forms.TextInput(attrs={"autocomplete": "off"}),
|
||||
}
|
||||
|
||||
def clean(self):
|
||||
data = super().clean()
|
||||
if data.get("provider") != MailboxConnection.Provider.CUSTOM:
|
||||
data["custom_host"] = ""
|
||||
if not self.instance.pk and not data.get("password"):
|
||||
self.add_error("password", "Een app-wachtwoord is verplicht voor een nieuwe koppeling.")
|
||||
return data
|
||||
|
||||
|
||||
class ManualImportForm(forms.Form):
|
||||
source_url = forms.URLField(
|
||||
|
||||
Reference in New Issue
Block a user