endlessm / endless-key-app

Endless Key app for Windows (formerly known as kolibri-app)
https://www.endlessos.org/key
MIT License
2 stars 1 forks source link

Fix downloading individual content items #131

Closed wjt closed 1 year ago

wjt commented 1 year ago

We use a Django middleware, AlwaysAuthenticatedMiddleware, which causes unauthenticated requests to be treated as if they were made by an authenticated endless user. We rely on this for certain API endpoints, including the one used to download individual items.

However, this middleware was previously not used, for two reasons:

  1. We were setting the DJANGO_SETTINGS_MODULE environment variable too late, because importing any Kolibri Python module causes this variable to be initialized to a default value. This PR corrects this by setting this variable from the Electron app before it launches the Python code.
  2. Because the settings module is only referred to in a string (and it in turn only refers to the AlwaysAuthenticatedMiddleware as a string), pyinstaller cannot automatically determine that it is used, and does not include it in the app bundle. This PR corrects this by explicitly telling pyinstaller to bundle these modules.

In addition I removed some decoy code that is not actually used, and made a minor CI tweak that helped debug the pyinstaller piece.

Fixes #128