How to use the coderedcms.wagtail_flexible_forms.models.SessionFormSubmission function in coderedcms

To help you get started, we’ve selected a few coderedcms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderedcorp / coderedcms / coderedcms / wagtail_flexible_forms / wagtail_hooks.py View on Github external
unprocessed_submissions_link.short_description = ''
    unprocessed_submissions_link.allow_tags = True

    def edit_link(self, obj):
        return '<a href="%s">%s</a>' % (
            reverse('wagtailadmin_pages:edit', args=(obj.pk,)),
            _('Edit this form page'))
    edit_link.short_description = ''
    edit_link.allow_tags = True


class SubmissionStatusFilter(SimpleListFilter):
    title = _('status')
    parameter_name = 'status'
    unprocessed_status = ','.join((SessionFormSubmission.COMPLETE,
                                   SessionFormSubmission.REVIEWED))

    def lookups(self, request, model_admin):
        yield (self.unprocessed_status, _('Complete or reviewed'))
        for status, verbose_status in SessionFormSubmission.STATUSES:
            if status != SessionFormSubmission.INCOMPLETE:
                yield status, verbose_status

    def queryset(self, request, queryset):
        status = self.value()
        if not status:
            return queryset
        if ',' in status:
            return queryset.filter(status__in=status.split(','))
        return queryset.filter(status=status)
github coderedcorp / coderedcms / coderedcms / wagtail_flexible_forms / wagtail_hooks.py View on Github external
'&amp;status=%s' % SubmissionStatusFilter.unprocessed_status)
    unprocessed_submissions_link.short_description = ''
    unprocessed_submissions_link.allow_tags = True

    def edit_link(self, obj):
        return '<a href="%s">%s</a>' % (
            reverse('wagtailadmin_pages:edit', args=(obj.pk,)),
            _('Edit this form page'))
    edit_link.short_description = ''
    edit_link.allow_tags = True


class SubmissionStatusFilter(SimpleListFilter):
    title = _('status')
    parameter_name = 'status'
    unprocessed_status = ','.join((SessionFormSubmission.COMPLETE,
                                   SessionFormSubmission.REVIEWED))

    def lookups(self, request, model_admin):
        yield (self.unprocessed_status, _('Complete or reviewed'))
        for status, verbose_status in SessionFormSubmission.STATUSES:
            if status != SessionFormSubmission.INCOMPLETE:
                yield status, verbose_status

    def queryset(self, request, queryset):
        status = self.value()
        if not status:
            return queryset
        if ',' in status:
            return queryset.filter(status__in=status.split(','))
        return queryset.filter(status=status)
github coderedcorp / coderedcms / coderedcms / wagtail_flexible_forms / models.py View on Github external
@receiver(post_delete, sender=SessionFormSubmission)
def delete_files(sender, **kwargs):
    instance = kwargs['instance']
    instance.reset_step()
    storage = instance.get_storage()
    for path in instance.get_all_files():
        storage.delete(path)

        # Automatically deletes ancestor folders if empty.
        directory = Path(path)
        while directory.parent != Path(directory.root):
            directory = directory.parent
            try:
                subdirectories, files = storage.listdir(directory)
            except FileNotFoundError:
                continue
            if not subdirectories and not files:
github coderedcorp / coderedcms / coderedcms / models / page_models.py View on Github external
def create_submission_changed_revision(sender, **kwargs):
    if not issubclass(sender, SessionFormSubmission):
        return
    submission = kwargs['instance']
    created = kwargs['created']
    CoderedSubmissionRevision.create_from_submission(
        submission, (CoderedSubmissionRevision.CREATED if created else CoderedSubmissionRevision.CHANGED))  # noqa
github coderedcorp / coderedcms / coderedcms / models / page_models.py View on Github external
def get_submission_class(self):
        """
        Returns submission class.

        You can override this method to provide custom submission class.
        Your class must be inherited from AbstractFormSubmission.
        """

        return FormSubmission


class CoderedSubmissionRevision(SubmissionRevision, models.Model):
    pass


class CoderedSessionFormSubmission(SessionFormSubmission):

    INCOMPLETE = 'incomplete'
    COMPLETE = 'complete'
    REVIEWED = 'reviewed'
    APPROVED = 'approved'
    REJECTED = 'rejected'
    STATUSES = (
        (INCOMPLETE, _('Not submitted')),
        (COMPLETE, _('Complete')),
        (REVIEWED, _('Under consideration')),
        (APPROVED, _('Approved')),
        (REJECTED, _('Rejected')),
    )
    status = models.CharField(max_length=10, choices=STATUSES, default=INCOMPLETE)

    def create_normal_submission(self, delete_self=True):