Resolve "Support PDF generation via a headless Chromium running in the background using celery" #2109

Merged
Owner

Closes #357

Closes #357
Author
Owner

added 2 commits

  • 4eedbe15 - Add support for an additional button and a redirect on success in progress template
  • 09aca710 - Add tools for rendering PDFs with electron-pdf

Compare with previous version

added 2 commits <ul><li>4eedbe15 - Add support for an additional button and a redirect on success in progress template</li><li>09aca710 - Add tools for rendering PDFs with electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4506&start_sha=503b88188fe83fe62b1ed5d18e5f561c79a03830)
Author
Owner

assigned to @nik and unassigned @hansegucker

assigned to @nik and unassigned @hansegucker
Author
Owner

requested review from @lloydmeins

requested review from @lloydmeins
Author
Owner

marked this merge request as ready

marked this merge request as **ready**
Owner

Please use location.replace

cf. https://stackoverflow.com/a/506004

Please use `location.replace` cf. https://stackoverflow.com/a/506004
Owner

s/at/on/ (like you did in JS)

s/at/on/ (like you did in JS)
Owner

Ouch…

  1. Why do you think it is /static? It's as configurable as STATIC_ROOT, so obviously using a hard-coded string is wrong.
  2. Do not simply replace some occurence of a string. It might be anywhere in the path, actually. That's a repeating anti-pattern, so please note it down somewhere ;).
  3. Post-processing a rendered template in such a way is not a good idea (beacuse, well, that's why we have a template engine)
Ouch… 1. Why do you think it is `/static`? It's as configurable as `STATIC_ROOT`, so obviously using a hard-coded string is wrong. 2. Do not simply replace some occurence of a string. It might be anywhere in the path, actually. That's a repeating anti-pattern, so please note it down somewhere ;). 3. Post-processing a rendered template in such a way is not a good idea (beacuse, well, that's why we have a template engine)
Owner

We have (or should have) a tempfile mechanism that depends on site configuration, as to not just dump tempfiles in /tmp. Also, security measure should be taken so as to not leak personal data to system locations readable by other processes that way.

We have (or should have) a tempfile mechanism that depends on site configuration, as to not just dump tempfiles in `/tmp`. Also, security measure should be taken so as to not leak personal data to system locations readable by other processes that way.
Owner

"Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file when done with it."

https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp

"Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file when done with it." https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp
Owner

Actually, the way you call electron-pdf, we could potentially also call it directly in the request context…

Actually, the way you call electron-pdf, we could potentially also call it directly in the request context…
Owner

Are you sure this does not need setting up an X.org environment before calling electron-pdf?

Are you sure this does not need setting up an X.org environment before calling electron-pdf?
Owner

Also, reading https://superuser.com/a/737587, I think you might want to try whether https://wkhtmltopdf.org/ and https://github.com/incuna/django-wkhtmltopdf, both of which are in Debian, are an option instead of electron-pdf.

Also, reading https://superuser.com/a/737587, I think you might want to try whether https://wkhtmltopdf.org/ and https://github.com/incuna/django-wkhtmltopdf, both of which are in Debian, are an option instead of electron-pdf.
Author
Owner

wkhtmltopdf was tested, but it wasn't able to understand modern CSS.

wkhtmltopdf was tested, but it wasn't able to understand modern CSS.
Owner

OK.

OK.
Owner

You could try using subprocess.Popen's pass_fd mechanism to pass open file descriptors to electron-pdf. I tested using /dev/stdin and /dev/stdout, and the latte rworks (the PDF is output to stdout), but it seems stdin is consumed before being read by the DOM loader. Using a separate file descriptor could work, probably using os.pipe.

You could try using `subprocess.Popen`'s `pass_fd` mechanism to pass open file descriptors to electron-pdf. I tested using `/dev/stdin` and `/dev/stdout`, and the latte rworks (the PDF is output to stdout), but it seems stdin is consumed before being read by the DOM loader. Using a separate file descriptor could work, probably using `os.pipe`.
Author
Owner

I'm unsure how to do/test this.

I'm unsure how to do/test this.
Owner

Me neither… but I am experimenting with it.

Me neither… but I am experimenting with it.
Author
Owner

The first two points of your annotation are easy to resolve, but for the last one I have no idea how to solve it. The URLs to CSS files, images etc. are typically built up like "/static/...". These URLs doesn't exist for electron-pdf, so we replace the /static/ stuff by the actual directory of the static files.

The first two points of your annotation are easy to resolve, but for the last one I have no idea how to solve it. The URLs to CSS files, images etc. are typically built up like "/static/...". These URLs doesn't exist for electron-pdf, so we replace the `/static/` stuff by the actual directory of the static files.
Author
Owner

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4641&start_sha=09aca71009ca1594fb0c85ee4c31b83de7ae763c#b30aad4d162aab8afcd08e98fe40c50c064008ab_52_52)
Author
Owner

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4641&start_sha=09aca71009ca1594fb0c85ee4c31b83de7ae763c#8c15ef90a05145592bdded0de1ca9faad06ca049_286_287)
Author
Owner

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4641&start_sha=09aca71009ca1594fb0c85ee4c31b83de7ae763c#967fc52dac05caefc389f7b5af3e363df7227442_34_33)
Author
Owner

added 3 commits

  • 810e5339 - Fix typo
  • 477113a5 - Use location.replace instead of location.href in JavaScript
  • 2f20a2e0 - Improve handling of temporary files in generate_pdf()

Compare with previous version

added 3 commits <ul><li>810e5339 - Fix typo</li><li>477113a5 - Use location.replace instead of location.href in JavaScript</li><li>2f20a2e0 - Improve handling of temporary files in generate_pdf()</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4641&start_sha=09aca71009ca1594fb0c85ee4c31b83de7ae763c)
Author
Owner

I will skip this as we are going to make celery non-optional.

I will skip this as we are going to make celery non-optional.
Author
Owner

added 2 commits

  • e870bfb5 - Improve handling of temporary files in generate_pdf()
  • e4bf1861 - Let generate_pdf() start a virtual X framebuffer for electron-pdf

Compare with previous version

added 2 commits <ul><li>e870bfb5 - Improve handling of temporary files in generate_pdf()</li><li>e4bf1861 - Let generate_pdf() start a virtual X framebuffer for electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4642&start_sha=2f20a2e02a89eb3d6bcf62c01c15945097ab869f)
Owner

Well, why is the URL in the template, then?

Well, why is the URL in the template, then?
Owner

All that temp file handling is quite messy. You should really use a context manager here (context managers are always the bette rchoice for resources that are to be cleand up afterwards). In that regard, you are looking for the TemporaryDirectory class instead of calling mkstemp directly: https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryDirectory (that way, you get a directory, in which you can use your own file names even). You can trust the OS to do the right thing concerning privileges and such that way and do not need an extra setting.

All that temp file handling is quite messy. You should really use a context manager here (context managers are always the bette rchoice for resources that are to be cleand up afterwards). In that regard, you are looking for the `TemporaryDirectory` class instead of calling `mkstemp` directly: https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryDirectory (that way, you get a directory, in which you can use your own file names even). You can trust the OS to do the right thing concerning privileges and such that way and do not need an extra setting.
Author
Owner

Because the URL is resolved correctly by web browsers if the page is opened from a web server.

Because the URL is resolved correctly by web browsers if the page is opened from a web server.
Author
Owner

marked this merge request as draft

marked this merge request as **draft**
Author
Owner

added 97 commits

  • e4bf1861...d23be3b6 - 96 commits from branch master
  • cc607501 - Merge branch 'master' into...

Compare with previous version

added 97 commits <ul><li>e4bf1861...d23be3b6 - 96 commits from branch <code>master</code></li><li>cc607501 - Merge branch &#39;master&#39; into...</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4899&start_sha=e4bf1861c66080d2908ce06d6e180639cb8bd384)
Author
Owner

changed this line in version 5 of the diff

changed this line in [version 5 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4901&start_sha=cc607501219bf4844b4d12bc196794cb7d8a128b#967fc52dac05caefc389f7b5af3e363df7227442_50_44)
Author
Owner

added 1 commit

  • 89415711 - Use non-optional Celery for PDF generation

Compare with previous version

added 1 commit <ul><li>89415711 - Use non-optional Celery for PDF generation</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4901&start_sha=cc607501219bf4844b4d12bc196794cb7d8a128b)
Author
Owner

changed this line in version 6 of the diff

changed this line in [version 6 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4904&start_sha=894157111ac8b75f06f913b74bc5b3f50ace77f6#967fc52dac05caefc389f7b5af3e363df7227442_39_28)
Author
Owner

added 1 commit

  • 17e9d417 - Use TemporaryDirectory for handling of temporary files in PDF generation

Compare with previous version

added 1 commit <ul><li>17e9d417 - Use TemporaryDirectory for handling of temporary files in PDF generation</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=4904&start_sha=894157111ac8b75f06f913b74bc5b3f50ace77f6)
Author
Owner

