diff options
| author | sostler <sbostler@gmail.com> | 2010-04-27 23:26:54 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-04-27 23:26:54 -0400 |
| commit | 0843de1a643dee969f496398312fa2268d8227a0 (patch) | |
| tree | 4d97dd0b09ca323ca2998362ddd2b484c631afe3 /src/admin.clj | |
| parent | 42348f2924aad9d26be5e950ef148e237b62987a (diff) | |
Cleaned up debug code
Diffstat (limited to 'src/admin.clj')
| -rw-r--r-- | src/admin.clj | 43 |
1 files changed, 29 insertions, 14 deletions
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 "<h2 color=\"red\">Caught Exception in " action " --" - (.getMessage e) - "</h2><br><pre>" - (exception-to-string e) - "</pre>")))] + (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")]))) |
