You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
konova/intervention/inputs.py

48 lines
1.3 KiB
Python

from django import forms
from django.urls import reverse
class DummyFilterInput(forms.HiddenInput):
""" A dummy input widget
Does not render anything. Can be used to keep filter logic using django_filter without having a pre defined
filter widget being rendered to the template.
"""
template_name = "konova/widgets/empty-dummy-input.html"
class TextToClipboardInput(forms.TextInput):
template_name = "konova/widgets/text-to-clipboard-input.html"
class GenerateInput(forms.TextInput):
"""
Provides a form group with a button at the end, which generates new content for the input.
The url used to fetch new content can be added using the attrs like
widget=GenerateInput(
attrs={
"url": reverse_lazy("app_name:view_name")
...
}
)
"""
template_name = "konova/widgets/generate-content-input.html"
class TreeSelectMultiple(forms.SelectMultiple):
""" Provides multiple selection of parent-child data
"""
template_name = "konova/widgets/checkbox-tree-select-base.html"
url = None
def __init__(self, *args, **kwargs):
self.url = kwargs.pop("url", None)
if self.url:
self.url = reverse(self.url)
super().__init__(*args, **kwargs)