Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
af900a7c
Commit
af900a7c
authored
Jun 10, 2017
by
Gijs Hendriksen
Browse files
Add html entity unescape functionality to event descriptions in the API
parent
cf29cc4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/events/api/serializers.py
View file @
af900a7c
...
...
@@ -2,6 +2,7 @@ from django.templatetags.static import static
from
django.urls
import
reverse
from
django.utils
import
timezone
from
django.utils.html
import
strip_tags
from
html
import
unescape
from
rest_framework
import
serializers
from
events.models
import
Event
,
Registration
...
...
@@ -111,7 +112,7 @@ class EventRetrieveSerializer(serializers.ModelSerializer):
has_fields
=
serializers
.
SerializerMethodField
(
'_has_fields'
)
def
_description
(
self
,
instance
):
return
strip_tags
(
instance
.
description
)
return
unescape
(
strip_tags
(
instance
.
description
)
)
def
_num_participants
(
self
,
instance
):
return
instance
.
num_participants
()
...
...
@@ -145,7 +146,7 @@ class EventListSerializer(serializers.ModelSerializer):
pizza
=
serializers
.
SerializerMethodField
(
'_pizza'
)
def
_description
(
self
,
instance
):
return
strip_tags
(
instance
.
description
)
return
unescape
(
strip_tags
(
instance
.
description
)
)
def
_registered
(
self
,
instance
):
try
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment