Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultipleObjectsReturned at /admin/wagtail_review/reviews/2/view/ #7

Open
AdrienLemaire opened this issue Apr 19, 2019 · 1 comment · May be fixed by #15
Open

MultipleObjectsReturned at /admin/wagtail_review/reviews/2/view/ #7

AdrienLemaire opened this issue Apr 19, 2019 · 1 comment · May be fixed by #15

Comments

@AdrienLemaire
Copy link
Contributor

AdrienLemaire commented Apr 19, 2019

Exception Value: | get() returned more than one Reviewer -- it returned 2!
Traceback
Environment:


Request Method: GET
Request URL: http://localhost:8000/admin/wagtail_review/reviews/2/view/

Django Version: 2.1.8
Python Version: 3.7.3
Installed Applications:
['home',
 'blog',
 'search',
 'wagtail.contrib.forms',
 'wagtail.contrib.redirects',
 'wagtail.embeds',
 'wagtail.sites',
 'wagtail.users',
 'wagtail.snippets',
 'wagtail.documents',
 'wagtail.images',
 'wagtail.search',
 'wagtail.admin',
 'wagtail.core',
 'modelcluster',
 'taggit',
 'wagtail_review',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'wagtail.core.middleware.SiteMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware']



Traceback:

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/wagtail/admin/urls/__init__.py" in wrapper
  102.             return view_func(request, *args, **kwargs)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/wagtail/admin/decorators.py" in decorated_view
  34.             return view_func(request, *args, **kwargs)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/wagtail_review/views/admin.py" in view_review_page
  133.         reviewer = review.reviewers.get(user=request.user)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method
  82.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/home/dori/.virtualenvs/project/lib/python3.7/site-packages/django/db/models/query.py" in get
  403.             (self.model._meta.object_name, num)

Exception Type: MultipleObjectsReturned at /admin/wagtail_review/reviews/2/view/
Exception Value: get() returned more than one Reviewer -- it returned 2!

Steps:

  • Install wagtail and follow getting started tutorial v2.4
  • Install wagtail-review
  • As admin, create 4 articles, and ask a review for the fourth post (I believe).
  • Login as editor, go to Reviews, but only the 3rd post (unpublished) appear (did I mistakenly ask a review for the 3rd post instead of the 4th?)
  • As editor, go as a review to self for the 4th post
  • from Reviews, click on the 4th post, the error happens.

Seeing 2 issues here:

  • review request from admin didn't show up in Reviews
  • Multiple reviewers (actually the same user twice) can be assigned to a post, but wagtail-review doesn't support it (wagtail_review/views/admin.py l.133)
@AdrienLemaire
Copy link
Contributor Author

AdrienLemaire commented Apr 19, 2019

Sorry for the lack of clarity, I'm just getting started with WagTail and don't yet understand the details behind it.

Here what I can see from a shell

In [27]: rf = Review.objects.first()

In [28]: PageRevision.objects.get(id=rf.page_revision_id)                                                   
Out[28]: <PageRevision: "Third post unpublished" at 2019-04-19 07:02:40.572529+00:00>                       

In [29]: [User.objects.get(id=r.user_id) for r in rf.reviewers.all()]                                       
Out[29]: [<User: Reviewer>, <User: dori>]

In [30]: rl = Review.objects.last()

In [31]: PageRevision.objects.get(id=rl.page_revision_id)                                                   
Out[31]: <PageRevision: "4th post to review" at 2019-04-19 07:04:40.425567+00:00>                           

In [32]: [User.objects.get(id=r.user_id) for r in rl.reviewers.all()]                                       
Out[32]: [<User: Reviewer>, <User: Reviewer>]

I do not know why my 3rd post has 2 reviewers. Is there some logic where unpublishing a post auto-assign reviewers? Strange... Also, no error happens when viewing it.

screenshot

I suppose the relevant bug report here is that the same user can be assigned twice for the same review, which causes a 500 error. Why the review made as admin didn't show up first in the user Reviews page is another concern.

@yedpodtrzitko yedpodtrzitko linked a pull request Aug 23, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant