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

[feature] Added a Custom Static Storage #172

Merged

Conversation

Arsh0023
Copy link
Contributor

@Arsh0023 Arsh0023 commented Mar 3, 2021

Ported changes from storage.py in ansible-openwisp2 to storage.py in openwisp_utils/

Added documentation and written test for CompressStaticFilesStorage in openwisp_utils.storage
In documentation created a separate storage utilities section and in settings added OPENWISP_STATICFILES_VERSIONED_EXCLUDE.

Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Fixes #166

Copy link
Member

@pandafy pandafy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arsh0023 you will have to add django-compress-staticfiles~=1.0.1b dependency in setup.py, here

install_requires=['django-model-utils>=4.0.0,<4.1.0'],

@Arsh0023 link the respective issue in the PR description. Also read the commit message style guidelines of OpenWISP.

@pandafy
Copy link
Member

pandafy commented Mar 4, 2021

Dependencies installed in requirements-test.txt are only installed to facilitate running of tests in CI. Since this feature relies on django-compress-staticfiles, we will have to mention it in setup.py of the project. So when someone installs openwisp-utils, django-compress-staticfiles is automatically installed. You can read this blog to learn about python modules and packaging.

@coveralls
Copy link

coveralls commented Mar 5, 2021

Coverage Status

Coverage increased (+0.02%) to 99.295% when pulling c976c1c on Arsh0023:issues/166-add-custom-static-storage into 2845916 on openwisp:master.

@Arsh0023
Copy link
Contributor Author

Arsh0023 commented Mar 5, 2021

@pandafy i have added django-compress-staticfiles~=1.0.1b in install_requires in setup.py and also linked the issue.

@Arsh0023 Arsh0023 requested a review from pandafy March 9, 2021 08:26
Copy link
Member

@pandafy pandafy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress @Arsh0023!

I am not entirely convinced the testing methodology here. But, I can't think of something better at the moment. I will share them later, but meanwhile you can address following requested changes.

README.rst Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
openwisp_utils/storage.py Outdated Show resolved Hide resolved
tests/test_project/tests/test_storage.py Outdated Show resolved Hide resolved
tests/test_project/tests/test_storage.py Outdated Show resolved Hide resolved
@Arsh0023
Copy link
Contributor Author

Thanks @pandafy @nemesisdesign for the review i have tried to address the requested changes
@nemesisdesign now it creates a folder with name test_storage_dir in the BASE_DIR and all the test files are created in that folder and finally that folder is deleted in the tearDownClass .

README.rst Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
@Arsh0023 Arsh0023 force-pushed the issues/166-add-custom-static-storage branch from c38a79b to cadeb7a Compare March 12, 2021 08:17
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only this is remaining: #172 (comment)

The rest looks good, what do you think @pandafy?

Arsh0023 and others added 10 commits March 22, 2021 09:14
…P_STATICFILES_VERSIONED_EXCLUDE

Fixed merging conflicts with the master
…#166

Ported changes from  storage.py in ansible-openwisp2 to storage.py in openwisp_utils/.
Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.
…#166

Ported changes from  storage.py in ansible-openwisp2 to storage.py in openwisp_utils/
Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Fixes openwisp#166
…#166

Ported changes from  storage.py in ansible-openwisp2 to storage.py in openwisp_utils/
Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Fixes openwisp#166
Ported changes from storage.py in ansible-openwisp2 to storage.py in openwisp_utils/ .

Added documentation and written test for CompressStaticFilesStorage in openwisp_utils.storage
In documentation created a separate storage utilities section and in settings added OPENWISP_STATICFILES_VERSIONED_EXCLUDE.

Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Added django-compress-staticfiles~=1.0.1b in install_requires in setup.py.

Fixes openwisp#166
Co-authored-by: Gagan Deep <the.one.above.all.titan@gmail.com>
Co-authored-by: Gagan Deep <the.one.above.all.titan@gmail.com>
Ported changes from storage.py in ansible-openwisp2 to storage.py in openwisp_utils/ .

Added documentation and written test for `CompressStaticFilesStorage` in openwisp_utils.storage
In documentation created a separate storage utilities section and in settings added `OPENWISP_STATICFILES_VERSIONED_EXCLUDE`.

Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Added `django-compress-staticfiles~=1.0.1b` in install_requires in setup.py.

Fixes openwisp#166
Ported changes from storage.py in ansible-openwisp2 to storage.py in openwisp_utils/ .

Added documentation and written test for `CompressStaticFilesStorage` in openwisp_utils.storage
In documentation created a separate storage utilities section and in settings added `OPENWISP_STATICFILES_VERSIONED_EXCLUDE`.

Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Added `django-compress-staticfiles~=1.0.1b` in install_requires in setup.py.

Updated with requested changes.

Fixes openwisp#166
Ported changes from storage.py in ansible-openwisp2 to storage.py in openwisp_utils/
That is added class CompressStaticFilesStorage which can exclude files based on OPENWISP_STATICFILES_VERSIONED_EXCLUDE.

Added documentation and written test for CompressStaticFilesStorage in openwisp_utils.storage
In documentation created a separate storage utilities section and in settings added OPENWISP_STATICFILES_VERSIONED_EXCLUDE.

Created test_storage in tests/test_project/tests , The test creates a temporary folder and 2 text files in it and then runs collectstatic in that folder and checks whether the file hashed is correct or not and later deletes that folder.

Added django-compress-staticfiles~=1.0.1b in install_requires in setup.py.

Fixes openwisp#166
@Arsh0023 Arsh0023 force-pushed the issues/166-add-custom-static-storage branch from cadeb7a to 9e11834 Compare March 22, 2021 09:17
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @Arsh0023!

I have some minor request for changes, see my comment below, and one request for the commit message: such long commit messages are not needed for minor features like these.
Please make it shorter, and use [feature] for the prefix, since we're adding new functionality to the module and we are adopting conventional commit style messages.

README.rst Outdated Show resolved Hide resolved
`CompressStaticFilesStorage` is added in storage.py which can exclude files based on `OPENWISP_STATICFILES_VERSIONED_EXCLUDE`.
Added Documetation and tests for the above.

Fixes openwisp#166
@Arsh0023 Arsh0023 force-pushed the issues/166-add-custom-static-storage branch from ba067f9 to c976c1c Compare March 23, 2021 07:21
@Arsh0023 Arsh0023 changed the title Issues/166 add custom static storage [feature] Added a Custom Static Storage Mar 30, 2021
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @Arsh0023 & @pandafy 👍

@nemesifier nemesifier merged commit 42b2500 into openwisp:master Apr 3, 2021
@Arsh0023
Copy link
Contributor Author

Arsh0023 commented Apr 4, 2021

Thanks a lot @nemesisdesign and @pandafy 👍🤘

@nemesifier
Copy link
Member

Next step for this subject: openwisp/ansible-openwisp2#266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[feature] Add a custom static storage class
5 participants