Skip to content

Commit

Permalink
Add get_contributors to log util
Browse files Browse the repository at this point in the history
  • Loading branch information
phlax committed May 22, 2017
1 parent fcde211 commit 4741ef2
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions pootle/apps/pootle_log/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ class ComparableLogEvent(BaseProxy):
if x not in ["__lt__", "__gt__", "__call__"])

def __cmp__(self, other):
# valuable revisions are authoritative
if self.revision is not None and other.revision is not None:
if self.revision > other.revision:
return 1
elif self.revision < other.revision:
return -1

# timestamps have the next priority
if self.timestamp and other.timestamp:
if self.timestamp > other.timestamp:
Expand Down Expand Up @@ -302,6 +295,27 @@ def get_events(self, **kwargs):
for event in self.get_submission_events(**kwargs):
yield event

def get_contributors(self, **kwargs):
event_sources = kwargs.pop(
"event_sources",
("submission", "suggestion", "unit_source"))
users = set()
if "unit_source" in event_sources:
for event in self.get_created_unit_events(**kwargs):
if event.user not in users and not event.user.username == "system":
yield event.user
users.add(event.user)
if "suggestion" in event_sources:
for event in self.get_suggestion_events(**kwargs):
if event.user not in users and not event.user.username == "system":
yield event.user
users.add(event.user)
if "submission" in event_sources:
for event in self.get_submission_events(**kwargs):
if event.user not in users and not event.user.username == "system":
yield event.user
users.add(event.user)


class StoreLog(Log):
include_meta = True
Expand Down

0 comments on commit 4741ef2

Please sign in to comment.