Publish curated VacatureRadar source snapshot
This commit is contained in:
commit
e29774cb7f
338 files changed
+32699
No files matched your search
@@ -0,0 +1,86 @@
|
||||
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=(
|
||||
"Alleen voor Gmail of een aangepaste provider. Microsoft 365 gebruikt "
|
||||
"de centrale OAuth-configuratie."
|
||||
),
|
||||
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"] = ""
|
||||
uses_oauth = data.get("provider") == MailboxConnection.Provider.OUTLOOK
|
||||
if not self.instance.pk and not uses_oauth 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(
|
||||
required=False,
|
||||
label="Vacature-URL",
|
||||
max_length=1000,
|
||||
widget=forms.URLInput(attrs={"autocomplete": "off"}),
|
||||
)
|
||||
pasted_text = forms.CharField(
|
||||
required=False,
|
||||
label="Tekst plakken",
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
"rows": 6,
|
||||
"placeholder": "Plak hier de vacaturetekst of relevante pagina-inhoud.",
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
data = super().clean()
|
||||
source_url = (data.get("source_url") or "").strip()
|
||||
pasted_text = (data.get("pasted_text") or "").strip()
|
||||
if not source_url and not pasted_text:
|
||||
raise forms.ValidationError("Vul een URL of een tekstfragment in.")
|
||||
return {"source_url": source_url, "pasted_text": pasted_text}
|
||||
Reference in new issue
Block a user