-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
private file field and private files directory (#814)
- Loading branch information
1 parent
1021eb9
commit a4fd0f3
Showing
15 changed files
with
208 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
/.idea/ | ||
/.tox/ | ||
/media/ | ||
/private_files/ | ||
/static/ | ||
/venv/ | ||
/laske_export_files/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.2.16 on 2025-01-14 07:42 | ||
|
||
import django.core.files.storage | ||
from django.db import migrations | ||
import forms.models.form | ||
import utils.models.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("forms", "0026_alter_answer_user_alter_attachment_user"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="attachment", | ||
name="attachment", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=forms.models.form.get_attachment_file_upload_to, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Generated by Django 4.2.16 on 2025-01-14 07:42 | ||
|
||
import django.core.files.storage | ||
from django.db import migrations | ||
import leasing.models.debt_collection | ||
import leasing.models.infill_development_compensation | ||
import leasing.models.inspection | ||
import leasing.models.land_area | ||
import leasing.models.land_use_agreement | ||
import utils.models.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
( | ||
"leasing", | ||
"0088_remove_rent_old_dwellings_in_housing_companies_price_index_type_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="collectioncourtdecision", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=leasing.models.debt_collection.get_collection_court_decision_file_upload_to, | ||
verbose_name="File", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="collectionletter", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=leasing.models.debt_collection.get_collection_letter_file_upload_to, | ||
verbose_name="File", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="collectionlettertemplate", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to="collection_letter_templates/", | ||
verbose_name="File", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="infilldevelopmentcompensationattachment", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=leasing.models.infill_development_compensation.get_attachment_file_upload_to, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="inspectionattachment", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=leasing.models.inspection.get_inspection_attachment_file_upload_to, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="landuseagreementattachment", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=leasing.models.land_use_agreement.get_attachment_file_upload_to, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="leaseareaattachment", | ||
name="file", | ||
field=utils.models.fields.PrivateFileField( | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=leasing.models.land_area.get_attachment_file_upload_to, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 4.2.16 on 2025-01-14 07:42 | ||
|
||
import django.core.files.storage | ||
from django.db import migrations | ||
import plotsearch.models.plot_search | ||
import utils.models.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("plotsearch", "0041_alter_areasearch_options"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="areasearchattachment", | ||
name="attachment", | ||
field=utils.models.fields.PrivateFileField( | ||
blank=True, | ||
null=True, | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=plotsearch.models.plot_search.get_area_search_attachment_upload_to, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="meetingmemo", | ||
name="meeting_memo", | ||
field=utils.models.fields.PrivateFileField( | ||
blank=True, | ||
null=True, | ||
storage=django.core.files.storage.FileSystemStorage( | ||
base_url="/attachments/", location="attachments" | ||
), | ||
upload_to=plotsearch.models.plot_search.get_meeting_memo_file_upload_to, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import Any | ||
|
||
from django.conf import settings | ||
from django.core.files.storage import FileSystemStorage | ||
from django.db import models | ||
|
||
|
||
class PrivateFileSystemStorage(FileSystemStorage): | ||
def __init__(self) -> None: | ||
# base_url is not needed, but it defaults to MEDIA_URL if not explicitly set | ||
super().__init__(location=settings.PRIVATE_FILES_LOCATION, base_url=None) | ||
|
||
|
||
class PrivateFileField(models.FileField): | ||
def __init__(self, **kwargs: Any) -> None: | ||
super().__init__(**kwargs) | ||
self.storage = PrivateFileSystemStorage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters