~michael.nelson/open-goal-tracker/trunk

« back to all changes in this revision

Viewing changes to src/usergoals/signals.py

  • Committer: Michael Nelson
  • Date: 2011-02-23 06:53:45 UTC
  • mfrom: (68.1.1 update-next-review)
  • Revision ID: michael.nelson@canonical.com-20110223065345-hojewluuqwd4xsr8
Merged update-next-review.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from django.contrib.comments.models import Comment
17
17
from django.db.models.signals import post_save
18
18
 
 
19
from usergoals.usergoalagreements.models import ReviewAgreement
 
20
 
19
21
 
20
22
# Note: to support action streams for goals, the goal should always be
21
23
# the target of each action (ie. for a comment on a step, the target
25
27
    comment = kwargs["instance"]
26
28
    sender = comment.user
27
29
 
 
30
    # If there is a review agreement for the user and goal, we update
 
31
    # the next review time.
 
32
    user_goal = comment.content_object
 
33
    try:
 
34
        agreement = user_goal.reviewagreement_set.get(reviewer=sender)
 
35
        agreement.set_next_review()
 
36
        agreement.save()
 
37
    except ReviewAgreement.DoesNotExist:
 
38
        pass
 
39
 
28
40
    if kwargs.get('created', False):
29
41
        action.send(
30
42
            sender, action_object=comment, verb='commented on',