mindwaveventures / good-thinking

Good Thinking
https://www.good-thinking.uk
4 stars 1 forks source link

Thumbs up/Thumbs down not showing in Wagtail #795

Closed ellemindwave closed 6 years ago

ellemindwave commented 6 years ago

In Wagtail, there doesn't seem to be a way to see the sum of all the thumbs up/thumbs down for a resource, just the individual data points in the 'Forms' area of Wagtail. It would be great to be able to see this somewhere, but not sure if it is possible.

screen shot 2017-12-15 at 09 51 14

reddog commented 6 years ago

Further information:

For example, Sleepio has 10 thumbs up and 8 thumbs down - but only showing 1 thumbs up and 1 thumbs down on Wagtail. https://www.good-thinking.uk/admin/forms/submissions/129/?p=2&ordering=

reddog commented 6 years ago

Using resource Sleepio as an example.

This resource appears on the Sleep Deprived landing page where it is showed with 11 thumbs up and 8 thumbs down. See https://www.good-thinking.uk/sleep-deprived/

It's own resource page is at https://www.good-thinking.uk/resources/sleepio-london/ This also shows 11 thumbs up and 8 thumbs down.

The database directly shows the same thumbs up/down total using the query

select * from likes_likes where resource_id=37;

The admin form submissions page for this resource at https://www.good-thinking.uk/admin/forms/submissions/37/ gives an Internal Server Error.

reddog commented 6 years ago

Server error log shows:

2017-12-15T10:26:29.306252+00:00 app[web.3]: ERROR:django.request:Internal Server Error: /admin/forms/submissions/37/
2017-12-15T10:26:29.306275+00:00 app[web.3]: Traceback (most recent call last):
2017-12-15T10:26:29.306276+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 42, in inner
2017-12-15T10:26:29.306277+00:00 app[web.3]:     response = get_response(request)
2017-12-15T10:26:29.306278+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
2017-12-15T10:26:29.306279+00:00 app[web.3]:     response = self.process_exception_by_middleware(e, request)
2017-12-15T10:26:29.306280+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
2017-12-15T10:26:29.306281+00:00 app[web.3]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
2017-12-15T10:26:29.306281+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/views/decorators/cache.py", line 43, in _cache_controlled
2017-12-15T10:26:29.306282+00:00 app[web.3]:     response = viewfunc(request, *args, **kw)
2017-12-15T10:26:29.306282+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/wagtail/wagtailadmin/decorators.py", line 27, in decorated_view
2017-12-15T10:26:29.306283+00:00 app[web.3]:     return view_func(request, *args, **kwargs)
2017-12-15T10:26:29.306284+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/wagtail/wagtailforms/views.py", line 69, in list_submissions
2017-12-15T10:26:29.306285+00:00 app[web.3]:     data_fields = form_page.get_data_fields()
2017-12-15T10:26:29.306285+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/wagtail/wagtailforms/models.py", line 191, in get_data_fields
2017-12-15T10:26:29.306286+00:00 app[web.3]:     for field in self.get_form_fields()
2017-12-15T10:26:29.306286+00:00 app[web.3]:   File "/app/.heroku/python/lib/python3.6/site-packages/wagtail/wagtailforms/models.py", line 179, in get_form_fields
2017-12-15T10:26:29.306287+00:00 app[web.3]:     return self.form_fields.all()
2017-12-15T10:26:29.306295+00:00 app[web.3]: AttributeError: 'NoneType' object has no attribute 'all'
reddog commented 6 years ago

There are two types of user feedback:

User clicks on the thumbs up/down icons are stored in the likes_likes table with information connecting a code assigned to a given user and the resource ID - this allows the site to ensure that users do not re-vote for a given resource.

Feedback (eg when visiting a resource's site and returning to GT to give feedback like "the app really helped me out") is stored as a Wagtail form feedback response (resources are actually created as Wagtail forms behind the scenes), see http://docs.wagtail.io/en/v1.13.1/reference/contrib/forms/index.html

Feedback for resources is not stored against the individual resource but rather the resource index page (where information for the resource and the feedback are stored together).

An admin view of per-resource and/or total likes/dislikes could be created.

@ellemindwave Can you decide whereabouts you might like to see this information? I can then feedback on how easy that particular option would be.

reddog commented 6 years ago

Test page created with a Wagtail ModelAdmin class object, see http://docs.wagtail.io/en/v1.13.1/reference/contrib/modeladmin/indexview.html

image

Test page at https://ldmw-staging.herokuapp.com/admin/resources/resourcepage/

Code at https://github.com/mindwaveventures/cms/commit/cf6b876978f98c26811b1efae0210d08c14e05e4

Awiting feedback from @ellemindwave

ellemindwave commented 6 years ago

@reddog This looks good to me - thanks! Good to push to the live Wagtail 👍

ellemindwave commented 6 years ago

test test test