Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions django/django_application/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'django_filters',
'parse_m2.apps.ParseM2Config',
'evaluate_m2.apps.EvaluateM2Config',
'django_prose_editor',
]

MIDDLEWARE = [
Expand Down
4 changes: 1 addition & 3 deletions django/evaluate_m2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class EvaluatorMetadataAdmin(admin.ModelAdmin):
readonly_fields = [
'id', 'category', 'fields_used', 'fields_display',
'long_description',
]
fields = [
'id', 'category', 'fields_used', 'fields_display',
Expand All @@ -20,8 +19,7 @@ class EvaluatorMetadataAdmin(admin.ModelAdmin):
'rationale', 'alternate_explanation',
]
list_display = [
'id', 'category', 'description', 'long_description',
'fields_used', 'fields_display',
'id', 'category', 'description', 'fields_used', 'fields_display',
]

def has_add_permission(self, request, obj=None):
Expand Down
18 changes: 17 additions & 1 deletion django/evaluate_m2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.db import models
from django.db.models import JSONField

from django_prose_editor.fields import ProseEditorField

from parse_m2.models import AccountActivity, Metro2Event


Expand All @@ -15,7 +17,21 @@ class Meta:
id = models.CharField(max_length=200, primary_key=True)
category = models.CharField(max_length=200, blank=True)
description = models.TextField(blank=True) # short plain language description
long_description = models.TextField(blank=True)
long_description = ProseEditorField(
extensions={
"Bold": True,
"Italic": True,
"BulletList": True,
"OrderedList": True,
"ListItem": True,
"Link": True,
"Heading": {
"levels": [4]
},
},
sanitize=True, # Built-in server side sanitization
blank=True,
)
fields_used = JSONField(encoder=DjangoJSONEncoder, null=True)
fields_display = JSONField(encoder=DjangoJSONEncoder, null=True)
crrg_reference = models.TextField(blank=True)
Expand Down
3 changes: 2 additions & 1 deletion django/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ gunicorn==25.3.0
whitenoise==6.12.0
smart-open[s3]==7.6.0
yappi==1.7.6
django-prose-editor[sanitize]

# Not required directly by Metro2; pinned to avoid CVEs
certifi==2026.4.22
cryptography==48.0.0
idna==3.15
PyJWT==2.12.1
PyJWT==2.13.0
requests==2.34.2
urllib3==2.7.0
5 changes: 3 additions & 2 deletions front-end/src/pages/Evaluator/overview/EvaluatorOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DOMPurify from 'dompurify'
import Accordion from '@src/components/Accordion/Accordion'
import type EvaluatorMetadata from '@src/types/EvaluatorMetadata'
import type Event from '@src/types/Event'
import type User from '@src/types/User'
import type { ReactElement } from 'react'
import EvaluatorLongDescription from './components/LongDescription'
import EvaluatorMetadataSection from './components/Metadata'
import EvaluatorSummary from './components/Summary'

Expand Down Expand Up @@ -33,7 +33,8 @@ export default function EvaluatorOverview({
<div className='evaluator-metadata'>
<Accordion header='Criteria evaluated'>
<div className='long-description'>
<EvaluatorLongDescription content={metadata.long_description} />
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(metadata.long_description) }}>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love setting inner HTML dangerously.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😈

</div>
</div>
</Accordion>
<Accordion header='How to evaluate these results'>
Expand Down

This file was deleted.

Loading