aboutsummaryrefslogtreecommitdiffhomepage
path: root/model.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-27 15:10:28 -0500
committerColin Okay <colin@cicadas.surf>2022-10-27 15:10:28 -0500
commitf0586d83687271525f8d6f0874dbb924ecb7f7c2 (patch)
treef986423c0e272f0c51a9bf234002fa9c93776704 /model.lisp
parentf80c82597ffcf3a65cc49ffca8f3b7ffa8117c27 (diff)
Add: explore page; editor privilege views
Diffstat (limited to 'model.lisp')
-rw-r--r--model.lisp12
1 files changed, 12 insertions, 0 deletions
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)