def post(self, request, *args, **kwargs):
        self.init_attachment_cache()

        # Stores a boolean indicating if we are considering a preview
        self.preview = 'preview' in self.request.POST

        # Initializes the forms
        post_form_class = self.get_post_form_class()
        post_form = self.get_post_form(post_form_class)
        attachment_formset_class = self.get_attachment_formset_class()
        attachment_formset = self.get_attachment_formset(attachment_formset_class)
        poll_option_formset_class = self.get_poll_option_formset_class()
        poll_option_formset = self.get_poll_option_formset(poll_option_formset_class)

        post_form_valid = post_form.is_valid()
        attachment_formset_valid = attachment_formset.is_valid() if attachment_formset \
            else None
        poll_option_formset_valid = poll_option_formset.is_valid() if poll_option_formset \
            and len(post_form.cleaned_data['poll_question']) else None

        self.attachment_preview = self.preview if attachment_formset_valid else None
        self.poll_preview = self.preview if poll_option_formset_valid else None

        poll_options_validated = poll_option_formset_valid is not None
        if post_form_valid and attachment_formset_valid is not False \
                and poll_option_formset_valid is not False:
            return self.form_valid(
                post_form, attachment_formset, poll_option_formset,
                poll_options_validated=poll_options_validated)
        else:
            return self.form_invalid(
                post_form, attachment_formset, poll_option_formset,
                poll_options_validated=poll_options_validated)
dataset/ETHPy150Open ellmetha/django-machina/machina/apps/forum_conversation/views.py/BaseTopicFormView.post/original