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

MVJ-111 upload attachments to custom directory [RETRY] #814

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

NC-jsAhonen
Copy link
Contributor

@NC-jsAhonen NC-jsAhonen commented Jan 14, 2025

All file fields are made into PrivateFileFields that have a custom file storage configured to them. The default for local settings is to save them to the codebase root under the /attachments/ directory, but the ATTACHMENTS_LOCATION and ATTACHMENTS_BASE_URL settings determine where the files will be stored.

@NC-jsAhonen
Copy link
Contributor Author

For some reason, the CI fails because of this false positive. The migrations mentioned on the logs have been removed. I wonder if this is an outdated cache issue.

Run python manage.py makemigrations --dry-run --check
  python manage.py makemigrations --dry-run --check
  python manage.py migrate
  shell: /usr/bin/bash -e {0}
  env:
    DATABASE_URL: ***localhost/github_actions
    pythonLocation: /opt/hostedtoolcache/Python/3.10.16/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.10.16/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.16/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.16/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.10.16/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.16/x64/lib
Migrations for 'forms':
  forms/migrations/0028_alter_attachment_attachment.py
    - Alter field attachment on attachment
Migrations for 'leasing':
  leasing/migrations/0090_alter_collectioncourtdecision_file_and_more.py
    - Alter field file on collectioncourtdecision
    - Alter field file on collectionletter
    - Alter field file on collectionlettertemplate
    - Alter field file on infilldevelopmentcompensationattachment
    - Alter field file on inspectionattachment
    - Alter field file on landuseagreementattachment
    - Alter field file on leaseareaattachment
Migrations for 'plotsearch':
  plotsearch/migrations/0043_alter_areasearchattachment_attachment_and_more.py
    - Alter field attachment on areasearchattachment
    - Alter field meeting_memo on meetingmemo

mvj/settings.py Outdated
MEDIA_URL = "/media/"
STATIC_URL = "/static/"
PRIVATE_FILES_BASE_URL = "/private_files/"
Copy link
Contributor

Choose a reason for hiding this comment

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

No base url is needed

super().__init__(**kwargs)
self.storage = PrivateFileSystemStorage(
location=settings.PRIVATE_FILES_LOCATION,
base_url=settings.PRIVATE_FILES_BASE_URL,
Copy link
Contributor

Choose a reason for hiding this comment

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

No base url needed

from django.db import models


class PrivateFileSystemStorage(FileSystemStorage): ... # noqa: E701
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider adding the location in the init of this class, since it is something we do not want to be configurable for this storage

Copy link
Contributor

@henrinie-nc henrinie-nc 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

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

Successfully merging this pull request may close these issues.

2 participants