From 0843de1a643dee969f496398312fa2268d8227a0 Mon Sep 17 00:00:00 2001 From: sostler Date: Tue, 27 Apr 2010 23:26:54 -0400 Subject: Cleaned up debug code --- src/admin.clj | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'src/admin.clj') diff --git a/src/admin.clj b/src/admin.clj index ef33aa2..f0b6453 100644 --- a/src/admin.clj +++ b/src/admin.clj @@ -173,21 +173,36 @@ AND cancelled = false (.setAttribute st "mailtemps" (lookup-templates "template/mail" "welcome")) (.toString st)))) +(defn debug-reg-email [session params] + (send-registration-email (params :nick) + (params :to) + (params :template)) + (str "Sent registration mail to " (params :to))) + +(defn debug-reset-email [session params] + ) + +(def *debug-action-map* {"regemail" debug-reg-email + "resetemail" debug-reset-email}) + +(defn format-unknown-action [action] + (html [:h2 {"color" "red"} ["Unknown action " action]])) + +(defn format-debug-exception [action e] + (html + [:h2 {"color" "red"} + ["Caught exception in " action " -- " (.getMessage e)]] + :br + [:pre (exception-to-string e)])) + (defn debug-commmand! [session params] (if-vip - (let [action (:action params) - msg (try - (cond (= action "regemail") - (do (send-registration-email (params :nick) - (params :to) - (params :template)) - (str "Sent registration mail to " (params :to))) - :else (str "Unknown action: " action)) - (catch Exception e - (str "

Caught Exception in " action " --" - (.getMessage e) - "


"
-                     (exception-to-string e)
-                     "
")))] + (let [action (s/lower-case (:action params)) + func (*debug-action-map* action) + msg (if func + (try (func session params) + (catch Exception e + (format-debug-exception action e))) + (format-unknown-action action))] [(flash-assoc :msg msg) (redirect-to "/debug")]))) -- cgit v1.2.3-70-g09d2