Skip to content
Merged
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
7 changes: 7 additions & 0 deletions frx_challenges/web/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from allauth.account.decorators import secure_admin_login
from django.contrib import admin
from django.urls import reverse
from django.utils import timezone
from django.utils.html import format_html
from reversion.admin import VersionAdmin

Expand All @@ -20,6 +21,12 @@ class ContentFileAdmin(VersionAdmin):
@admin.register(Evaluation)
class EvaluationAdmin(VersionAdmin):
list_display = ("id", "status", "version_link", "submission_name", "version__user__username", "created_at", "last_updated")
actions = ["set_status_not_started"]

@admin.action(description="Set status to Not Started")
def set_status_not_started(self, request, queryset):
updated = queryset.update(status=Evaluation.Status.NOT_STARTED, last_updated=timezone.now())
self.message_user(request, f"{updated} evaluation(s) set to Not Started.")
Comment on lines +27 to +29

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

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

Using queryset.update(...) will bypass Model.save(), so Evaluation.last_updated (auto_now) won’t be bumped and any model signals won’t run. If you expect the admin bulk reset to reflect as a fresh update (and since last_updated is displayed and used for latest("last_updated")), consider also updating last_updated explicitly (e.g., to timezone.now()) or iterating and calling save() if signal behavior is required.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 70e18e4. The queryset.update() call now also sets last_updated=timezone.now() explicitly, ensuring the timestamp is bumped correctly since auto_now fields are bypassed by bulk queryset updates.


def version_link(self, obj):
url = reverse("admin:web_version_change", args=[obj.version.id])
Expand Down
Loading