Closed climu closed 4 years ago
So we can show polls in blog posts (here for instance).
I registered machina TopicPoll
as a wagtail snippet added a SnippetChooserBlock
to our streamfield here and adapted machina template a bit in here.
I also had to create a template tag to fetch poll form here
Sadly machina polls views will redirect to the forum post. So after voting or asking to change vote, user will come to forum post and not the blog post.
One would have to subclass TopicPollVoteView to override get_success_url
.
Changing vote should be handled too as machina just add a get param ?change_vote=true
.
Anyway it's a step forward.
So this has created some issue.
For some reasons the above change will refer to TopicPoll
as machina.core.db.models.TopicPoll
in migration file.
Running migrate
will hence raise AttributeError: module 'machina.core.db.models' has no attribute 'TopicPoll'
.
I tried changing the import in home.models
to from machina.apps.forum_conversation.forum_polls.models import TopicPoll
but still migration files will refer to machina.core.db.models.TopicPoll
.
Then I tried importing abstract models as follow:
from machina.apps.forum_conversation.forum_polls.abstract_models import AbstractTopicPoll as TopicPoll
This does makes migrations files consistent since they refer to machina.apps.forum_conversation.forum_polls.abstract_models.AbstractTopicPoll
but we then have error at runtime type object 'AbstractTopicPoll' has no attribute 'objects
.
This was fixed adding TopicPoll.__module__ = "machina.apps.forum_conversation.forum_polls.models"
to home.models
At the moment we cannot render polls in a blog post.
We are using machina polls in forum post. It should be possible to create a poll block for wagtail streamfield reusing machina polls templates and methods.