Add open_access field to Question model and update question detail template
This commit is contained in:
@@ -148,6 +148,7 @@ class QuestionForm(ModelForm):
|
||||
"condition",
|
||||
"presentation",
|
||||
"subspecialty",
|
||||
"open_access",
|
||||
]
|
||||
|
||||
widgets = {
|
||||
|
||||
@@ -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.'),
|
||||
),
|
||||
]
|
||||
@@ -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):
|
||||
|
||||
@@ -149,6 +149,14 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2"><strong>Open Access:</strong>
|
||||
<div>
|
||||
{% if question.open_access %}
|
||||
<span class="badge bg-success">Yes</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">No</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ app_name = "sbas"
|
||||
|
||||
urlpatterns = [
|
||||
path("question/", views.QuestionView.as_view(), name="question_view"),
|
||||
path("question/<int:pk>/", views.question_detail, name="question_detail"),
|
||||
#path("question/<int:pk>/", views.question_detail, name="question_detail"),
|
||||
path("question/create/", views.QuestionCreate.as_view(), name="question_create"),
|
||||
path(
|
||||
"question/<int:pk>/update",
|
||||
|
||||
+4
-4
@@ -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):
|
||||
|
||||
@@ -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; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user