def update_last_activity(cls, user, discussion_topic_id): """Set the `last_activity_at` for both this user and their team in the given discussion topic. No-op if the user is not a member of the team for this discussion. """ try: membership = cls.objects.get(user=user, team__discussion_topic_id=discussion_topic_id) # If a privileged user is active in the discussion of a team # they do not belong to, do not update their last activity # information. except ObjectDoesNotExist: return now = datetime.utcnow().replace(tzinfo=pytz.utc) membership.last_activity_at = now membership.team.last_activity_at = now membership.team.save() membership.save() emit_team_event('edx.team.activity_updated', membership.team.course_id, { 'team_id': membership.team.team_id, })
def update_last_activity(cls, user, discussion_topic_id): """Set the `last_activity_at` for both this user and their team in the given discussion topic. No-op if the user is not a member of the team for this discussion. """ try: membership = cls.objects.get(user=user, team__discussion_topic_id=discussion_topic_id) # If a privileged user is active in the discussion of a team # they do not belong to, do not update their last activity # information. except ObjectDoesNotExist: return now = datetime.utcnow().replace(tzinfo=pytz.utc) membership.last_activity_at = now membership.team.last_activity_at = now membership.team.save() membership.save() emit_team_event('edx.team.activity_updated', membership.team.course_id, { 'team_id': membership.team_id, })