From 79835ccad41157d731d1930e4f0e7e9cb1f109e1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 03 2016 20:34:20 +0000 Subject: Add a JSON representation of a log entry to the DB model --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 50230ef..bdd98bf 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -1614,6 +1614,22 @@ class PagureLog(BASE): remote_side=[PullRequest.uid] ) + def to_json(self, public=False): + ''' Returns a dictionary representation of the issue. + + ''' + output = { + 'id': self.id, + 'description': self.description, + 'date': self.date.strftime('%Y-%m-%d'), + 'date_created': self.date_created.strftime('%s'), + 'user': self.user.to_json(public=public), + #'issue': self.issue.to_json(public=public) if self.issue else None, + #'pull-request': self.pull_request.to_json(public=public) if self.pull_request else None, + #'project': self.project.to_json(public=public) if self.project else None, + } + return output + # # Class and tables specific for the API/token access #