Skip to content

Commit

Permalink
fix(models): try to address file handling in development without AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
cweider committed Oct 23, 2024
1 parent 81acc7d commit 774b069
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cl/search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.postgres.indexes import HashIndex
from django.core.exceptions import ValidationError
from django.core.files.storage import storages
from django.db import IntegrityError, models, transaction
from django.db.models import Q, QuerySet
from django.db.models.functions import MD5
Expand Down Expand Up @@ -41,7 +42,6 @@
normalize_search_dicts,
null_map,
)
from cl.lib.storage import IncrementingAWSMediaStorage
from cl.lib.string_utils import trunc
from cl.lib.utils import deepgetattr
from cl.search.docket_sources import DocketSources
Expand Down Expand Up @@ -664,7 +664,7 @@ class Docket(AbstractDateTimeModel, DocketSources):
"original RECAP architecture. These fields are for backup purposes "
f"only. {s3_warning_note}",
upload_to=make_recap_path,
storage=IncrementingAWSMediaStorage(),
storage=storages["document"],
max_length=1000,
blank=True,
)
Expand Down Expand Up @@ -2728,7 +2728,7 @@ class OpinionCluster(AbstractDateTimeModel):
filepath_pdf_harvard = models.FileField(
help_text="The case PDF from the Caselaw Access Project for this cluster",
upload_to=make_upload_path,
storage=IncrementingAWSMediaStorage(),
storage=storages["document"],
blank=True,
)
arguments = models.TextField(
Expand Down Expand Up @@ -3426,7 +3426,7 @@ class Opinion(AbstractDateTimeModel):
f"stored. {s3_warning_note}"
),
upload_to=make_upload_path,
storage=IncrementingAWSMediaStorage(),
storage=storages["document"],
blank=True,
db_index=True,
)
Expand Down
6 changes: 6 additions & 0 deletions cl/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,16 @@
STORAGES["staticfiles"] = {
"BACKEND": "cl.lib.storage.SubDirectoryS3ManifestStaticStorage",
}
STORAGES["document"] = {
"BACKEND": "cl.lib.storage.IncrementingAWSMediaStorage",
}
else:
STORAGES["staticfiles"] = {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
}
STORAGES["document"] = {
"BACKEND": "django.core.files.storage.FileSystemStorage",
}

TEMPLATES = [
{
Expand Down

0 comments on commit 774b069

Please sign in to comment.