caktus/pycon — pull request #133 by dpoirier (2013-07-10 14:31:55+00:00)
Title: Duplicate memberships

Seeing this on staging:

Traceback (most recent call last):

File "/srv/staging-pycon.python.org/shared/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/srv/staging-pycon.python.org/shared/env/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
return view_func(request, *args, **kwargs)

File "/srv/staging-pycon.python.org/releases/952b082533e841b6522bb27d257c949638d62671/symposion/teams/views.py", line 59, in team_detail
state = team.get_state_for_user(request.user)

File "/srv/staging-pycon.python.org/releases/952b082533e841b6522bb27d257c949638d62671/symposion/teams/models.py", line 41, in get_state_for_user
return self.memberships.get(user=user).state

File "/srv/staging-pycon.python.org/shared/env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 143, in get
return self.get_query_set().get(*args, **kwargs)

File "/srv/staging-pycon.python.org/shared/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 393, in get
(self.model._meta.object_name, num, kwargs))

MultipleObjectsReturned: get() returned more than one Membership -- it returned 2! Lookup parameters were {'user': }

It looks like:

* Membership needs to be unique on (user, team)
* We need to figure out where the dupes are getting created
* We need to fix the data.