From bdb7aff5d1692060472e808a31cbd45fbc28bd8c Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 20 Oct 2025 20:56:37 +0100 Subject: [PATCH] Add open_access field to Question model and update question detail template --- sbas/forms.py | 1 + .../0021_alter_question_open_access.py | 18 +++++ sbas/models.py | 4 ++ sbas/templates/sbas/question_detail.html | 8 +++ sbas/urls.py | 2 +- sbas/views.py | 8 +-- templates/question_table_view.html | 71 +++++++++---------- 7 files changed, 71 insertions(+), 41 deletions(-) create mode 100644 sbas/migrations/0021_alter_question_open_access.py diff --git a/sbas/forms.py b/sbas/forms.py index ff032da6..4abe2c99 100755 --- a/sbas/forms.py +++ b/sbas/forms.py @@ -148,6 +148,7 @@ class QuestionForm(ModelForm): "condition", "presentation", "subspecialty", + "open_access", ] widgets = { diff --git a/sbas/migrations/0021_alter_question_open_access.py b/sbas/migrations/0021_alter_question_open_access.py new file mode 100644 index 00000000..b782df96 --- /dev/null +++ b/sbas/migrations/0021_alter_question_open_access.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.4 on 2025-10-20 19:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sbas', '0020_question_sources'), + ] + + operations = [ + migrations.AlterField( + model_name='question', + name='open_access', + field=models.BooleanField(default=True, help_text='If set, this question is available to all users for use in their exams.'), + ), + ] diff --git a/sbas/models.py b/sbas/models.py index 28a5ef5c..4659990e 100644 --- a/sbas/models.py +++ b/sbas/models.py @@ -107,6 +107,10 @@ class Question(QuestionBase): presentation = models.ManyToManyField(Presentation, blank=True, related_name="sbas_questions") subspecialty = models.ManyToManyField(Subspecialty, blank=True, related_name="sbas_questions") + open_access = models.BooleanField( + default=True, help_text="If set, this question is available to all users for use in their exams." + ) + #notes = GenericRelation(QuestionNote) def __str__(self): diff --git a/sbas/templates/sbas/question_detail.html b/sbas/templates/sbas/question_detail.html index a2167704..cbc45177 100644 --- a/sbas/templates/sbas/question_detail.html +++ b/sbas/templates/sbas/question_detail.html @@ -149,6 +149,14 @@ {% endif %} +
Open Access: +
+ {% if question.open_access %} + Yes + {% else %} + No + {% endif %} +
diff --git a/sbas/urls.py b/sbas/urls.py index a1f8a334..56242b59 100644 --- a/sbas/urls.py +++ b/sbas/urls.py @@ -9,7 +9,7 @@ app_name = "sbas" urlpatterns = [ path("question/", views.QuestionView.as_view(), name="question_view"), - path("question//", views.question_detail, name="question_detail"), + #path("question//", views.question_detail, name="question_detail"), path("question/create/", views.QuestionCreate.as_view(), name="question_create"), path( "question//update", diff --git a/sbas/views.py b/sbas/views.py index cafd2343..4095cdff 100644 --- a/sbas/views.py +++ b/sbas/views.py @@ -98,10 +98,10 @@ class AuthorOrCheckerRequiredMixin(object): # return render(request, "sbas/question_view.html", {"questions": questions}) -@login_required -def question_detail(request, pk): - question = get_object_or_404(Question, pk=pk) - return render(request, "sbas/question_detail.html", {"question": question}) +#@login_required +#def question_detail(request, pk): +# question = get_object_or_404(Question, pk=pk) +# return render(request, "sbas/question_detail.html", {"question": question}) def active_exams(request): diff --git a/templates/question_table_view.html b/templates/question_table_view.html index fce3cd01..e429d537 100644 --- a/templates/question_table_view.html +++ b/templates/question_table_view.html @@ -163,45 +163,44 @@ } /* Dark mode overrides */ - .floating-filter { - background: #0f1720; /* near-black */ - color: #e6eef6; - border-top-color: rgba(255,255,255,0.06); - } - .bottom-filter-minibar .btn { - background: rgba(255,255,255,0.02); - color: #e6eef6; - border-color: rgba(255,255,255,0.06); - } - .filter-card { - background: #0b1220; - border-color: rgba(255,255,255,0.04); - color: #e6eef6; - } + .floating-filter { + background: #0f1720; /* near-black */ + color: #e6eef6; + border-top-color: rgba(255,255,255,0.06); + } + .bottom-filter-minibar .btn { + background: rgba(255,255,255,0.02); + color: #e6eef6; + border-color: rgba(255,255,255,0.06); + } + .filter-card { + background: #0b1220; + border-color: rgba(255,255,255,0.04); + color: #e6eef6; + } /* target common form-control/form-select/select/textarea so native selects and bootstrap styles are overridden for dark theme inside filter cards */ - .filter-card .form-control, - .filter-card .form-select, - .filter-card input, - .filter-card select, - .filter-card textarea { - background: #07101a !important; - color: #f1f5f9 !important; - border-color: rgba(255,255,255,0.06) !important; - } + .filter-card .form-control, + .filter-card .form-select, + .filter-card input, + .filter-card select, + .filter-card textarea { + background: #07101a !important; + color: #f1f5f9 !important; + border-color: rgba(255,255,255,0.06) !important; + } /* options in native multi-selects */ - .filter-card select option, - .filter-card .form-select option { - background: #07101a !important; - color: #f1f5f9 !important; - } + .filter-card select option, + .filter-card .form-select option { + background: #07101a !important; + color: #f1f5f9 !important; + } /* placeholder color */ - .filter-card .form-control::placeholder { color: rgba(255,255,255,0.5) !important; } - .filter-help { color: #9fb0c7; } - .badge.bg-primary.filter-count-badge { background: #0d6efd; color: #fff; } - .btn-outline-secondary { color: #e6eef6; border-color: rgba(255,255,255,0.06); } - .btn-light { background: #111827; color: #e6eef6; border-color: rgba(255,255,255,0.04); } - .filter-card label { color: #e6eef6; } + .filter-card .form-control::placeholder { color: rgba(255,255,255,0.5) !important; } + .filter-help { color: #9fb0c7; } + .badge.bg-primary.filter-count-badge { background: #0d6efd; color: #fff; } + .btn-outline-secondary { color: #e6eef6; border-color: rgba(255,255,255,0.06); } + .btn-light { background: #111827; color: #e6eef6; border-color: rgba(255,255,255,0.04); } + .filter-card label { color: #e6eef6; } {% endblock %} - \ No newline at end of file