-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix jsonapi returns None for sample's DateOfBirth field (#114)
* Added a field manager for AgeDateOfBirthField * Fix NameError: name 'IAgeDateOfBirthField' is not defined * Changelog
- Loading branch information
Showing
7 changed files
with
43 additions
and
0 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 @@ | ||
# -*- coding: utf-8 -*- |
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,8 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<!-- Adapter for senaite.patient's AT AgeDateOfBirthField --> | ||
<adapter | ||
for="senaite.patient.interfaces.IAgeDateOfBirthField" | ||
factory=".fieldmanagers.AgeDateOfBirthFieldManager"/> | ||
|
||
</configure> |
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,21 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from senaite.jsonapi import api | ||
from senaite.jsonapi.fieldmanagers import ATFieldManager | ||
from senaite.jsonapi.interfaces import IFieldManager | ||
from zope import interface | ||
|
||
|
||
class AgeDateOfBirthFieldManager(ATFieldManager): | ||
"""Adapter to get/set the value of AT's AgeDateOfBirthField | ||
""" | ||
interface.implements(IFieldManager) | ||
|
||
def json_data(self, instance, default=None): | ||
"""Get a JSON compatible value | ||
""" | ||
dob = self.field.get_date_of_birth(instance) | ||
from_age = self.field.get_from_age(instance) | ||
estimated = self.field.get_estimated(instance) | ||
|
||
return [api.to_iso_date(dob), from_age, estimated] |