Skip to content
admin.py 27.8 KiB
Newer Older
    raw_id_fields = ("participation",)

    list_display = (
            "get_course",
            "exam",
            "participation",
            "state",
            "creation_time",
            "usage_time",
            )

    date_hierarchy = "usage_time"

    search_fields = (
            "exam__course__identifier",
            "exam__flow_id",
            "exam__description",
            "participation__user__username",
            "participation__user__first_name",
            "participation__user__last_name",
            )

    # {{{ permissions

    def get_queryset(self, request):
        qs = super().get_queryset(request)
        return _filter_participation_linked_obj_for_user(qs, request.user)

    exclude = ("creator",)

    def save_model(self, request, obj, form, change):
        obj.creator = request.user
        obj.save()

    # }}}

    @admin.action(
        description=_("Revoke Exam Tickets")
    )
    def revoke_exam_tickets(self, request, queryset):
        queryset \
                .filter(state=exam_ticket_states.valid) \
                .update(state=exam_ticket_states.revoked)

    actions = [revoke_exam_tickets]

# vim: foldmethod=marker