Beispiel #1
0
    def serialize(self, with_users=False):
        data = {
            "id":
            self.external_id,
            "name":
            self.name,
            "createdAt":
            iso_datetime_format(self.created_at),
            "lockedAt":
            iso_datetime_format(self.locked_at),
            "downloadedAt":
            iso_datetime_format(self.downloaded_at),
            "readyToAssessAt":
            iso_datetime_format(self.ready_to_assess_at),
            "stillAssessingAt":
            iso_datetime_format(self.still_assessing_at),
            "active":
            self.active,
            "outcome":
            self.outcome.serialize() if self.outcome is not None else None,
        }

        if with_users:
            data['users'] = [{
                k: v
                for k, v in user.serialize().items()
                if k in {'active', 'emailAddress', 'id', 'name', 'role'}
            } for user in self.users]

        return data
 def serialize(self):
     resolved_search_url = urljoin(current_app.config['DM_SEARCH_API_URL'], self.search_url)
     return {
         "id": self.id,
         "createdBy": self.created_by,
         "projectId": self.project.external_id,
         "createdAt": iso_datetime_format(self.created_at),
         "searchedAt": iso_datetime_format(self.searched_at),
         "searchUrl": resolved_search_url,
         "active": self.active
     }
Beispiel #3
0
 def serialize(self):
     resolved_search_url = urljoin(current_app.config['DM_SEARCH_API_URL'], self.search_url)
     return {
         "id": self.id,
         "createdBy": self.created_by,
         "projectId": self.project.external_id,
         "createdAt": iso_datetime_format(self.created_at),
         "searchedAt": iso_datetime_format(self.searched_at),
         "searchUrl": resolved_search_url,
         "active": self.active
     }
    def serialize(self, with_users=False):
        data = {
            "id": self.external_id,
            "name": self.name,
            "createdAt": iso_datetime_format(self.created_at),
            "lockedAt": iso_datetime_format(self.locked_at),
            "downloadedAt": iso_datetime_format(self.downloaded_at),
            "readyToAssessAt": iso_datetime_format(self.ready_to_assess_at),
            "stillAssessingAt": iso_datetime_format(self.still_assessing_at),
            "active": self.active,
            "outcome": self.outcome.serialize() if self.outcome is not None else None,
        }

        if with_users:
            data['users'] = [
                {k: v for k, v in user.serialize().items() if k in {'active', 'emailAddress', 'id', 'name', 'role'}}
                for user in self.users
            ]

        return data
def test_iso_datetime_format(dt, formatted_datetime):
    assert iso_datetime_format(dt, 'my_default') == formatted_datetime