- Implemented custom form widgets for date, time, and datetime fields with DaisyUI styling. - Created utility functions for formatting dates, times, and numbers according to user preferences. - Developed views for profile settings, API key management, and notifications, including health check endpoints. - Added URL configurations for Themis tests and main application routes. - Established test cases for custom widgets to ensure proper functionality and integration. - Defined project metadata and dependencies in pyproject.toml for package management.
101 lines
2.9 KiB
Python
101 lines
2.9 KiB
Python
"""
|
|
Django forms for Library admin views.
|
|
|
|
These forms are used by the custom admin views for Library, Collection,
|
|
and Item CRUD. They are plain Django forms (not ModelForms) because
|
|
neomodel StructuredNodes are not Django ORM models.
|
|
"""
|
|
|
|
from django import forms
|
|
|
|
from .content_types import LIBRARY_TYPE_DEFAULTS
|
|
|
|
|
|
LIBRARY_TYPE_CHOICES = [
|
|
(key, key.capitalize()) for key in LIBRARY_TYPE_DEFAULTS.keys()
|
|
]
|
|
|
|
|
|
class LibraryForm(forms.Form):
|
|
"""Form for creating/editing a Library node."""
|
|
|
|
name = forms.CharField(
|
|
max_length=200,
|
|
widget=forms.TextInput(attrs={"class": "input input-bordered w-full"}),
|
|
)
|
|
library_type = forms.ChoiceField(
|
|
choices=LIBRARY_TYPE_CHOICES,
|
|
widget=forms.Select(attrs={"class": "select select-bordered w-full"}),
|
|
)
|
|
description = forms.CharField(
|
|
required=False,
|
|
widget=forms.Textarea(
|
|
attrs={"class": "textarea textarea-bordered w-full", "rows": 3}
|
|
),
|
|
)
|
|
embedding_instruction = forms.CharField(
|
|
required=False,
|
|
widget=forms.Textarea(
|
|
attrs={"class": "textarea textarea-bordered w-full", "rows": 3}
|
|
),
|
|
)
|
|
reranker_instruction = forms.CharField(
|
|
required=False,
|
|
widget=forms.Textarea(
|
|
attrs={"class": "textarea textarea-bordered w-full", "rows": 3}
|
|
),
|
|
)
|
|
llm_context_prompt = forms.CharField(
|
|
required=False,
|
|
widget=forms.Textarea(
|
|
attrs={"class": "textarea textarea-bordered w-full", "rows": 3}
|
|
),
|
|
)
|
|
|
|
|
|
class CollectionForm(forms.Form):
|
|
"""Form for creating/editing a Collection node."""
|
|
|
|
name = forms.CharField(
|
|
max_length=200,
|
|
widget=forms.TextInput(attrs={"class": "input input-bordered w-full"}),
|
|
)
|
|
description = forms.CharField(
|
|
required=False,
|
|
widget=forms.Textarea(
|
|
attrs={"class": "textarea textarea-bordered w-full", "rows": 3}
|
|
),
|
|
)
|
|
|
|
|
|
class ItemForm(forms.Form):
|
|
"""Form for creating/editing an Item node."""
|
|
|
|
title = forms.CharField(
|
|
max_length=500,
|
|
widget=forms.TextInput(attrs={"class": "input input-bordered w-full"}),
|
|
)
|
|
item_type = forms.CharField(
|
|
required=False,
|
|
max_length=100,
|
|
widget=forms.TextInput(attrs={"class": "input input-bordered w-full"}),
|
|
)
|
|
file_type = forms.CharField(
|
|
required=False,
|
|
max_length=50,
|
|
widget=forms.TextInput(attrs={"class": "input input-bordered w-full"}),
|
|
)
|
|
file = forms.FileField(
|
|
required=False,
|
|
widget=forms.ClearableFileInput(
|
|
attrs={"class": "file-input file-input-bordered w-full"}
|
|
),
|
|
help_text="Upload a document (PDF, EPUB, DOCX, PPTX, TXT, etc.)",
|
|
)
|
|
auto_embed = forms.BooleanField(
|
|
required=False,
|
|
initial=True,
|
|
widget=forms.CheckboxInput(attrs={"class": "checkbox checkbox-primary"}),
|
|
help_text="Automatically start embedding after upload",
|
|
)
|