# HG changeset patch # User Steve Losh # Date 1317861153 14400 # Node ID 34a95eb41902f0df7b35568e5a0ded2893bfe9d7 # Parent 6b52e3b8fcd97978284470bf1b6c79913cb6be28 Delete account. diff -r 6b52e3b8fcd9 -r 34a95eb41902 resources/public/css/style.less --- a/resources/public/css/style.less Tue Oct 04 19:36:45 2011 -0400 +++ b/resources/public/css/style.less Wed Oct 05 20:32:33 2011 -0400 @@ -123,6 +123,17 @@ line-height: 1.25; } } +p.delete { + text-align: center; + color: #777; + margin-bottom: -18px; + padding-top: 12px; + border-top: 2px solid #ddd; + + a { + color: #555; + } +} // Pages .user { diff -r 6b52e3b8fcd9 -r 34a95eb41902 src/newseasons/loops/refresh.clj --- a/src/newseasons/loops/refresh.clj Tue Oct 04 19:36:45 2011 -0400 +++ b/src/newseasons/loops/refresh.clj Wed Oct 05 20:32:33 2011 -0400 @@ -1,7 +1,6 @@ (ns newseasons.loops.refresh (:require [newseasons.models.shows :as shows]) - (:require [newseasons.itunes :as itunes]) - ) + (:require [newseasons.itunes :as itunes])) ; Dammit, Clojure. diff -r 6b52e3b8fcd9 -r 34a95eb41902 src/newseasons/loops/templates/email.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/newseasons/loops/templates/email.clj Wed Oct 05 20:32:33 2011 -0400 @@ -0,0 +1,12 @@ +(ns newseasons.loops.templates.email) + + +(defn new-season [email show] + (str "A new season of " (:title show) " has just hit iTunes!" + "\n\n" + (:latest show) + "\n" + (:url show) + "\n\n" + "If you want to stop receiving these emails you can delete your account " + "by going to: http://newseasons.stevelosh.com/delete-account")) diff -r 6b52e3b8fcd9 -r 34a95eb41902 src/newseasons/models/shows.clj --- a/src/newseasons/models/shows.clj Tue Oct 04 19:36:45 2011 -0400 +++ b/src/newseasons/models/shows.clj Wed Oct 05 20:32:33 2011 -0400 @@ -20,7 +20,7 @@ ; ; The shows we need to check are stored in a set: ; -; shows:to-check = z#{, ...} +; shows:to-check = #{, ...} ; ; All current version IDs for shows are stored as a hash: ; diff -r 6b52e3b8fcd9 -r 34a95eb41902 src/newseasons/models/users.clj --- a/src/newseasons/models/users.clj Tue Oct 04 19:36:45 2011 -0400 +++ b/src/newseasons/models/users.clj Wed Oct 05 20:32:33 2011 -0400 @@ -44,3 +44,12 @@ (defn user-rem-show! [email show-id] @(r [:srem (key-user-shows email) show-id]) @(r [:srem (key-show-watchers show-id) email])) + + +(defn user-delete! [email] + @(r [:del (key-user email)]) + @(r [:del (key-user-shows email)]) + (let [shows @(r [:smembers "shows:to-check"])] + (dorun (map (fn [show-id] + @(r [:srem (key-show-watchers show-id) email])) + shows)))) diff -r 6b52e3b8fcd9 -r 34a95eb41902 src/newseasons/templates/main.clj --- a/src/newseasons/templates/main.clj Tue Oct 04 19:36:45 2011 -0400 +++ b/src/newseasons/templates/main.clj Wed Oct 05 20:32:33 2011 -0400 @@ -48,14 +48,20 @@ (defpartial inner [title body-class & content] (base body-class - [:h2.sixteen.columns.page-title - [:div.profile - (form-to [:post "/logout"] - (submit-button "Log Out")) - (form-to [:get "/password"] - (submit-button "Change Password"))] - title] - content)) + [:h2.sixteen.columns.page-title + [:div.profile + (form-to [:post "/logout"] + (submit-button "Log Out")) + (form-to [:get "/password"] + (submit-button "Change Password"))] + title] + content + [:p.delete.sixteen.columns + "Don't want to receive any more notifications? " + "You can " + (link-to "/delete-account" "delete your account") + "."] + )) ; Pages ----------------------------------------------------------------------- @@ -126,3 +132,10 @@ (form-to [:post ""] (field password-field "password" "New Password") (submit-button "Change Password"))])) + +(defpartial delete-account [] + (inner "Delete Your Account" "delete-account" + [:section.sixteen.columns + [:p "If you're sure about this you can delete your account here."] + (form-to [:post ""] + (submit-button "Delete Account"))])) diff -r 6b52e3b8fcd9 -r 34a95eb41902 src/newseasons/views/main.clj --- a/src/newseasons/views/main.clj Tue Oct 04 19:36:45 2011 -0400 +++ b/src/newseasons/views/main.clj Wed Oct 05 20:32:33 2011 -0400 @@ -146,3 +146,16 @@ (defpage [:post "/logout"] [] (sess/remove! :email) (resp/redirect "/")) + + +; Delete Account -------------------------------------------------------------- +(defpage [:get "/delete-account"] [] + (login-required + (t/delete-account))) + +(defpage [:post "/delete-account"] [] + (login-required + (users/user-delete! (sess/get :email)) + (sess/remove! :email) + (resp/redirect "/"))) +