Done.

Done.
Author
Owner

Any idea?

Any idea?
Owner

In my understanding, the whole concept of this MR is that the page is not opened via a regular web server anymore.

In my understanding, the whole concept of this MR is that the page is not opened via a regular web server anymore.
Author
Owner

Yes, that's the problem.

Yes, that's the problem.
Author
Owner

added 185 commits

  • 17e9d417...030dbb6e - 184 commits from branch master
  • 54d82b91 - Merge branch 'master' into...

Compare with previous version

added 185 commits <ul><li>17e9d417...030dbb6e - 184 commits from branch <code>master</code></li><li>54d82b91 - Merge branch &#39;master&#39; into...</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6477&start_sha=17e9d4176016d9ac895e292a56a90c2ecd2e4cee)
Author
Owner

changed this line in version 9 of the diff

changed this line in [version 9 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6486&start_sha=54d82b9130d86de5324e0440c3dfc8bdde652572#967fc52dac05caefc389f7b5af3e363df7227442_26_25)
Author
Owner

added 1 commit

  • e7fe54d1 - Add absolute URL to all static URLs for printing via electron-pdf

Compare with previous version

added 1 commit <ul><li>e7fe54d1 - Add absolute URL to all static URLs for printing via electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6486&start_sha=54d82b9130d86de5324e0440c3dfc8bdde652572)
Author
Owner

marked this merge request as ready

marked this merge request as **ready**
Author
Owner

I added a new solve option for this in e7fe54d1695f336475565404ac335c00b91f7bec. Could you please check if this could be a good one?

This also needs some little changes in Django Any-JS, so don't just merge.

I added a new solve option for this in e7fe54d1695f336475565404ac335c00b91f7bec. Could you please check if this could be a good one? This also needs some little changes in Django Any-JS, so don't just merge.
Author
Owner

resolved all threads

resolved all threads
lloydmeins commented 2021-03-28 21:31:56 +02:00 (Migrated from edugit.org)

approved this merge request

approved this merge request
Owner

Unrelated whitespace change

Unrelated whitespace change
Owner
        # Start an X framebuffer and run electron-pdf
```suggestion:-0+0 # Start an X framebuffer and run electron-pdf ```
Owner

Then what is the meaning of this comment?

Then what is the meaning of this comment?
Owner

How do you know this display is free? Or why do you even care?

Just let Xvfb choose itself.

(You are probably looking for the xvfb-run command which you can pass the electron-pdf command directly and it does everything necessary)

How do you know this display is free? Or why do you even care? Just let Xvfb choose itself. (You are probably looking for the `xvfb-run` command which you can pass the electron-pdf command directly and it does everything necessary)
Owner

This looks like a view. Why is it not in views.py (and class-based)?

This looks like a view. Why is it not in `views.py` (and class-based)?
Owner

I'm not yet convinced by that.

It does unnecessary requests to the static server, which might not even be reachable from within the AlekSIS server/container. We cannot require the AleKSIS ap perver to have HTTP access to the static files server.

I'm not yet convinced by that. It does unnecessary requests to the static server, which might not even be reachable from within the AlekSIS server/container. We cannot require the AleKSIS ap perver to have HTTP access to the static files server.
Owner

This makes #376 worse. We cannot store such sensitive data in MEDIA_ROOT, without thought about this. Either put it somewhere else and add a view with proper permission checking to retrieve it, or at least make a model forthe result that has the file linked that can leverage the permission checking mechanism we implement globally to solve #376.

This makes #376 worse. We cannot store such sensitive data in `MEDIA_ROOT`, without thought about this. Either put it somewhere else and add a view with proper permission checking to retrieve it, or at least make a model forthe result that has the file linked that can leverage the permission checking mechanism we implement globally to solve #376.
Owner

This clobbers any previous ocntext, including the static_prefix you added further up.

This clobbers any previous ocntext, including the `static_prefix` you added further up.
Owner

Do not forget to test inside Docker, and update the Docker image to contain the necessary dependencies.

Do not forget to test inside Docker, and update the Docker image to contain the necessary dependencies.
Owner

In general, I'm still reluctant to force users to run Chrome on their servers.

