Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring transformations to be applied to the filename before #542

Merged
merged 3 commits into from Sep 9, 2019

Conversation

@grembo
Copy link
Contributor

commented May 18, 2019

parsing. The motivation was that files produced by a Brother scanner
wouldn't match paperless' expectations. At most one transformation
is applied (first matching). It won't affect the filename on disk.

This is generic enough so that it is useful for various purposes.
In my case it allows me to use the different hardware buttons on
the scanner to use different profiles, feeding one instance of
paperless with documents of multiple entities and tagging them
accordingly.

Example:

PAPERLESS_FILENAME_PARSE_TRANSFORMS=[{"pattern":"^([a-z]+)_(\\d{8})_(\\d{6})_([0-9]+)\\.", "repl":"\\2\\3Z - \\4 - \\1."},{"pattern":"^([a-z]+)_([0-9]+)\\.", "repl":" - \\2 - \\1."}]

@grembo grembo force-pushed the grembo:master branch from 9c0d86c to aaf9085 May 19, 2019

@grembo

This comment has been minimized.

Copy link
Contributor Author

commented Aug 26, 2019

Note that I extended the pull request to add a protocol to CORS headers, otherwise the following error is generated with recent versions:

SystemCheckError: System check identified some issues:

ERRORS:
?: (corsheaders.E013) Origin 'localhost:8080' in CORS_ORIGIN_WHITELIST is missing scheme or netloc
	HINT: Add a scheme (e.g. https://) or netloc (e.g. example.com).

@grembo grembo changed the title Allow configuring transformations to be applied to the filename before Fix CORS error / Allow configuring transformations to be applied to the filename before Aug 26, 2019

docs/guesswork.rst Outdated Show resolved Hide resolved
src/paperless/settings.py Outdated Show resolved Hide resolved
src/documents/models.py Outdated Show resolved Hide resolved
src/paperless/settings.py Outdated Show resolved Hide resolved

@grembo grembo changed the title Fix CORS error / Allow configuring transformations to be applied to the filename before Allow configuring transformations to be applied to the filename before Aug 31, 2019

Allow configuring transformations to be applied to the filename before
parsing. The motivation was that files produced by a Brother scanner
wouldn't match paperless' expectations. At most one transformation
is applied (first matching). It won't affect the filename on disk.

This is generic enough so that it is useful for various purposes.
In my case it allows me to use the different hardware buttons on
the scanner to use different profiles, feeding one instance of
paperless with documents of multiple entities and tagging them
accordingly.

Example:

PAPERLESS_FILENAME_PARSE_TRANSFORMS=[{"pattern":"^([a-z]+)_(\\d{8})_(\\d{6})_([0-9]+)\\.", "repl":"\\2\\3Z - \\4 - \\1."},{"pattern":"^([a-z]+)_([0-9]+)\\.", "repl":" - \\2 - \\1."}]

@grembo grembo force-pushed the grembo:master branch from d0b92cc to f0320fb Aug 31, 2019

@pitkley pitkley requested a review from the-paperless-project/reviewers Aug 31, 2019

@danielquinn
Copy link
Collaborator

left a comment

This is a great idea, and a slick way to execute it too. Thank you for the contribution! I have a Brother scanner myself and I've long wondered how I might do something like this.

I've asked for a couple changes. Some of them cosmetic, and one show-stopper. I'd also like to request that you add a test for Document.from_path() to account for your changes here. It should be a straightforward test to write as this is a stuff-goes-in-stuff-comes out sort of method, but if you need help, feel free to ask. You can add your test(s) to this class if you like, or to this class. I'm not fussed :-) Cleaning up the locations of our tests is a job for another day.

src/documents/models.py Show resolved Hide resolved
src/documents/models.py Show resolved Hide resolved
src/paperless/settings.py Outdated Show resolved Hide resolved

@grembo grembo force-pushed the grembo:master branch 2 times, most recently from 3e904da to 197486e Sep 8, 2019

@grembo

This comment has been minimized.

Copy link
Contributor Author

commented Sep 8, 2019

I've asked for a couple changes. Some of them cosmetic, and one show-stopper. I'd also like to request that you add a test for Document.from_path() to account for your changes here.

@danielquinn I think I should've addressed all requested changes/concerns now.
@pitkley Sorry for piecemealing today's commits.

@grembo grembo force-pushed the grembo:master branch from 197486e to 0862b3a Sep 8, 2019

@grembo grembo force-pushed the grembo:master branch from 0862b3a to 4f85d9e Sep 8, 2019

@pitkley
pitkley approved these changes Sep 9, 2019
Copy link
Member

left a comment

@grembo no problem :)

@danielquinn danielquinn self-requested a review Sep 9, 2019

@danielquinn danielquinn merged commit 1c95665 into the-paperless-project:master Sep 9, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on master at 57.404%
Details
@danielquinn

This comment has been minimized.

Copy link
Collaborator

commented Sep 9, 2019

Thanks so much for this contribution! Paperless has been getting some top-notch feature additions lately.

@grembo

This comment has been minimized.

Copy link
Contributor Author

commented Sep 9, 2019

You're welcome! Paperless is a really cool project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.