wagtail icon indicating copy to clipboard operation
wagtail copied to clipboard

Implement bulk actions for form submissions

Open rohitsrma opened this issue 1 year ago • 4 comments

Fixes #8182

ezgif com-video-to-gif-converter

rohitsrma avatar Apr 13 '24 21:04 rohitsrma

Manage this branch in Squash

Test this branch here: https://rohitsrmaimplement-bulk-action-g2x2y.squash.io

squash-labs[bot] avatar Apr 13 '24 21:04 squash-labs[bot]

The current changes I've made aren't working when using CustomFormSubmission. The problem arises because the FormSubmission model doesn't have direct access to these custom models. When a CustomFormSubmission is used, the data gets saved in a different queryset. This means that to access this queryset, I must use the get_submission_class() method provided by FormMixin (or something else i am not aware of).

So, I'm not sure how I can access this custom model. It seems like I need to use the get_submission_class()method to get the correct model class for the submissions, when dealing with CustomFormSubmission. However, I'm unsure how to integrate this method into FormSubmissionBulkAction to correctly handle both FormSubmission and CustomFormSubmission.

I'm trying to hack something but, it would be incredibly helpful to get some guidance from a core team member on how to proceed.

rohitsrma avatar Apr 16 '24 13:04 rohitsrma

I've made progress with my FormSubmissionBulkAction class by updating it as follows:

class FormSubmissionBulkAction(BulkAction):
    
    @classproperty
    def models(cls):
        page = Page.objects.get(id=70).specific
        submission_class = page.get_submission_class()
        return [submission_class]

This works well for both FormSubmission and CustomFormSubmission when I manually provide the ID of the form page. But, I'm not sure how we can automatically fetch the page ID within the FormSubmissionBulkAction class, similar to how we do it in our views.

@gasman / @laymonage , could you please provide some guidance on how I can retrieve the form page information within my FormSubmissionBulkAction class?

rohitsrma avatar Apr 17 '24 13:04 rohitsrma