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

readable receipt file names in default export #1275

Closed
MarcusWolschon opened this issue Jan 10, 2022 · 4 comments
Closed

readable receipt file names in default export #1275

MarcusWolschon opened this issue Jan 10, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@MarcusWolschon
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When exporting a single or multiple/all receipts, the individual zip files are currently just named 1.zip, 2,zip, 3.zip,...

Describe the solution you'd like
The name of the receipt with all illegal characters removed and a length limit should be used as the file name.
If this causes collisions, either _1.zip, _2.zip could be added as needed or all receipts get their id number as a postfix.

Additional context
This also allows storing some exported receipts on a shared Nextcloud or other file storage that multiple users share.
Each with their own receipt applications (not all of them Tandoor Receipts) or using the receipts manually. (e.g. by having an exported PDF in each receipt in addition to the machine readable version and the image file.)

@MarcusWolschon MarcusWolschon added the enhancement New feature or request label Jan 10, 2022
@MarcusWolschon
Copy link
Contributor Author

Shell script to rename a directory of already exported 1.zip 2.zip .... into readable .zip file names that Tandoor will still recognize

for file in *.zip ; do 
   mkdir temp ; 
   cd temp; 
   unzip ../$file ; 
   NEWNAME=$(cat recipe.json | sed -e "s#{\"name\":\"##" | sed -e "s#\".*##" | sed s/[ä]/ae/g | sed s/[ü]/ue/g | sed s/[ö]/oe/g | sed s/[^a-zA-Z0-9_]/_/g) ; 
   cd .. ; 
   rm -r temp ; 
   mv $file $NEWNAME.zip ; 
done

@MarcusWolschon MarcusWolschon changed the title readable receipt names in default export readable receipt file names in default export Jan 10, 2022
@MarcusWolschon
Copy link
Contributor Author

Proposal:

In cookbook/integration/default.py line 59 use the sanitized receipt name

MarcusWolschon added a commit to MarcusWolschon/AdvancedRecipes that referenced this issue Jan 11, 2022
TandoorRecipes#1275 readable receipt file names in default export
@MarcusWolschon MarcusWolschon mentioned this issue Jan 11, 2022
@MarcusWolschon
Copy link
Contributor Author

Issued a pull request with a fix:
#1280

@vabene1111
Copy link
Collaborator

i think i want to add a "slug" field to recipes which should be unqiue to a recipe. This would also allow to link recipes together after an import, that is currently not possible.

i will merge the PR for now as i think this is already an improvement but in the long run i will rewrite this to a "slug" system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants