upload.managers - Model managers for upload models

class upload.managers.UploadSessionManager(*args, **kwargs)

Bases: Manager

Custom manager for UploadSession model.

get_expirable() QuerySet

Return all expired upload sessions that can be set to EXPIRED.

A session can be expired if it has not been interacted with in at least UPLOAD_SESSION_EXPIRE_AFTER_INACTIVE_MINUTES minutes.

get_deletable() QuerySet

Return all upload sessions that can be safely deleted.

An upload session that can be safely deleted matches these criteria:

  • It has expired (either by checking the last_upload_interaction_time, or the status)

  • It is not linked to an in-progress submission.

If a session is linked to an InProgressSubmission, and matches the same last interaction criteria above, then it will be returned by get_expirable instead.