1. Steve Losh
  2. newseasons

Commits

Steve Losh  committed 34a95eb

Delete account.

  • Participants
  • Parent commits 6b52e3b
  • Branches default

Comments (0)

Files changed (7)

File resources/public/css/style.less

View file
  • Ignore whitespace
         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 {

File src/newseasons/loops/refresh.clj

View file
  • Ignore whitespace
 (ns newseasons.loops.refresh
   (:require [newseasons.models.shows :as shows])
-  (:require [newseasons.itunes :as itunes])
-  )
+  (:require [newseasons.itunes :as itunes]))
 
 
 ; Dammit, Clojure.

File src/newseasons/loops/templates/email.clj

View file
  • Ignore whitespace
+(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"))

File src/newseasons/models/shows.clj

View file
  • Ignore whitespace
 ;
 ; 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:
 ;

File src/newseasons/models/users.clj

View file
  • Ignore whitespace
 (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))))

File src/newseasons/templates/main.clj

View file
  • Ignore whitespace
 
 (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 -----------------------------------------------------------------------
                     (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"))]))

File src/newseasons/views/main.clj

View file
  • Ignore whitespace
 (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 "/")))
+