add question schema model and integrate most urls/views
This commit is contained in:
+15
-3
@@ -27,6 +27,7 @@ from atlas.models import (
|
||||
CidReportAnswer,
|
||||
Differential,
|
||||
Finding,
|
||||
QuestionSchema,
|
||||
Resource,
|
||||
SelfReview,
|
||||
Series,
|
||||
@@ -528,10 +529,11 @@ class JsonAnswerForm(Form):
|
||||
class Meta:
|
||||
fields = ["json_answer"]
|
||||
|
||||
def __init__(self, *args, case_detail, **kwargs):
|
||||
def __init__(self, *args, question_schema=None, **kwargs):
|
||||
super(JsonAnswerForm, self).__init__(*args, **kwargs)
|
||||
if case_detail.question_schema is not None:
|
||||
self.fields["json_answer"] = JSONSchemaField(schema=case_detail.question_schema, options='schema/options.json')
|
||||
if question_schema is not None:
|
||||
self.fields["json_answer"] = JSONSchemaField(schema=question_schema, options='schema/options.json')
|
||||
self.fields["json_answer"].label = False
|
||||
|
||||
class BaseReportAnswerForm(ModelForm):
|
||||
class Meta:
|
||||
@@ -768,4 +770,14 @@ class CaseDetailForm(ModelForm):
|
||||
widgets = {
|
||||
"question_schema": SvelteJSONEditorWidgetOverride(),
|
||||
"question_answers": SvelteJSONEditorWidgetOverride(),
|
||||
}
|
||||
|
||||
|
||||
class QuestionSchemaForm(ModelForm):
|
||||
class Meta:
|
||||
model = QuestionSchema
|
||||
fields = ["name", "description", "schema"]
|
||||
|
||||
widgets = {
|
||||
"schema": SvelteJSONEditorWidgetOverride(),
|
||||
}
|
||||
Reference in New Issue
Block a user