In general, I'm still reluctant to **force** users to run Chrome on their servers.
Author
Owner

added 12 commits

  • e7fe54d1...262b664b - 4 commits from branch master
  • e3f97741 - Add support for an additional button and a redirect on success in progress template
  • 34cffc2e - Add tools for rendering PDFs with electron-pdf
  • 0f1a77d3 - Use location.replace instead of location.href in JavaScript
  • daea4090 - Improve handling of temporary files in generate_pdf()
  • d8ddbca7 - Let generate_pdf() start a virtual X framebuffer for electron-pdf
  • 920f0509 - Use non-optional Celery for PDF generation
  • 6e316fb2 - Use TemporaryDirectory for handling of temporary files in PDF generation
  • 5a075e44 - Add absolute URL to all static URLs for printing via electron-pdf

Compare with previous version

added 12 commits <ul><li>e7fe54d1...262b664b - 4 commits from branch <code>master</code></li><li>e3f97741 - Add support for an additional button and a redirect on success in progress template</li><li>34cffc2e - Add tools for rendering PDFs with electron-pdf</li><li>0f1a77d3 - Use location.replace instead of location.href in JavaScript</li><li>daea4090 - Improve handling of temporary files in generate_pdf()</li><li>d8ddbca7 - Let generate_pdf() start a virtual X framebuffer for electron-pdf</li><li>920f0509 - Use non-optional Celery for PDF generation</li><li>6e316fb2 - Use TemporaryDirectory for handling of temporary files in PDF generation</li><li>5a075e44 - Add absolute URL to all static URLs for printing via electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6550&start_sha=e7fe54d1695f336475565404ac335c00b91f7bec)
Author
Owner

No, the previous context is not relevant for the progress template, just for the render_string method.

No, the previous context is not relevant for the progress template, just for the `render_string` method.
Author
Owner

First of all, it looks like the render method. This was the intention because there are views for example in Chronos (timetable) which return a browser version in one case and a print version in an other case. But what I can imagine is to add a class-based view that makes use of this render_pdf method.

First of all, it looks like the `render` method. This was the intention because there are views for example in Chronos (`timetable`) which return a browser version in one case and a print version in an other case. But what I can imagine is to add a class-based view that makes use of this `render_pdf` method.
Author
Owner

marked this merge request as draft

marked this merge request as **draft**
Owner

Do not re-use variable names. if a variable has two meanings in one scope, use two differently-named varibales.

(I have the impression that we discussed this already on another MR less tha na wekk ago ☺)

Do not re-use variable names. if a variable has two meanings in one scope, use two differently-named varibales. (I have the impression that we discussed this already on another MR less tha na wekk ago ☺)
Author
Owner

changed this line in version 11 of the diff

changed this line in [version 11 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6561&start_sha=5a075e440b00b85cde38bd92302b6fd016501b08#90fc1f1fbc4e4d4c861d86cecbdd96f1a56d883d_33_33)
Author
Owner

added 1 commit

  • 367a14b4 - Add absolute URL to all static URLs for printing via electron-pdf

Compare with previous version

added 1 commit <ul><li>367a14b4 - Add absolute URL to all static URLs for printing via electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6561&start_sha=5a075e440b00b85cde38bd92302b6fd016501b08)
Author
Owner

changed this line in version 12 of the diff

changed this line in [version 12 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6569&start_sha=367a14b4fad5396b7f45b8c674364a35bdf13d0f#967fc52dac05caefc389f7b5af3e363df7227442_33_33)
Author
Owner

added 1 commit

  • adb077c4 - Run test with xfvb-run in Docker image

Compare with previous version

added 1 commit <ul><li>adb077c4 - Run test with xfvb-run in Docker image</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6569&start_sha=367a14b4fad5396b7f45b8c674364a35bdf13d0f)
Owner

added 11 commits

  • adb077c4...7d022176 - 10 commits from branch master
  • ddbcf3b6 - Merge branch 'master' into...

Compare with previous version

added 11 commits <ul><li>adb077c4...7d022176 - 10 commits from branch <code>master</code></li><li>ddbcf3b6 - Merge branch &#39;master&#39; into...</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6662&start_sha=adb077c4668b22ffb1e1499578e08875a30bcd74)
Author
Owner

added 1 commit

  • d51458d3 - Run test with xfvb-run in Docker image

Compare with previous version

added 1 commit <ul><li>d51458d3 - Run test with xfvb-run in Docker image</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6667&start_sha=ddbcf3b622664eee7059379b26bf052a23023539)
Author
Owner

