')
+ return mark_safe('No image')
image_object = obj[0].image
try:
@@ -196,7 +195,7 @@ class CidUserTable(SelectionTable):
if record.supervisor is not None:
return format_html("""{}\n[{}]""", record.email, record.supervisor.email)
else:
- return format_html(record.email)
+ return record.email
class CidUserExamTable(SelectionTable):
@@ -249,7 +248,7 @@ class CidUserExamTable(SelectionTable):
if record.supervisor is not None:
return format_html("""{}\n[{}]""", record.email, record.supervisor.email)
else:
- return format_html(record.email)
+ return record.email
# def render_cid(self, value, record):
diff --git a/generic/views.py b/generic/views.py
index f4c92a23..6ceeb7a4 100644
--- a/generic/views.py
+++ b/generic/views.py
@@ -16,6 +16,7 @@ from django.urls import reverse_lazy
from django.urls.base import reverse
from django.utils import timezone
from django.utils.html import format_html
+from django.utils.safestring import mark_safe
from django.views.decorators.csrf import csrf_exempt
from django.core.exceptions import PermissionDenied, FieldError
@@ -850,7 +851,7 @@ def generic_exam_set_open_access(request):
# For now require the user to have edit access (ExamViews.check_user_edit_access equivalent)
# We'll do a lightweight check: if user is superuser OR user in exam.get_author_objects()
if not (request.user.is_superuser or request.user in exam.get_author_objects()):
- return HttpResponse(format_html('Permission denied
'))
+ return HttpResponse(mark_safe('Permission denied
'))
set_val = True if request.POST.get("set_open_access") == "true" else False
@@ -1147,7 +1148,7 @@ class ExamViews(View, LoginRequiredMixin):
if request.method == "POST":
if not self.check_user_edit_access(request.user, exam_id=pk):
return HttpResponse(
- format_html(
+ mark_safe(
'Error toggling results published.
'
)
)
@@ -1163,7 +1164,7 @@ class ExamViews(View, LoginRequiredMixin):
})
else:
HttpResponse(
- format_html(
+ mark_safe(
'Error toggling results published.
'
)
)
@@ -1173,7 +1174,7 @@ class ExamViews(View, LoginRequiredMixin):
if request.method == "POST":
if not self.check_user_edit_access(request.user, exam_id=pk):
return HttpResponse(
- format_html(
+ mark_safe(
'Error toggling exam active.
'
)
)
@@ -1189,7 +1190,7 @@ class ExamViews(View, LoginRequiredMixin):
})
else:
HttpResponse(
- format_html(
+ mark_safe(
'Error toggling exam active.
'
)
)
@@ -4722,7 +4723,7 @@ def user_group_add_by_email_user(request, group_id):
res += f"
Invalid emails [{','.join(invalid_emails)}]
"
- return HttpResponse(format_html(res), content_type="text/html")
+ return HttpResponse(res, content_type="text/html")
diff --git a/longs/tables.py b/longs/tables.py
index 6ebc55a1..c4f4651b 100755
--- a/longs/tables.py
+++ b/longs/tables.py
@@ -6,6 +6,7 @@ from generic.tables import BlockImageColumn, SeriesImageColumn
from .models import Long, LongSeries, UserAnswer
from django.utils.html import format_html
+from django.utils.safestring import mark_safe
from django.db.models import Prefetch
from easy_thumbnails.files import get_thumbnailer
@@ -61,7 +62,7 @@ class PopupLinkColumn(tables.Column):
obj = value.first()
if obj is None:
- return format_html("No image")
+ return mark_safe("No image")
return obj.get_thumbnail()[0]
diff --git a/rad/views.py b/rad/views.py
index 36295864..2ac1bd86 100644
--- a/rad/views.py
+++ b/rad/views.py
@@ -23,6 +23,7 @@ from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.utils.html import format_html
+from django.utils.safestring import mark_safe
# from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required, user_passes_test
@@ -1107,7 +1108,7 @@ def accounts_bulk_create(request):
except Exception as error:
error_text = error_text + f"Error creating users.
{error}
"
- context["error"] = format_html(error_text)
+ context["error"] = mark_safe(error_text)
context["created_users"] = created_users
if existing_users:
diff --git a/rapids/models.py b/rapids/models.py
index 18beb338..a7f97860 100644
--- a/rapids/models.py
+++ b/rapids/models.py
@@ -316,9 +316,9 @@ class Rapid(QuestionBase):
if not unmarked_answers:
return "No answers to mark"
return format_html(
- "{} answer unmarked: {}".format(
- len(unmarked_answers), ", ".join(unmarked_answers)
- )
+ "{} answer unmarked: {}",
+ len(unmarked_answers),
+ ", ".join(unmarked_answers),
)
def get_unmarked_user_answers(self, exam_pk: int | None = None, marker=None):
diff --git a/sbas/tables.py b/sbas/tables.py
index 6d4218fc..5af1dcc8 100644
--- a/sbas/tables.py
+++ b/sbas/tables.py
@@ -11,11 +11,14 @@ from generic.tables import SelectionTable
class QuestionTable(SelectionTable):
def get_view_cell(record):
+
if record.open_access:
- return format_html(""" View""")
+ return mark_safe(
+ """ View"""
+ )
else:
return 'View'
#edit = tables.LinkColumn(
diff --git a/shorts/models.py b/shorts/models.py
index bf1a7e7c..88aa6d4b 100644
--- a/shorts/models.py
+++ b/shorts/models.py
@@ -185,9 +185,9 @@ class Question(QuestionBase):
if not unmarked_answers:
return "No answers to mark"
return format_html(
- "{} answer unmarked: {}".format(
- len(unmarked_answers), ", ".join(unmarked_answers)
- )
+ "{} answer unmarked: {}",
+ len(unmarked_answers),
+ ", ".join(unmarked_answers),
)
def get_unmarked_user_answers(self, exam_pk: int | None = None, marker=None):