staging
This commit is contained in:
+15
-1
@@ -65,6 +65,9 @@ from django.core.exceptions import ValidationError
|
|||||||
import datetime
|
import datetime
|
||||||
from django.forms.utils import from_current_timezone, to_current_timezone
|
from django.forms.utils import from_current_timezone, to_current_timezone
|
||||||
|
|
||||||
|
from crispy_forms.helper import FormHelper
|
||||||
|
from crispy_forms.layout import Submit
|
||||||
|
|
||||||
class SplitDateTimeFieldDefaultTime(SplitDateTimeField):
|
class SplitDateTimeFieldDefaultTime(SplitDateTimeField):
|
||||||
def compress(self, data_list):
|
def compress(self, data_list):
|
||||||
if data_list:
|
if data_list:
|
||||||
@@ -107,6 +110,15 @@ class ExamFormMixin:
|
|||||||
def __init__(self, *args, user, **kwargs) -> None:
|
def __init__(self, *args, user, **kwargs) -> None:
|
||||||
super(ModelForm, self).__init__(*args, **kwargs)
|
super(ModelForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.helper = FormHelper()
|
||||||
|
self.helper.form_id = 'id-exam-form'
|
||||||
|
self.helper.form_class = 'exam-form'
|
||||||
|
self.helper.form_method = 'post'
|
||||||
|
self.helper.form_action = 'submit'
|
||||||
|
|
||||||
|
|
||||||
|
self.helper.add_input(Submit('submit', 'Submit'))
|
||||||
|
|
||||||
#if user.is_superuser or user.groups.filter(name="cid_user_manager").exists():
|
#if user.is_superuser or user.groups.filter(name="cid_user_manager").exists():
|
||||||
# cid_user_group_queryset = CidUserGroup.objects.filter(archive=False)
|
# cid_user_group_queryset = CidUserGroup.objects.filter(archive=False)
|
||||||
# user_user_group_queryset = UserUserGroup.objects.filter(archive=False)
|
# user_user_group_queryset = UserUserGroup.objects.filter(archive=False)
|
||||||
@@ -130,6 +142,7 @@ class ExamFormMixin:
|
|||||||
time_format="%H:%M",
|
time_format="%H:%M",
|
||||||
),
|
),
|
||||||
required=False,
|
required=False,
|
||||||
|
help_text="The date the exam is due to start (time is optional)",
|
||||||
)
|
)
|
||||||
self.fields["end_date"] = SplitDateTimeFieldDefaultTimeEnd(
|
self.fields["end_date"] = SplitDateTimeFieldDefaultTimeEnd(
|
||||||
widget=SplitDateTimeWidget(
|
widget=SplitDateTimeWidget(
|
||||||
@@ -139,6 +152,7 @@ class ExamFormMixin:
|
|||||||
time_format="%H:%M",
|
time_format="%H:%M",
|
||||||
),
|
),
|
||||||
required=False,
|
required=False,
|
||||||
|
help_text="The date the exam is due to start (time is optional)",
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -149,9 +163,9 @@ class ExamFormMixin:
|
|||||||
"authors_only",
|
"authors_only",
|
||||||
"exam_mode",
|
"exam_mode",
|
||||||
"include_history",
|
"include_history",
|
||||||
|
"restrict_to_dates",
|
||||||
"start_date",
|
"start_date",
|
||||||
"end_date",
|
"end_date",
|
||||||
"restrict_to_dates",
|
|
||||||
"active",
|
"active",
|
||||||
"publish_results",
|
"publish_results",
|
||||||
"archive",
|
"archive",
|
||||||
|
|||||||
+3
-3
@@ -76,7 +76,7 @@ INSTALLED_APPS = [
|
|||||||
"django_unused_media",
|
"django_unused_media",
|
||||||
"django_htmx",
|
"django_htmx",
|
||||||
"crispy_forms",
|
"crispy_forms",
|
||||||
"crispy_bootstrap4",
|
"crispy_bootstrap5",
|
||||||
"autocomplete",
|
"autocomplete",
|
||||||
'markdownify.apps.MarkdownifyConfig',
|
'markdownify.apps.MarkdownifyConfig',
|
||||||
'django_jsonforms',
|
'django_jsonforms',
|
||||||
@@ -291,8 +291,8 @@ EMAIL_USE_SSL = True
|
|||||||
|
|
||||||
ADMINS = [("Ross","ross@xkjq.uk")]
|
ADMINS = [("Ross","ross@xkjq.uk")]
|
||||||
|
|
||||||
CRISPY_ALLOWED_TEMPLATE_PACK = 'bootstrap4'
|
CRISPY_ALLOWED_TEMPLATE_PACK = 'bootstrap5'
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
CRISPY_TEMPLATE_PACK = 'bootstrap5'
|
||||||
|
|
||||||
DEBUG_CONTAINER = False
|
DEBUG_CONTAINER = False
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -34,7 +34,8 @@ debugpy
|
|||||||
git+https://github.com/jazzband/django-cookie-consent#django-cookie-consent
|
git+https://github.com/jazzband/django-cookie-consent#django-cookie-consent
|
||||||
django-crispy-forms
|
django-crispy-forms
|
||||||
django-ninja
|
django-ninja
|
||||||
crispy-bootstrap4
|
#crispy-bootstrap4
|
||||||
|
crispy-bootstrap5
|
||||||
django-rich
|
django-rich
|
||||||
ipython
|
ipython
|
||||||
django-htmx-autocomplete
|
django-htmx-autocomplete
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{% extends view.model.app_name|add:"/base.html" %}
|
{% extends view.model.app_name|add:"/base.html" %}
|
||||||
|
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ form.media }}
|
{{ form.media }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -7,12 +8,10 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h2>Add Exam</h2>
|
<h2>Add Exam</h2>
|
||||||
|
Create a new exam. Questions and candidates can be added later.
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
{% crispy form form.helper %}
|
||||||
{{ form }}
|
|
||||||
</table>
|
|
||||||
<input type="submit" value="Submit">
|
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
{% if view_all %}
|
{% if view_all %}
|
||||||
<a href="{% url app_name|add:':exam_list' %}" >Hide archived</a>
|
<a href="{% url app_name|add:':exam_list' %}" >Hide archived</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{% url app_name|add:':exam_list_all' %}">View all</a>
|
<a href="{% url app_name|add:':exam_list_all' %}" title="Show all exams (including archived)">View all</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% include 'exam_overview_js.html' %}
|
{% include 'exam_overview_js.html' %}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{% extends exam.app_name|add:"/exams.html" %}
|
{% extends exam.app_name|add:"/exams.html" %}
|
||||||
|
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
{{ form.media }}
|
{{ form.media }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -14,10 +16,11 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Update Exam</h2>
|
<h2>Update Exam</h2>
|
||||||
|
This form allows you to edit the exam details. To manage candidates head to the <a href="{% url exam.app_name|add:':exam_cids' exam.pk %}">candidates</a> page.
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ form|crispy }}
|
||||||
</table>
|
</table>
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user