diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 5c55717..155c84c 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -713,6 +713,7 @@ def add_pull_request_flag(session, request, username, percent, comment, url, topic='pull-request.flag.%s' % action, msg=dict( pullrequest=request.to_json(), + flag=pr_flag.to_json(), agent=user_obj.username, ) ) diff --git a/pagure/lib/model.py b/pagure/lib/model.py index a09e5a6..aced64a 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -883,6 +883,23 @@ class PullRequestFlag(BASE): foreign_keys=[pull_request_uid], remote_side=[PullRequest.uid]) + def to_json(self, public=False): + ''' Returns a dictionnary representation of the pull-request. + + ''' + output = { + 'uid': self.uid, + 'pull_request_uid': self.pull_request_uid, + 'username': self.username, + 'percent': self.percent, + 'comment': self.comment, + 'url': self.url, + 'date_created': self.date_created.strftime('%s'), + 'user': self.user.to_json(public=public), + } + + return output + class PagureGroupType(BASE): """