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

Remove unused modified field on Upload model #1713

Merged
merged 1 commit into from
Oct 17, 2023
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
2 changes: 1 addition & 1 deletion dandiapi/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,5 @@ class AssetAdmin(admin.ModelAdmin):

@admin.register(Upload)
class UploadAdmin(admin.ModelAdmin):
list_display = ['id', 'upload_id', 'blob', 'etag', 'upload_id', 'size', 'modified', 'created']
list_display = ['id', 'upload_id', 'blob', 'etag', 'upload_id', 'size', 'created']
list_display_links = ['id', 'upload_id']
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.1.11 on 2023-10-16 16:37

from django.db import migrations
import django_extensions.db.fields


class Migration(migrations.Migration):
dependencies = [
('api', '0043_asset_asset_metadata_no_computed_keys_or_published'),
]

operations = [
migrations.RemoveField(
model_name='embargoedupload',
name='modified',
),
migrations.RemoveField(
model_name='upload',
name='modified',
),
migrations.AlterField(
model_name='embargoedupload',
name='created',
field=django_extensions.db.fields.CreationDateTimeField(auto_now_add=True),
),
migrations.AlterField(
model_name='upload',
name='created',
field=django_extensions.db.fields.CreationDateTimeField(auto_now_add=True),
),
Comment on lines +21 to +30
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this migration got created because TimeStampedModel defines created internally a bit differently using gettext_lazy https://github.com/django-extensions/django-extensions/blob/main/django_extensions/db/models.py#L17

]
6 changes: 4 additions & 2 deletions dandiapi/api/models/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.conf import settings
from django.core.validators import RegexValidator
from django.db import models
from django_extensions.db.models import TimeStampedModel
from django_extensions.db.models import CreationDateTimeField

from dandiapi.api.storage import (
get_embargo_storage,
Expand All @@ -19,13 +19,15 @@
from .dandiset import Dandiset


class BaseUpload(TimeStampedModel):
class BaseUpload(models.Model):
ETAG_REGEX = r'[0-9a-f]{32}(-[1-9][0-9]*)?'

class Meta:
indexes = [models.Index(fields=['etag'])]
abstract = True

created = CreationDateTimeField()

# This is the key used to generate the object key, and the primary identifier for the upload.
upload_id = models.UUIDField(unique=True, default=uuid4, db_index=True)
etag = models.CharField(
Expand Down
Loading