add question schema model and integrate most urls/views
This commit is contained in:
@@ -74,6 +74,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from loguru import logger
|
||||
|
||||
|
||||
|
||||
image_storage = FileSystemStorage(
|
||||
# Physical file location ROOT
|
||||
location="{0}atlas/".format(settings.MEDIA_ROOT),
|
||||
@@ -1272,3 +1273,25 @@ class CaseResource(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.resource} - {self.case} (Pre: {self.pre_review})"
|
||||
|
||||
|
||||
class QuestionSchema(models.Model, AuthorMixin):
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField(blank=True, null=True)
|
||||
schema = models.JSONField()
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("atlas:question_schema_detail", kwargs={"pk": self.pk})
|
||||
|
||||
def get_example_form(self):
|
||||
from .forms import JsonAnswerForm
|
||||
example_form = JsonAnswerForm(
|
||||
question_schema=self.schema
|
||||
)
|
||||
return example_form
|
||||
|
||||
def get_schema_as_json(self) -> str:
|
||||
return json.dumps(self.schema)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "{}".format(self.name)
|
||||
Reference in New Issue
Block a user