Skip to content

Commit

Permalink
Further scorelog cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2-1 committed Sep 12, 2016
1 parent 7b5ee6a commit 4bc3a1a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pootle/apps/pootle_statistics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,7 @@ def save(self, *args, **kwargs):

scorelogs_created = []
for score in ScoreLog.get_scorelogs(submission=self):
if 'action_code' in score and score['user'] is not None:
if not isinstance(score["user"], models.Model):
score["user_id"] = score["user"]
del score["user"]
if 'action_code' in score and score['user_id'] is not None:
scorelogs_created.append(ScoreLog(**score))
if scorelogs_created:
self.scorelog_set.add(*scorelogs_created)
Expand Down Expand Up @@ -425,14 +422,14 @@ def get_scorelogs(cls, submission):
reviewer = translator

previous_translator_score = score_dict.copy()
previous_translator_score['user'] = translator
previous_translator_score['user_id'] = translator
previous_reviewer_score = score_dict.copy()
previous_reviewer_score['user'] = reviewer
previous_reviewer_score['user_id'] = reviewer
submitter_score = score_dict.copy()
submitter_score['user'] = submission.submitter
submitter_score['user_id'] = submission.submitter_id
suggester_score = score_dict.copy()
if submission.suggestion is not None:
suggester_score['user'] = submission.suggestion.user
suggester_score['user_id'] = submission.suggestion.user_id

if (submission.field == SubmissionFields.TARGET and
submission.type in SubmissionTypes.EDIT_TYPES):
Expand Down Expand Up @@ -505,7 +502,7 @@ def save(self, *args, **kwargs):
super(ScoreLog, self).save(*args, **kwargs)

User = get_user_model()
User.objects.filter(id=self.user.id).update(
User.objects.filter(id=self.user_id).update(
score=F('score') + self.score_delta
)
self.log()
Expand Down

0 comments on commit 4bc3a1a

Please sign in to comment.