.
This commit is contained in:
@@ -49,6 +49,7 @@ class Formats(models.Model):
|
|||||||
self.format = self.format.replace("\r\n", "\n")
|
self.format = self.format.replace("\r\n", "\n")
|
||||||
return super().clean()
|
return super().clean()
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
self.format = self.format.replace("\r\n", "\n")
|
self.format = self.format.replace("\r\n", "\n")
|
||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
@@ -62,6 +63,9 @@ class Formats(models.Model):
|
|||||||
formats.reverse()
|
formats.reverse()
|
||||||
return "\n".join(formats)
|
return "\n".join(formats)
|
||||||
|
|
||||||
|
def get_entries(self):
|
||||||
|
return Entry.objects.filter(questions__icontains=self.get_format())
|
||||||
|
|
||||||
class Specialty(models.Model):
|
class Specialty(models.Model):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,10 @@
|
|||||||
{{ form }}
|
{{ form }}
|
||||||
<input type="submit" value="Update">
|
<input type="submit" value="Update">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h2>Entries</h2>
|
||||||
|
<ul>
|
||||||
|
{% for entry in object.get_entries %}
|
||||||
|
<li>{{ entry.exam_code }} / {{ entry.exam_name }}</li>
|
||||||
|
{% endfor %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
@@ -3,15 +3,23 @@
|
|||||||
<h2>Questions</h2>
|
<h2>Questions</h2>
|
||||||
There are {{ questions|length }} question sets.
|
There are {{ questions|length }} question sets.
|
||||||
|
|
||||||
<div>Filter by:
|
<div>
|
||||||
<textarea type="text" id="search-text" name="search" placeholder="Search text.." rows=5 cols=50 ></textarea>
|
<textarea type="text" id="search-text" name="search" placeholder="Search text.." rows=5 cols=50 ></textarea>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
||||||
_="on click repeat for el in <li.question/>
|
_="on click repeat for el in <li.question/>
|
||||||
set p to the first <pre/> in el then
|
set p to the first <pre/> in el then
|
||||||
if p.title does not contain value of #search-text then hide el">Filter</button>
|
if p.title does not contain value of #search-text then hide el">Search</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
Filter by
|
||||||
|
<button
|
||||||
|
_="on click hide .unnamed then show .named"
|
||||||
|
>Named</button>
|
||||||
|
<button
|
||||||
|
_="on click hide .named then show .unnamed"
|
||||||
|
>Unnamed</button>
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-end bg-dark" tabindex="-1" id="offcanvasExample" data-bs-scroll="true" data-bs-backdrop="false" aria-labelledby="offcanvasExampleLabel">
|
<div class="offcanvas offcanvas-end bg-dark" tabindex="-1" id="offcanvasExample" data-bs-scroll="true" data-bs-backdrop="false" aria-labelledby="offcanvasExampleLabel">
|
||||||
<div class="offcanvas-header">
|
<div class="offcanvas-header">
|
||||||
@@ -32,7 +40,7 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for question, format in questions_and_formats %}
|
{% for question, format in questions_and_formats %}
|
||||||
<li class="question">
|
<li class="question {% if format %}named{% else %}unnamed{% endif %}">
|
||||||
<span class="format-name">
|
<span class="format-name">
|
||||||
{% if format %}
|
{% if format %}
|
||||||
<a href='{% url "oef:format_update" format.pk %}'>{{format.name}}</a>
|
<a href='{% url "oef:format_update" format.pk %}'>{{format.name}}</a>
|
||||||
@@ -79,7 +87,7 @@
|
|||||||
end
|
end
|
||||||
"
|
"
|
||||||
>Add codes to sidebar</button>
|
>Add codes to sidebar</button>
|
||||||
<input type="text" class="format-name" placeholder="format name" style="display:none">
|
<input type="text" class="format-name" name="format_name" placeholder="format name" style="display:none">
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm save-format-button" type="button" style="display:none"
|
class="btn btn-sm save-format-button" type="button" style="display:none"
|
||||||
hx-post="{% url 'oef:formats_save' %}"
|
hx-post="{% url 'oef:formats_save' %}"
|
||||||
|
|||||||
+1
-1
@@ -179,7 +179,7 @@ def formats_save(request):
|
|||||||
if Formats.objects.filter(format=question).exists():
|
if Formats.objects.filter(format=question).exists():
|
||||||
return HttpResponse("Format questions already exists")
|
return HttpResponse("Format questions already exists")
|
||||||
|
|
||||||
Formats.objects.create(name="format_name", format=question)
|
Formats.objects.create(name=format_name, format=question)
|
||||||
|
|
||||||
return HttpResponse("Format saved")
|
return HttpResponse("Format saved")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user