added 12 commits

  • d51458d3...7d022176 - 10 commits from branch master
  • 3b7fa96a - Run test with xfvb-run in Docker image
  • fa9747a6 - Merge branch 'master' into...

Compare with previous version

added 12 commits <ul><li>d51458d3...7d022176 - 10 commits from branch <code>master</code></li><li>3b7fa96a - Run test with xfvb-run in Docker image</li><li>fa9747a6 - Merge branch &#39;master&#39; into...</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6669&start_sha=d51458d3663b43037e7a448af0447785f43d911a)
Author
Owner

added 1 commit

  • f08f2953 - Install xorg in Docker for use with electron-pdf

Compare with previous version

added 1 commit <ul><li>f08f2953 - Install xorg in Docker for use with electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6888&start_sha=fa9747a6726c550fa0b41f459f09191b10829c6b)
Author
Owner

added 1 commit

  • d8762574 - Install xorg in Docker for use with electron-pdf

Compare with previous version

added 1 commit <ul><li>d8762574 - Install xorg in Docker for use with electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6891&start_sha=f08f295347b77c9a6fb4bd2cced20ad8848f0032)
Author
Owner

added 1 commit

  • 79076225 - Install xorg in Docker for use with electron-pdf

Compare with previous version

added 1 commit <ul><li>79076225 - Install xorg in Docker for use with electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6893&start_sha=d876257430f177fa83109ae30acac661b601aaf7)
Author
Owner

added 1 commit

  • 2ec48e88 - Install xorg in Docker for use with electron-pdf

Compare with previous version

added 1 commit <ul><li>2ec48e88 - Install xorg in Docker for use with electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6895&start_sha=790762256fb49f2ee1a28539893c9fca819fc530)
Author
Owner

added 1 commit

  • df6b2672 - Install xorg in Docker for use with electron-pdf

Compare with previous version

added 1 commit <ul><li>df6b2672 - Install xorg in Docker for use with electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6899&start_sha=2ec48e88bb5b8ddb374642d653f0cf379cf4aab7)
Author
Owner

changed this line in version 21 of the diff

changed this line in [version 21 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6910&start_sha=df6b267283cdd58dc82c5ba62a46313dbcebee76#967fc52dac05caefc389f7b5af3e363df7227442_32_36)
Author
Owner

changed this line in version 21 of the diff

changed this line in [version 21 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6910&start_sha=df6b267283cdd58dc82c5ba62a46313dbcebee76#967fc52dac05caefc389f7b5af3e363df7227442_62_73)
Author
Owner

added 1 commit

  • c0995406 - Use an headless Chromium instead of electron-pdf

Compare with previous version

added 1 commit <ul><li>c0995406 - Use an headless Chromium instead of electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6910&start_sha=df6b267283cdd58dc82c5ba62a46313dbcebee76)
Author
Owner

changed title from Draft: Resolve "Support PDF generation via {-electron-pdf-} running in the background using celery" to Draft: Resolve "Support PDF generation via {+an headless Chromium+} running in the background using celery"

changed title from **Draft: Resolve "Support PDF generation via {-electron-pdf-} running in the background using celery"** to **Draft: Resolve "Support PDF generation via {+an headless Chromium+} running in the background using celery"**
Author
Owner

added 1 commit

  • 40f11494 - Use a headless Chromium instead of electron-pdf

Compare with previous version

added 1 commit <ul><li>40f11494 - Use a headless Chromium instead of electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6912&start_sha=c0995406f6282f197260d79802f4141bca885f25)
Author
Owner

changed title from Draft: Resolve "Support PDF generation via a{-n-} headless Chromium running in the background using celery" to Draft: Resolve "Support PDF generation via a headless Chromium running in the background using celery"

changed title from **Draft: Resolve "Support PDF generation via a{-n-} headless Chromium running in the background using celery"** to **Draft: Resolve "Support PDF generation via a headless Chromium running in the background using celery"**
Author
Owner

added 1 commit

  • 524b91d7 - Use a headless Chromium instead of electron-pdf

Compare with previous version

added 1 commit <ul><li>524b91d7 - Use a headless Chromium instead of electron-pdf</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6917&start_sha=40f11494d9a29244aaced096c48ebab7220296f1)
Author
Owner

