diff --git a/src/mtgcoll/models/lists.clj b/src/mtgcoll/models/lists.clj index 82a3c9c..db434b5 100644 --- a/src/mtgcoll/models/lists.clj +++ b/src/mtgcoll/models/lists.clj @@ -17,18 +17,22 @@ (defn remove-list! [list-id] - (vexec! view-system db - ["delete from lists + (if (= 0 list-id) + (throw (Exception. "Cannot remove the 'Owned' list.")) + (vexec! view-system db + ["delete from lists where id = ?" - (int list-id)])) + (int list-id)]))) (defn update-list-name! [list-id name] - (vexec! view-system db - ["update lists + (if (= 0 list-id) + (throw (Exception. "Cannot change the name of the 'Owned' list.")) + (vexec! view-system db + ["update lists set name = ? where id = ?" - (str name) (int list-id)])) + (str name) (int list-id)]))) (defn update-list-note! [list-id note] @@ -40,8 +44,10 @@ (defn update-list-visibility! [list-id public?] - (vexec! view-system db - ["update lists + (if (= 0 list-id) + (throw (Exception. "Cannot change the visibility of the 'Owned' list.")) + (vexec! view-system db + ["update lists set is_public = ? where id = ?" - (boolean public?) (int list-id)])) + (boolean public?) (int list-id)]))) diff --git a/src/mtgcoll/views/functions/lists.clj b/src/mtgcoll/views/functions/lists.clj index 53bd97b..d58ff07 100644 --- a/src/mtgcoll/views/functions/lists.clj +++ b/src/mtgcoll/views/functions/lists.clj @@ -34,8 +34,7 @@ where lc.list_id = l.id ) as num_cards from lists l - where l.id != 0 - and l.is_public in (true, ?) + where l.is_public in (true, ?) order by l.name" public-only?])) @@ -44,7 +43,6 @@ (let [public-only? (nil? user-id)] ["select id, name from lists - where id != 0 - and is_public in (true, ?) + where is_public in (true, ?) order by name" public-only?]))