Esempio n. 1
0
 def serialize_topic(self, topic_obj):
     return {
         "id": topic_obj.pk,
         "description": topic_obj.description,
         "created": _encode_datetime(topic_obj.creationdate),
         "source": self.serialize_source(topic_obj.source),
     }
Esempio n. 2
0
    def serialize_selection(self, selection_obj):
        if selection_obj.user is not None:
            username = selection_obj.user.username
        else:
            username = None

        return {
            "id": selection_obj.pk,
            "paragraph_id": selection_obj.paragraph_id,
            "source": self.serialize_source(selection_obj.source),
            "start": selection_obj.startLetter,
            "end": selection_obj.endLetter,
            "topic": self.serialize_topic(selection_obj.topic),
            "user": username,
            "created": _encode_datetime(selection_obj.creationdate),
        }