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

Do not modify Download objects #3356

Merged
merged 1 commit into from
May 28, 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
6 changes: 2 additions & 4 deletions app/grandchallenge/serving/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

@admin.register(Download)
class DownloadAdmin(admin.ModelAdmin):
ordering = ("-modified",)
ordering = ("-created",)
list_display = (
"modified",
"count",
"created",
"creator",
"image",
"submission",
Expand All @@ -25,7 +24,6 @@ class DownloadAdmin(admin.ModelAdmin):
"feedback__pk",
)
readonly_fields = (
"count",
"creator",
"image",
"submission",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.13 on 2024-05-28 11:15

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("serving", "0002_download_challenge_request_and_more"),
]

operations = [
migrations.AlterUniqueTogether(
name="download",
unique_together=set(),
),
migrations.RemoveField(
model_name="download",
name="count",
),
]
5 changes: 0 additions & 5 deletions app/grandchallenge/serving/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,3 @@ class Download(models.Model):
feedback = models.ForeignKey(
Feedback, null=True, on_delete=models.CASCADE, editable=False
)

count = models.BigIntegerField(default=1, editable=False)

class Meta:
unique_together = ("creator", "image", "submission")
6 changes: 1 addition & 5 deletions app/grandchallenge/serving/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.conf import settings
from django.core.exceptions import MultipleObjectsReturned, PermissionDenied
from django.db.models import F
from django.http import Http404, HttpResponseRedirect
from django.utils._os import safe_join
from guardian.utils import get_anonymous_user
Expand Down Expand Up @@ -72,10 +71,7 @@ def _create_download(
"creator and only one other foreign key must be set"
)

n_updated = Download.objects.filter(**kwargs).update(count=F("count") + 1)

if n_updated == 0:
Download.objects.create(**kwargs)
Download.objects.create(**kwargs)


def serve_images(request, *, pk, path, pa="", pb=""):
Expand Down