Giter Club home page Giter Club logo

Comments (4)

denilsonsa avatar denilsonsa commented on June 9, 2024

Worth mentioning: I have not tested any of the other form fields. I have not tested any of the other trigger types (and I know those will lead to different form fields).

Whoever investigates (and fixes) this bug, please take a look at all form fields to make sure they all behave consistently.

from paperless-ngx.

stumpylog avatar stumpylog commented on June 9, 2024

To a certain extent, this is user error. It seems clear enough that no sources will match nothing. We can probably add some validation to prevent empty sources though

from paperless-ngx.

denilsonsa avatar denilsonsa commented on June 9, 2024

In my humble opinion, it's not "clear enough".

Following the logic of "no sources will match nothing", we would expect that no filter path will match nothing as well. It's inconsistent among the form fields.

I believe the best option is to make "no sources" simply disable the source-checking, just like empty path also disables the path-checking.

If that is not possible, I agree with you regarding adding some validation to warn the user about invalid trigger conditions.


(EDIT) I did a quick research in the codebase:

  • Tag filter is only active if the trigger has any tag defined:

    if (
    trigger.filter_has_tags.all().count() > 0
    and document.tags.filter(
    id__in=trigger.filter_has_tags.all().values_list("id"),
    ).count()
    == 0
    ):

  • Correspondent filter is only active if the correspondent was set in the trigger:

    if (
    trigger.filter_has_correspondent is not None
    and document.correspondent != trigger.filter_has_correspondent
    ):

  • Document type filter is only active if the document type was set in the trigger:

    if (
    trigger.filter_has_document_type is not None
    and document.document_type != trigger.filter_has_document_type
    ):

  • Filename filter is only active if the filename glob was set in the trigger:

    if (
    trigger.filter_filename is not None
    and len(trigger.filter_filename) > 0
    and document.original_filename is not None
    and not fnmatch(
    document.original_filename.lower(),
    trigger.filter_filename.lower(),
    )
    ):
    and
    if (
    trigger.filter_filename is not None
    and len(trigger.filter_filename) > 0
    and not fnmatch(
    document.original_file.name.lower(),
    trigger.filter_filename.lower(),
    )
    ):

  • Mailrule filter is only active if it was set in the trigger:

    if (
    document.mailrule_id is not None
    and trigger.filter_mailrule is not None
    and document.mailrule_id != trigger.filter_mailrule.pk
    ):

  • And, yet, the document source is always active, regardless if it was set in the trigger or left empty:

    if document.source not in [int(x) for x in list(trigger.sources)]:

It really sounds like an oversight, and I think it leads to surprising behavior for the user.

from paperless-ngx.

github-actions avatar github-actions commented on June 9, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns. See our contributing guidelines for more details.

from paperless-ngx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.