added 12 commits

  • 186c111c - Add support for an additional button and a redirect on success in progress template
  • 875906c2 - Add tools for rendering PDFs with electron-pdf
  • 00e9882a - Use location.replace instead of location.href in JavaScript
  • 6743559d - Improve handling of temporary files in generate_pdf()
  • 707715bb - Let generate_pdf() start a virtual X framebuffer for electron-pdf
  • d397a439 - Use non-optional Celery for PDF generation
  • da0e44bf - Use TemporaryDirectory for handling of temporary files in PDF generation
  • e299f045 - Add absolute URL to all static URLs for printing via electron-pdf
  • 8e0e5b6f - Test electron-pdf with xfvb-run in Docker image
  • 4a76e450 - Install xorg in Docker for use with electron-pdf
  • 205dc4a2 - Use a headless Chromium instead of electron-pdf
  • 1091cda7 - Add a view to test the PDF generation (based on a generic PDF generation view)

Compare with previous version

added 12 commits <ul><li>186c111c - Add support for an additional button and a redirect on success in progress template</li><li>875906c2 - Add tools for rendering PDFs with electron-pdf</li><li>00e9882a - Use location.replace instead of location.href in JavaScript</li><li>6743559d - Improve handling of temporary files in generate_pdf()</li><li>707715bb - Let generate_pdf() start a virtual X framebuffer for electron-pdf</li><li>d397a439 - Use non-optional Celery for PDF generation</li><li>da0e44bf - Use TemporaryDirectory for handling of temporary files in PDF generation</li><li>e299f045 - Add absolute URL to all static URLs for printing via electron-pdf</li><li>8e0e5b6f - Test electron-pdf with xfvb-run in Docker image</li><li>4a76e450 - Install xorg in Docker for use with electron-pdf</li><li>205dc4a2 - Use a headless Chromium instead of electron-pdf</li><li>1091cda7 - Add a view to test the PDF generation (based on a generic PDF generation view)</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=6924&start_sha=524b91d7f58bf8274af97d9cdb1a17ce7962079c)
Author
Owner

changed this line in version 25 of the diff

changed this line in [version 25 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7113&start_sha=1091cda7d8067c2f7ef8e3452607ba063e236fc1#967fc52dac05caefc389f7b5af3e363df7227442_70_77)
Author
Owner

added 5 commits

  • 1091cda7...9ade2048 - 3 commits from branch master
  • b881c8c0 - Merge branch 'master' into...
  • b999f34e - Store references to generated PDF files in DB and generate PDF files by calling an actual URL

Compare with previous version

added 5 commits <ul><li>1091cda7...9ade2048 - 3 commits from branch <code>master</code></li><li>b881c8c0 - Merge branch &#39;master&#39; into...</li><li>b999f34e - Store references to generated PDF files in DB and generate PDF files by calling an actual URL</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7113&start_sha=1091cda7d8067c2f7ef8e3452607ba063e236fc1)
Author
Owner

added 1 commit

  • b03040bd - Store references to generated PDF files in DB and generate PDF files by calling an actual URL

Compare with previous version

added 1 commit <ul><li>b03040bd - Store references to generated PDF files in DB and generate PDF files by calling an actual URL</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7114&start_sha=b999f34e24e1b69dafc3899102aae5d66217b711)
Author
Owner

added 3 commits

  • 827b235c - Add missing import of render_pdf
  • 968caaac - Add selenium test for PDF generation
  • 0ed66417 - Let PDF generation task fail if Chromium doesn't return a success return code

Compare with previous version

added 3 commits <ul><li>827b235c - Add missing import of render_pdf</li><li>968caaac - Add selenium test for PDF generation</li><li>0ed66417 - Let PDF generation task fail if Chromium doesn&#39;t return a success return code</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7167&start_sha=b03040bdd4ccd0838b2785686aa47bc8ae2eba6b)
Author
Owner

added 14 commits

  • 0ed66417...3bfcc9c2 - 9 commits from branch master
  • 9066d31a - Reformat
  • acb973e1 - Rewrite clean up task for PDF files to use PDFFile objects
  • 0913d30c - Add further tests for PDFFile model and clean-up task
  • 08ad3ce8 - Merge branch 'master' into...
  • b80b5d2d - Merge migrations and fix migration order after merge

Compare with previous version

