Skip to content

Commit b5912d5

Browse files
committed
Fix SyntaxWarnings
1 parent b4b807c commit b5912d5

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

course/staff_views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ def get_common_objects(self):
4545
k: str(Enrollment.ENROLLMENT_STATUS[getattr(Enrollment.ENROLLMENT_STATUS, k)])
4646
for k in Enrollment.ENROLLMENT_STATUS.keys()
4747
}
48-
self.enrollment_statuses_json = json.dumps(self.enrollment_statuses)
49-
self.participants = json.dumps(self._get_students_with_tags())
48+
self.participants = self._get_students_with_tags()
5049
self.internal_user_label = settings_text('INTERNAL_USER_LABEL')
5150
self.external_user_label = settings_text('EXTERNAL_USER_LABEL')
5251
self.note(
5352
'participants', 'tags',
54-
'enrollment_statuses', 'enrollment_statuses_json',
53+
'enrollment_statuses',
5554
'internal_user_label', 'external_user_label',
5655
)
5756

course/templates/course/staff/participants.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,15 @@ <h4 class="modal-title" id="enrollment-remove-modal-label">
258258
{% endif %}
259259

260260
<script src="{% static 'js/participants.js' %}"></script>
261+
262+
{{ participants|json_script:"participants-data" }}
263+
{{ enrollment_statuses|json_script:"enrollment-statuses-data" }}
261264
<script>
262265
$(function () {
263-
const participants = {{ participants|escape_slashes|safe }};
266+
const participants = JSON.parse(document.getElementById('participants-data').textContent);
264267
const api_url = "{% url 'api:course-detail' 2 instance.id %}";
265268
const is_teacher = {{ is_teacher|yesno:"true,false" }};
266-
const enrollment_statuses = {{ enrollment_statuses_json|escape_slashes|safe }};
269+
const enrollment_statuses = JSON.parse(document.getElementById('enrollment-statuses-data').textContent);
267270
participants_list(participants, api_url, is_teacher, enrollment_statuses);
268271
});
269272
</script>

course/templatetags/course.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ def group_select(context):
4646
'selected': selected,
4747
}
4848

49-
@register.filter
50-
def escape_slashes(string):
51-
return str(string).replace('/', '\/') # noqa: W605
5249

5350
@register.filter
5451
def parse_localization(entry):

lib/remote_page.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ def fix_relative_urls(self, is_multilingual_course):
226226
# pylint: disable-next=too-many-locals too-many-branches
227227
def _fix_relative_urls(self, url, tag_name, attr_name, is_multilingual_course):
228228
# Starts with "#", "//" or "https:".
229-
test = re.compile('^(#|\/\/|\w+:)', re.IGNORECASE) # noqa: W605
229+
test = re.compile(r'^(#|//|\w+:)', re.IGNORECASE)
230230
# Ends with filename extension ".html" and possibly "#anchor".
231-
chapter = re.compile('.*\.html(#.+)?$', re.IGNORECASE) # noqa: W605
231+
chapter = re.compile(r'.*\.html(#.+)?$', re.IGNORECASE)
232232
# Starts with at least one "../".
233233
start_dotdot_path = re.compile(r"^(../)+")
234234
# May end with the language suffix _en or _en/#anchor or _en#anchor.

0 commit comments

Comments
 (0)