1 ''' |
1 ''' |
2 field serializing and deserializing metacategorization protocols |
2 field serializing and deserializing metacategorization protocols |
3 ''' |
3 ''' |
4 import logging |
4 import logging |
5 |
5 |
|
6 from notes import settings |
6 from rest_framework import serializers |
7 from rest_framework import serializers |
7 |
8 |
8 logger = logging.getLogger(__name__) |
9 logger = logging.getLogger(__name__) |
9 |
10 |
10 class ProtocolField(serializers.Field): |
11 class ProtocolField(serializers.Field): |
15 # not just the field attribute. |
16 # not just the field attribute. |
16 return obj |
17 return obj |
17 |
18 |
18 def to_representation(self, obj): |
19 def to_representation(self, obj): |
19 logger.debug("ProtocolField.to_representation %r", obj) |
20 logger.debug("ProtocolField.to_representation %r", obj) |
20 return { |
21 return settings.NOTES_SETTINGS['PROTOCOL'] |
21 "id": "a4977c1f-4752-4aff-b724-eec4033af25c", |
|
22 "owner": "group1", |
|
23 "revision": "1", |
|
24 "description": "Cras rutrum lacinia pretium. Suspendisse justo est, tincidunt sed tellus a, sodales suscipit risus. Curabitur odio tortor, tincidunt sed est nec, ullamcorper sodales velit.", |
|
25 "metacategories": [{ |
|
26 "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d", |
|
27 "revision": 2, |
|
28 "base": "ef14bcce-52ac-44ba-a7d1-f1441bab94de", |
|
29 "name": "référence", |
|
30 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin massa nibh, hendrerit quis justo vitae, luctus tempor dolor. Nam quis fringilla diam.", |
|
31 "color": "#2cbfff", |
|
32 "has_comment": False |
|
33 }] |
|
34 } |
|
35 |
22 |
36 def to_internal_value(self, data): |
23 def to_internal_value(self, data): |
37 logger.debug("ProtocolField.to_internal_value %r", data) |
24 logger.debug("ProtocolField.to_internal_value %r", data) |
38 return "base protocol" |
25 return "base protocol" |
39 |
26 |