'Customize save method to set the last_activity_at if it does not
currently exist. Also resets the team\'s size if this model is
being created.'

def save(self, *args, **kwargs):

    should_reset_team_size = False
    if (self.pk is None):
        should_reset_team_size = True
    if (not self.last_activity_at):
        self.last_activity_at = datetime.utcnow().replace(tzinfo=pytz.utc)
    super(CourseTeamMembership, self).save(*args, **kwargs)
    if should_reset_team_size:
        self.team.reset_team_size()
