From f0586d83687271525f8d6f0874dbb924ecb7f7c2 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 27 Oct 2022 15:10:28 -0500 Subject: Add: explore page; editor privilege views --- model.lisp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'model.lisp') diff --git a/model.lisp b/model.lisp index fc8d93f..42142ed 100644 --- a/model.lisp +++ b/model.lisp @@ -36,6 +36,10 @@ ;;; MODEL OPERATIONS +(defun can-edit-p (user playlist) + (or (eq (playlist-user playlist) user) + (member user (playlist-editors playlist) :test #'eq))) + (defun invite-by-code (code) "Returns NIL if CODE is an invalid invite code. Returns the INVITE instance otherwise" @@ -56,6 +60,14 @@ (when (equalp pwhash (hash-string password pwsalt)) user)))) +(defun last-change (obj) + (slot-value obj 'bknr.datastore::last-change)) + +(defun recent-playlists (&optional (count 10)) + (take count + (sort (copy-seq (store-objects-with-class 'playlist)) + #'> + :key #'last-change))) (defun playlist-duration (pl) (reduce #'+ (playlist-tracks pl) -- cgit v1.2.3