summaryrefslogtreecommitdiff
path: root/model.lisp
diff options
context:
space:
mode:
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)