add question schema model and integrate most urls/views

This commit is contained in:
Ross
2024-06-24 11:43:33 +01:00
parent 71fefe6c4f
commit cef06e4682
12 changed files with 232 additions and 25 deletions
+1
View File
@@ -16,6 +16,7 @@
<a href="{% url 'atlas:series_create' %}" title="Create a new image series">Create Series</a> /
<a href="{% url 'atlas:resource_view' %}" title="Resources">Resources</a> /
<a href="{% url 'atlas:user_uploads' %}" title="View unimported uploads">Uploads</a> /
<a href="{% url 'atlas:question_schema_overview' %}" title="View and edit question schemas">Question Schemas</a> /
<a href="{% url 'atlas:help' %}" title="View the atlas help pages">Help</a>
{% endif %}
{% comment %} </br>
@@ -29,7 +29,7 @@
hx-target=".offcanvas-body"
>Collection questions</button>
<button class="btn btn-primary btn-sm" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight"
hx-get="{% url 'atlas:question_schemas_preset' %}"
hx-get="{% url 'atlas:question_schema_schemas' %}"
hx-target=".offcanvas-body"
>Preset questions</button>
+24
View File
@@ -0,0 +1,24 @@
{% extends 'atlas/base.html' %}
{% block content %}
<div>
<h3>Name: {{question_schema.name}}</h3>
<p>Description: {{question_schema.description}}</p>
<details><summary>JSON:</summary>{{question_schema.schema}}</details>
{{example_form}}
<a href='{% url "atlas:question_schema_update" pk=question_schema.pk %}'><button>Edit</button></a>
<a href='{% url "atlas:question_schema_delete" pk=question_schema.pk %}'><button>Delete</button></a>
</div>
{% endblock %}
{% block js %}
{{example_form.media}}
{% endblock %}
@@ -3,12 +3,12 @@
{% comment %} <script src="{% static 'js/jquery-3.7.1.min.js' %}"></script>
<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script> {% endcomment %}
<ol>
{% for schema in schemas %}
{% for question_schema in question_schemas %}
<li class="schemas">
<button class="btn btn-sm btn-secondary use-layout">Use schema</button>
<details><summary>Schema:</summary>
<div class="schema" data-schema='{{schema|safe}}'>{{schema}}</div>
<details><summary>{{question_schema.name}}</summary>
<div class="schema" data-schema='{{question_schema.get_schema_as_json|safe}}'>{{question_schema.schema}}</div>
</details>
<div class="form"></div>
+24
View File
@@ -0,0 +1,24 @@
{% extends "atlas/base.html" %}
<!-- {% load static from static %} -->
{% block css %}
{% endblock %}
{% block js %}
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
{{form.media}}
<script type="text/javascript">
</script>
<!-- {{ form.media }} -->
{% endblock %}
{% block content %}
<h2>Add/Edit Condition</h2>
<p>Use this form to create or edit a question schema.</p>
<form action="" method="post" enctype="multipart/form-data" id="condition-form">
{% csrf_token %}
{{ form.as_div }}
<input type="submit" class="submit-button" value="Submit" name="submit">
</form>
{% endblock %}