aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/caf/forms.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/caf/forms.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/ctrack/caf/forms.py b/ctrack/caf/forms.py
index ee3bf21..34826be 100644
--- a/ctrack/caf/forms.py
+++ b/ctrack/caf/forms.py
@@ -4,23 +4,38 @@ from crispy_forms.layout import ButtonHolder
from crispy_forms.layout import Fieldset
from crispy_forms.layout import Layout
from crispy_forms.layout import Submit
+
from django import forms
+from django.urls import reverse
+
+from django.forms import ModelChoiceField
+
from ctrack.caf.models import CAF
+from ctrack.caf.models import DocumentFile
class CAFForm(forms.ModelForm):
+ file = ModelChoiceField(
+ queryset=DocumentFile.objects.all(),
+ required=False,
+ help_text="Please select an existing File. <a href='/caf/file/documentfile/create' target='_blank'>Create new File</a>" # TODO this URL does not exist
+ )
+
class Meta:
model = CAF
- fields = ["owner", "essential_system"]
+ fields = ["owner", "essential_system", "file"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ cancel_redirect = reverse('caf:caf_list') # TODO this URL doesn't exist
+
self.helper = FormHelper(self)
self.helper.form_class = "form-group"
self.helper.form_method = "post"
self.helper.layout = Layout(
- Fieldset("Create/Edit CAF", "owner", "essential_system"),
+ Fieldset("Create/Edit CAF", "owner", "essential_system", "file"),
ButtonHolder(Submit("submit", "Submit"), Button("cancel", "Cancel")),
)
+