34a95eb41902

Delete account.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 05 Oct 2011 20:32:33 -0400
parents 6b52e3b8fcd9
children 9275d33bd224
branches/tags (none)
files resources/public/css/style.less src/newseasons/loops/refresh.clj src/newseasons/loops/templates/email.clj src/newseasons/models/shows.clj src/newseasons/models/users.clj src/newseasons/templates/main.clj src/newseasons/views/main.clj

Changes

--- 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 {
--- 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.
--- /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"))
--- 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#{<iTunes artist ID>, ...}
+; shows:to-check = #{<iTunes artist ID>, ...}
 ;
 ; All current version IDs for shows are stored as a hash:
 ;
--- 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))))
--- 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"))]))
--- 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 "/")))
+