Files
url_shortening_service/site/links/forms.py
T
westfarn 143ac7c6d0
CI / test (pull_request) Successful in 6s
Add v1 shortener: Bearer API, public 302, landing, and CI.
Standalone Django service so callers can mint links and phones get a 302.
Closes #1.
2026-08-30 06:54:32 -05:00

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