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",
|
"condition",
|
||||||
"presentation",
|
"presentation",
|
||||||
"subspecialty",
|
"subspecialty",
|
||||||
|
"open_access",
|
||||||
]
|
]
|
||||||
|
|
||||||
widgets = {
|
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")
|
presentation = models.ManyToManyField(Presentation, blank=True, related_name="sbas_questions")
|
||||||
subspecialty = models.ManyToManyField(Subspecialty, 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)
|
#notes = GenericRelation(QuestionNote)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -149,6 +149,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ app_name = "sbas"
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("question/", views.QuestionView.as_view(), name="question_view"),
|
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/create/", views.QuestionCreate.as_view(), name="question_create"),
|
||||||
path(
|
path(
|
||||||
"question/<int:pk>/update",
|
"question/<int:pk>/update",
|
||||||
|
|||||||
+4
-4
@@ -98,10 +98,10 @@ class AuthorOrCheckerRequiredMixin(object):
|
|||||||
# return render(request, "sbas/question_view.html", {"questions": questions})
|
# return render(request, "sbas/question_view.html", {"questions": questions})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
#@login_required
|
||||||
def question_detail(request, pk):
|
#def question_detail(request, pk):
|
||||||
question = get_object_or_404(Question, pk=pk)
|
# question = get_object_or_404(Question, pk=pk)
|
||||||
return render(request, "sbas/question_detail.html", {"question": question})
|
# return render(request, "sbas/question_detail.html", {"question": question})
|
||||||
|
|
||||||
|
|
||||||
def active_exams(request):
|
def active_exams(request):
|
||||||
|
|||||||
@@ -163,45 +163,44 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dark mode overrides */
|
/* Dark mode overrides */
|
||||||
.floating-filter {
|
.floating-filter {
|
||||||
background: #0f1720; /* near-black */
|
background: #0f1720; /* near-black */
|
||||||
color: #e6eef6;
|
color: #e6eef6;
|
||||||
border-top-color: rgba(255,255,255,0.06);
|
border-top-color: rgba(255,255,255,0.06);
|
||||||
}
|
}
|
||||||
.bottom-filter-minibar .btn {
|
.bottom-filter-minibar .btn {
|
||||||
background: rgba(255,255,255,0.02);
|
background: rgba(255,255,255,0.02);
|
||||||
color: #e6eef6;
|
color: #e6eef6;
|
||||||
border-color: rgba(255,255,255,0.06);
|
border-color: rgba(255,255,255,0.06);
|
||||||
}
|
}
|
||||||
.filter-card {
|
.filter-card {
|
||||||
background: #0b1220;
|
background: #0b1220;
|
||||||
border-color: rgba(255,255,255,0.04);
|
border-color: rgba(255,255,255,0.04);
|
||||||
color: #e6eef6;
|
color: #e6eef6;
|
||||||
}
|
}
|
||||||
/* target common form-control/form-select/select/textarea so native selects and bootstrap styles
|
/* target common form-control/form-select/select/textarea so native selects and bootstrap styles
|
||||||
are overridden for dark theme inside filter cards */
|
are overridden for dark theme inside filter cards */
|
||||||
.filter-card .form-control,
|
.filter-card .form-control,
|
||||||
.filter-card .form-select,
|
.filter-card .form-select,
|
||||||
.filter-card input,
|
.filter-card input,
|
||||||
.filter-card select,
|
.filter-card select,
|
||||||
.filter-card textarea {
|
.filter-card textarea {
|
||||||
background: #07101a !important;
|
background: #07101a !important;
|
||||||
color: #f1f5f9 !important;
|
color: #f1f5f9 !important;
|
||||||
border-color: rgba(255,255,255,0.06) !important;
|
border-color: rgba(255,255,255,0.06) !important;
|
||||||
}
|
}
|
||||||
/* options in native multi-selects */
|
/* options in native multi-selects */
|
||||||
.filter-card select option,
|
.filter-card select option,
|
||||||
.filter-card .form-select option {
|
.filter-card .form-select option {
|
||||||
background: #07101a !important;
|
background: #07101a !important;
|
||||||
color: #f1f5f9 !important;
|
color: #f1f5f9 !important;
|
||||||
}
|
}
|
||||||
/* placeholder color */
|
/* placeholder color */
|
||||||
.filter-card .form-control::placeholder { color: rgba(255,255,255,0.5) !important; }
|
.filter-card .form-control::placeholder { color: rgba(255,255,255,0.5) !important; }
|
||||||
.filter-help { color: #9fb0c7; }
|
.filter-help { color: #9fb0c7; }
|
||||||
.badge.bg-primary.filter-count-badge { background: #0d6efd; color: #fff; }
|
.badge.bg-primary.filter-count-badge { background: #0d6efd; color: #fff; }
|
||||||
.btn-outline-secondary { color: #e6eef6; border-color: rgba(255,255,255,0.06); }
|
.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); }
|
.btn-light { background: #111827; color: #e6eef6; border-color: rgba(255,255,255,0.04); }
|
||||||
.filter-card label { color: #e6eef6; }
|
.filter-card label { color: #e6eef6; }
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
Reference in New Issue
Block a user