added 14 commits <ul><li>0ed66417...3bfcc9c2 - 9 commits from branch <code>master</code></li><li>9066d31a - Reformat</li><li>acb973e1 - Rewrite clean up task for PDF files to use PDFFile objects</li><li>0913d30c - Add further tests for PDFFile model and clean-up task</li><li>08ad3ce8 - Merge branch &#39;master&#39; into...</li><li>b80b5d2d - Merge migrations and fix migration order after merge</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7223&start_sha=0ed66417ef870410429a03d345a6e1005a059e10)
Author
Owner

resolved all threads

resolved all threads
Author
Owner

changed this line in version 29 of the diff

changed this line in [version 29 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7225&start_sha=b80b5d2d3539ce4c95df5d630d79f71ed3057f2d#967fc52dac05caefc389f7b5af3e363df7227442_98_98)
Author
Owner

added 1 commit

  • 1177b1f9 - Rename context variable in render_pdf to avoid confusion

Compare with previous version

added 1 commit <ul><li>1177b1f9 - Rename context variable in render_pdf to avoid confusion</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7225&start_sha=b80b5d2d3539ce4c95df5d630d79f71ed3057f2d)
Author
Owner

@nik Everything works fine now. The only thing that's missing is the authentication.

@nik Everything works fine now. The only thing that's missing is the authentication.
Author
Owner

added 11 commits

  • 1177b1f9...37d73508 - 9 commits from branch master
  • 1510cc4a - Merge branch 'master' into...
  • 275e6da3 - Introduce secret for PDF files to protect HTML page against unauthorized access

Compare with previous version

added 11 commits <ul><li>1177b1f9...37d73508 - 9 commits from branch <code>master</code></li><li>1510cc4a - Merge branch &#39;master&#39; into...</li><li>275e6da3 - Introduce secret for PDF files to protect HTML page against unauthorized access</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7300&start_sha=1177b1f938a06396eb93bbd32aff49c096ba08b0)
Author
Owner

mentioned in merge request AlekSIS-App-Alsijil!1824

mentioned in merge request AlekSIS-App-Alsijil!1824
Author
Owner

Blocked by #376

Blocked by #376
Author
Owner

marked this merge request as ready

marked this merge request as **ready**
Owner

Unnecessary left-over.

Unnecessary left-over.
Owner

Please move into a function/method used as default on the field.

Please move into a function/method used as `default` on the field.
Owner
    def secret(self) -> str:
```suggestion:-0+0 def secret(self) -> str: ```
Owner
    def html_url(self) -> str:
```suggestion:-0+0 def html_url(self) -> str: ```
Owner

The timeout should be in minutes, and default to something very small (like 3 minutes, or so).

The timeout should be in minutes, and default to something very small (like 3 minutes, or so).
Owner

The HMAC can be re-used for the filename.

The HMAC can be re-used for the filename.
Owner
        return redirect(file_object.file.url)
```suggestion:-0+0 return redirect(file_object.file.url) ```
Owner
https://www.youtube.com/watch?v=Hgx0RTx0aFg
Author
Owner

These people sorting things alphabetically ...

These people sorting things alphabetically ...
Author
Owner

changed this line in version 31 of the diff

