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

fix: increase FileField maximum length to 380 characters #5390

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.15 on 2024-12-19 21:31

from django.db import migrations
import private_storage.fields
import private_storage.storage.files


class Migration(migrations.Migration):

dependencies = [
('markdownx_uploader', '0002_markdownxuploaderfilereference'),
]

operations = [
migrations.AlterField(
model_name='markdownxuploaderfile',
name='content',
field=private_storage.fields.PrivateFileField(
max_length=380,
storage=private_storage.storage.files.PrivateFileSystemStorage(),
upload_to='__markdown_media_files/%Y/%m/%d',
),
),
]
3 changes: 2 additions & 1 deletion kobo/apps/markdownx_uploader/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class MarkdownxUploaderFile(models.Model):
content = PrivateFileField(
# Avoid collisions with usernames, which must begin with `[a-z]`
# (see `kpi.forms.USERNAME_REGEX`)
upload_to='__markdown_media_files/%Y/%m/%d'
upload_to='__markdown_media_files/%Y/%m/%d',
max_length=380,
)

def __str__(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2.15 on 2024-12-19 21:31

from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.db import migrations

import kobo.apps.openrosa.apps.logger.models.attachment
import kobo.apps.openrosa.apps.logger.models.xform
import kpi.fields.file


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('logger', '0039_populate_counters'),
]

operations = [
migrations.AlterField(
noliveleger marked this conversation as resolved.
Show resolved Hide resolved
model_name='attachment',
name='media_file',
field=kpi.fields.file.ExtendedFileField(
db_index=True,
max_length=380,
storage=FileSystemStorage(),
upload_to=kobo.apps.openrosa.apps.logger.models.attachment.upload_to,
),
),
migrations.AlterField(
model_name='xform',
name='xls',
field=kpi.fields.file.ExtendedFileField(
max_length=380,
null=True,
storage=FileSystemStorage(),
upload_to=kobo.apps.openrosa.apps.logger.models.xform.upload_to,
),
),
]
7 changes: 6 additions & 1 deletion kobo/apps/openrosa/apps/logger/models/xform.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ class XForm(AbstractTimeStampedModel):
CLONED_SUFFIX = '_cloned'
MAX_ID_LENGTH = 100

xls = ExtendedFileField(storage=default_storage, upload_to=upload_to, null=True)
xls = ExtendedFileField(
storage=default_storage,
upload_to=upload_to,
null=True,
max_length=380,
)
json = models.TextField(default='')
description = models.TextField(default='', null=True)
xml = models.TextField()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.15 on 2024-12-19 21:31

from django.core.files.storage import FileSystemStorage
from django.db import migrations

import kobo.apps.openrosa.apps.main.models.meta_data
import kpi.fields.file


class Migration(migrations.Migration):

dependencies = [
('main', '0017_userprofile_submissions_suspended'),
]

operations = [
migrations.AlterField(
model_name='metadata',
name='data_file',
field=kpi.fields.file.ExtendedFileField(
blank=True,
max_length=380,
null=True,
storage=FileSystemStorage(),
upload_to=kobo.apps.openrosa.apps.main.models.meta_data.upload_to,
),
),
]
1 change: 1 addition & 0 deletions kobo/apps/openrosa/apps/main/models/meta_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class MetaData(AbstractTimeStampedModel):
upload_to=upload_to,
blank=True,
null=True,
max_length=380,
)
data_file_type = models.CharField(max_length=255, blank=True, null=True)
file_hash = models.CharField(max_length=50, blank=True, null=True)
Expand Down
2 changes: 1 addition & 1 deletion kpi/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def enketo_flush_cached_preview(server_url, form_id):
@celery_app.task(time_limit=LIMIT_HOURS_23, soft_time_limit=LIMIT_HOURS_23)
def perform_maintenance():
"""
Run daily maintenance tasks. Ensure it cannot run multiple times.
Run daily maintenance tasks.
"""

remove_unused_markdown_files()
Expand Down
Loading