CI / test (pull_request) Successful in 6s
Standalone Django service so callers can mint links and phones get a 302. Closes #1.
22 lines
735 B
Python
22 lines
735 B
Python
from django import forms
|
|
|
|
from links.services import ValidationError, validate_target_url
|
|
|
|
|
|
class DebugCreateForm(forms.Form):
|
|
target_url = forms.URLField(
|
|
label="Target URL",
|
|
widget=forms.URLInput(
|
|
attrs={"placeholder": "https://mkdrealtor.com/listings/oak-st", "autofocus": True}
|
|
),
|
|
)
|
|
title = forms.CharField(label="Title", required=False, max_length=200)
|
|
external_ref = forms.CharField(label="External ref", required=False, max_length=64)
|
|
|
|
def clean_target_url(self) -> str:
|
|
raw = self.cleaned_data["target_url"]
|
|
try:
|
|
return validate_target_url(raw)
|
|
except ValidationError as exc:
|
|
raise forms.ValidationError(str(exc)) from exc
|