changed this line in [version 31 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7331&start_sha=275e6da32e6730c2e3042b44052215a4b0568a3e#2e44ad1f61249cf0440bea20d23bd07cc7f3a61a_990_990)
Author
Owner

changed this line in version 31 of the diff

changed this line in [version 31 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7331&start_sha=275e6da32e6730c2e3042b44052215a4b0568a3e#2e44ad1f61249cf0440bea20d23bd07cc7f3a61a_999_999)
Author
Owner

changed this line in version 31 of the diff

changed this line in [version 31 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7331&start_sha=275e6da32e6730c2e3042b44052215a4b0568a3e#ca5e4a886c594c4b59402dbdbd16348bdbcddf3a_975_975)
Author
Owner

added 1 commit

  • 27f94b46 - Apply 3 suggestion(s) to 2 file(s)

Compare with previous version

added 1 commit <ul><li>27f94b46 - Apply 3 suggestion(s) to 2 file(s)</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7331&start_sha=275e6da32e6730c2e3042b44052215a4b0568a3e)
Author
Owner

changed this line in version 32 of the diff

changed this line in [version 32 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7332&start_sha=27f94b46f9e784f789d9127161cd13ace44075a1#2e44ad1f61249cf0440bea20d23bd07cc7f3a61a_1011_1012)
Author
Owner

changed this line in version 32 of the diff

changed this line in [version 32 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7332&start_sha=27f94b46f9e784f789d9127161cd13ace44075a1#cedfd047579474194a5f10a12c798242313675da_284_284)
Author
Owner

added 1 commit

  • 0246d430 - [PDF] Set default expiration time much shorter and use default attribute

Compare with previous version

added 1 commit <ul><li>0246d430 - [PDF] Set default expiration time much shorter and use default attribute</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7332&start_sha=27f94b46f9e784f789d9127161cd13ace44075a1)
Author
Owner

added 1 commit

  • 1868fd7f - Update poetry.lock to get current dev dependencies

Compare with previous version

added 1 commit <ul><li>1868fd7f - Update poetry.lock to get current dev dependencies</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7333&start_sha=0246d430fc8bcdf7c19afca99e8a3fcce5cb42ad)
Author
Owner

changed this line in version 34 of the diff

changed this line in [version 34 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7395&start_sha=1868fd7f816e7d905f7ee3b4c78cb4cb4ec38fe0#6651ddff6eb82c840ced7c1dddee15c6e1913dd4_36_36)
Author
Owner

added 7 commits

  • 1868fd7f...ee8679da - 6 commits from branch master
  • 29dbcb7b - Merge branch 'master' into...

Compare with previous version

added 7 commits <ul><li>1868fd7f...ee8679da - 6 commits from branch <code>master</code></li><li>29dbcb7b - Merge branch &#39;master&#39; into...</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7395&start_sha=1868fd7f816e7d905f7ee3b4c78cb4cb4ec38fe0)
Author
Owner

added 1 commit

  • 8bf6e49d - Use HMAC secret as filename for generated PDF files

Compare with previous version

added 1 commit <ul><li>8bf6e49d - Use HMAC secret as filename for generated PDF files</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7396&start_sha=29dbcb7b95ae5a973844c14a4ec537ff8d93e6b3)
Author
Owner

changed this line in version 36 of the diff

changed this line in [version 36 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7400&start_sha=8bf6e49dba26bfc3a952e07df4068c90d4ee89b1#967fc52dac05caefc389f7b5af3e363df7227442_88_78)
Author
Owner

added 2 commits

  • 7b228c51 - [PDF] Remove code to replace static and media URLs with absolute URLs
  • 8bbde224 - Use TransactionTestCase for PDFFile tests

Compare with previous version

added 2 commits <ul><li>7b228c51 - [PDF] Remove code to replace static and media URLs with absolute URLs</li><li>8bbde224 - Use TransactionTestCase for PDFFile tests</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7400&start_sha=8bf6e49dba26bfc3a952e07df4068c90d4ee89b1)
Author
Owner

resolved all threads

resolved all threads
Author
Owner

changed this line in version 37 of the diff

changed this line in [version 37 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7402&start_sha=8bbde22471ab4de0e2efffa8a738d0e1e65e2df2#967fc52dac05caefc389f7b5af3e363df7227442_73_70)
Author
Owner

added 1 commit

  • 29fbbeb0 - Update docstrings for PDF generation utils

Compare with previous version

added 1 commit <ul><li>29fbbeb0 - Update docstrings for PDF generation utils</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7402&start_sha=8bbde22471ab4de0e2efffa8a738d0e1e65e2df2)
Owner
    chromium \
```suggestion:-0+0 chromium \ ```
Owner

resolved all threads

resolved all threads
Owner

changed this line in version 38 of the diff

changed this line in [version 38 of the diff](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7405&start_sha=29fbbeb0c90f59b4acaa2e365d74a4bb71d4e50c#6651ddff6eb82c840ced7c1dddee15c6e1913dd4_29_29)
Owner

added 1 commit

Compare with previous version

added 1 commit <ul><li>5168ee93 - Fix escape in Dockerfile</li></ul> [Compare with previous version](/AlekSIS/official/AlekSIS-Core/-/merge_requests/464/diffs?diff_id=7405&start_sha=29fbbeb0c90f59b4acaa2e365d74a4bb71d4e50c)
nik scheduled this pull request to auto merge when all checks succeed 2021-04-17 14:25:54 +02:00
nik merged commit 183a0dbfb0 into master 2021-04-17 14:49:45 +02:00
Owner

mentioned in commit 183a0dbfb0

mentioned in commit 183a0dbfb02dbc47da2454d8a1eab2aed1a324d0
lloydmeins (Migrated from edugit.org) approved these changes 2026-07-30 18:36:07 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aleksis/AlekSIS-Core!2109
No description provided.