-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: move reused base serializer classes We use a few convenience serializers across our MFE. Currently CharListField, a list of strings, and IsRequiredField, a field converting from text-based "required" string to boolean. This moves them into a base utils file for reuse across our serializers. * feat: add assessment serializers * refactor: move assessment load to page context This lets us load the response for assessment only once and pass that context down to the assessment serializer. This also has the effect of simplifying the assessment serializer. * feat: allow jumping back to peer step
- Loading branch information
Showing
7 changed files
with
593 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Some custom serializer types and utils we use across our MFE | ||
""" | ||
|
||
from rest_framework.fields import BooleanField, CharField, ListField | ||
|
||
|
||
class CharListField(ListField): | ||
""" | ||
Shorthand for serializing a list of strings (CharFields) | ||
""" | ||
|
||
child = CharField() | ||
|
||
|
||
class IsRequiredField(BooleanField): | ||
""" | ||
Utility for checking if a field is "required" to reduce repeated code. | ||
""" | ||
|
||
def to_representation(self, value): | ||
return value == "required" | ||
|
||
|
||
class NullField(CharField): | ||
""" | ||
A field which returns a Null/None value | ||
""" | ||
|
||
def to_representation(self, value): | ||
return None |
Oops, something went wrong.