Commit 84a94c23 by Ned Batchelder

Include a message in the teams.ImmutableMembershipFieldException

Also add a __repr__ to CourseTeam so that it could be useful too.
parent d3f39b2f
......@@ -130,6 +130,9 @@ class CourseTeam(models.Model):
return course_team
def __repr__(self):
return "<CourseTeam team_id={0.team_id}>".format(self)
def add_user(self, user):
"""Adds the given user to the CourseTeam."""
if not CourseEnrollment.is_enrolled(user, self.course_id):
......@@ -172,7 +175,9 @@ class CourseTeamMembership(models.Model):
# an immutable field.
current_value = getattr(self, name, None)
if current_value is not None:
raise ImmutableMembershipFieldException
raise ImmutableMembershipFieldException(
"Field %r shouldn't change from %r to %r" % (name, current_value, value)
)
super(CourseTeamMembership, self).__setattr__(name, value)
def save(self, *args, **kwargs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment